can't output sql query with php code.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

I have a mysql database setup to use with my php web page.  I have
been able to access the database and get values into my drop down
menus.  However when I tried to output the contents into two two
diferent variables the code does not work.  To be more specific I will
show you the code both the one that works and the one that doesn't

Doesn't work
-------------------------------------------------
<?php
$month_query = mysql_query("SELECT m_id, months FROM Month");
while ($row = mysql_fetch_array($month_query))
{
     $val = $row["m_id"];
     $out = $row["months"];
     echo "<option value=$val>$out</option>";
}
?>

---------------------------------------------
Code that works
---------------------------------------------
<?php
			
	echo '  <select name="equipment" size="1" id="equip" onChange="addRow()">';
	$Equip_query = mysql_query("SELECT equip FROM Equipment ORDER BY
equip ASC");
		 	
	while ($r = mysql_fetch_array($Equip_query))
	{
		 $val = $r["equip"];
		 echo "<option value=$val>$val</option>\n";
	}
	echo "</select></td>";
?>

Also I should tell you that the code that works comes after the code
that doesn't work in my web page.

Oh for the values that are outputted in the code that doesn't work are
val is numeric and out is a string.

I know my sql query works because I tested it in mysql.

Thanks for the help

Paul

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux