You are here: Re: another question: foreach() « All PHP « IT news, forums, messages
Re: another question: foreach()

Posted by Paul Kaspers on 05/09/06 12:01

Well in fact you only select 1 result, you don't go through the
resultset (more to read on www.php.net look under mysql_fetch_array).
The correct way to handle a db request is below.

function form_MS($formname, $method, $action){

$sql = "SELECT orders.MS FROM orders;";
$result = @mysql_query($sql);
$numrows = @mysql_num_rows($result);

if ($numrows == NULL){
return (false);
}
else
{

echo ("<form name=\"$formname\" method=\"$method\" action=\"$action\">\n");

echo ("<select name=\"MS\">\n");

while ($my_baby = mysql_fetch_array($result)){
echo ("<option
value=\"".$my_baby['orders.MS']."\">".$my_baby['orders.MS']."</option>\n");
}

echo ("</select>\n");
echo ("</form>\n");

}


}

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация