I am trying to fetch contents of my MySQL database and put them into form fields.
The database has the following fields and values:
id0: 1a
code0: 1001
name0: Test
type0: Test
The idea is to have more and more data being put into the database, the 2nd row of form fields is going to be id1,code1 and so on.
I currently have this code:
<?php
// Fetch tags from database
$gettags = mysql_query('SELECT * FROM `tags_' . $_GET['pid'] . '`',$db);
// Save results as vars
$row = 0;
$num = 0;
while(mysql_num_rows($gettags) <= $row) {
$code[$row] = mysql_result($gettags,$num);
if(isset($_GET['debug'])) {
echo "\$code[\$row]: " . $code[$row] . "\n";
}
$num++;
$id[$row] = mysql_result($gettags,$num);
if(isset($_GET['debug'])) {
echo "\$id[\$row]: " . $id[$row] . "\n";
}
$num++;
$name[$row] = mysql_result($gettags,$num);
if(isset($_GET['debug'])) {
echo "\$name[\$row]: " . $name[$row] . "\n";
}
$num++;
$type[$row] = mysql_result($gettags,$num);
if(isset($_GET['debug'])) {
echo "\$type[\$row]: " . $type[$row] . "\n";
}
$num++;
echo " <tr>\n";
echo "\t<td><div align=\"center\"><input name=\"id" . $row . "\" type=\"text\" size=\"4\" maxlength=\"3\" value=\"" . $id[$row] . "\"></div></td>\n";
echo "\t<td><div align=\"center\"><input name=\"code" . $row . "\" type=\"text\" size=\"5\" maxlength=\"4\" value=\"" . $code[$row] . "\"></div></td>\n";
echo "\t<td><div align=\"center\"><select name=\"type" . $row . "\"><option>" . $type[$row] . "</option></select></div></td>\n";
echo "\t<td><div align=\"center\"><input name=\"name" . $row . "\" type=\"text\" value=\"" . $name[$row] . "\"></div></td>\n";
echo "\t<td><div align=\"center\"><input name=\"add" . $row . "\" type=\"submit\" value=\"+\"> <input name=\"del" . $row . "\" type=\"submit\" value=\"-\"></div></td>\n";
echo " </tr>\n";
$row++;
}
?>
But the whole while() doesn't seem to get executed at all, because the output under "if(isset($_GET['debug']))" is not at all shown when I add &debug to the querystring. What am I doing wrong here ?