Forum Moderators: coopster
Can anyone help please?
some of my code:
while ( $row = mysql_fetch_array($result) )
echo .. <input type='text' name='description' value=".$row[tea_choice].">
...
You might want to try:
<input type='text' name='description' value=".htmlentities($row[tea_choice]).">
If there is a " character in your variable, it would otherwise close the attribute in the HTML you're trying to place the value into.
htmlentities [us2.php.net] converts all applicable characters to HTML entities
this is my code:
$result = mysql_query("select * from cp_teas"); //query the database
if (!$result) //error check
{
echo("<P>Error performing query:".mysql_error() );
exit();
}
echo ("<table>");
echo ("<tr align=center>");
echo ("<th>Choice</th>");
echo ("<th>Decription</th>");
echo ("<th>Price</th>");
echo ("<th>Order</th>");
echo ("</tr>");
while ( $row = mysql_fetch_array($result) ) //return results line by line
{
echo ("<tr>");
echo "<td> <form><input type='text' name='choice' value=".$row[tea_choice]"></td>";
echo "<td> <form><input type='text' name='descrtiption' value=".$row[tea_desc]."></td>";
echo "<td> <form><input type='text' name='price' value=".$row[tea_price]."></td>";
}
echo ("</table></center>");
?>
while ( $row = mysql_fetch_array($result) ) //return results line by line
{
print_r($row);
CONTINUE;
}
exit(0);
If the variables look OK, then you can assume it's the PHP or the HTML formatting that's causing problems.
The HTML you supplied may cause problems, You might want to put the beginning of your <form> when you output <table> and close it along with the table after the while loop. You included <form> within each row of the MySQL output, which would cause problems later on when you're trying to update the database.
Can it be done?
eg:
$menu1 = mysql_query("..."); //query the database tea table
$menu2 = mysql_query("...");
echo "<td>"."<input type='button' value='Teas' name='button1' onclick='".$menu1."'></td>";//
echo "<td><input type='button' value='Platters' name='button2' onclick='".$menu2."'></td>";//
if ($menu1) {...}
if ($menu2) {...}