I can't figure out why the while loop isn't executing...All I know is that it only executes when there is data in the table for the field 'html'. If the field 'html' is blank, the while field does not execute. Why is this?
$state = $_POST['state'];
$tbl = $_POST['tbl'];
$state_id = state_id($state);
$html_sql = "SELECT * FROM `{$tbl_prefix}{$tbl}` WHERE `stateid` = '".$state_id."' LIMIT 1";
$html_query = mysql_query($html_sql) or die("MODIFY QUERY: " . mysql_error());
echo "<form method='post' action='$PHP_SELF?act=modify'>";
while($html_row = mysql_fetch_array($html_query))
{
echo "<textarea name='html' cols='100' rows='15'>{$html_row[code=html]}</textarea><br>";
}
echo "<input name='state_id' type='hidden' value='$state_id'>";
echo "<input name='tbl' type='hidden' value='$tbl'>";
echo "<input type='submit' name='Modify' value='Modify'>";
echo "</form>";
The state_id function
function state_id($state)
{
global $tbl_prefix;
$sql = "SELECT * FROM `{$tbl_prefix}states` WHERE `state` = '".$state."' LIMIT 1";
$query = mysql_query($sql) or die("STATE FUNCTION: " . mysql_error());
while($row = mysql_fetch_array($query))
{
return $row[id];
}
}