ocean86
05-02-2010, 08:48 PM
Hi,
I create a widget type "PHP Direct Execution". In the PHP code that I've written, there is a cycle (while). When I insert this PHP code in the widget, the cycle doesn't function. Only the last result of the query it's printed.
This is the PHP Code:
$db_host = "localhost";
$db_user = "user";
$db_password = "pwd";
$db_name = "database";
$db = mysql_connect($db_host, $db_user, $db_password);
mysql_select_db($db_name, $db);
$countdown_true = "1";
$query_ViewCountdown = mysql_query("SELECT * FROM city WHERE countdown='$countdown_true'", $db);
$num_rows = mysql_num_rows($query_ViewCountdown);
if ($num_rows > 0)
while($row = mysql_fetch_array($query_ViewCountdown)){
$username = $row['id_user'];
$nave = $row['id_nave'];
$testo = "Pinco pallino parte $username davvero tanto bravo $nave "; }
$output = $testo; "<br />";
}
Why the cycle isn't execute?
Thank you and excuse me for bad english!
I create a widget type "PHP Direct Execution". In the PHP code that I've written, there is a cycle (while). When I insert this PHP code in the widget, the cycle doesn't function. Only the last result of the query it's printed.
This is the PHP Code:
$db_host = "localhost";
$db_user = "user";
$db_password = "pwd";
$db_name = "database";
$db = mysql_connect($db_host, $db_user, $db_password);
mysql_select_db($db_name, $db);
$countdown_true = "1";
$query_ViewCountdown = mysql_query("SELECT * FROM city WHERE countdown='$countdown_true'", $db);
$num_rows = mysql_num_rows($query_ViewCountdown);
if ($num_rows > 0)
while($row = mysql_fetch_array($query_ViewCountdown)){
$username = $row['id_user'];
$nave = $row['id_nave'];
$testo = "Pinco pallino parte $username davvero tanto bravo $nave "; }
$output = $testo; "<br />";
}
Why the cycle isn't execute?
Thank you and excuse me for bad english!