with this code, i can retrieve the row number that is selected, but not any of the actual values - name, id etc. how do i retrieve that?
here's my code:
//select the table
$result = mysql_query("select * from equipment where catid=4")or die(mysql_error());
if ( isset($_POST['submit']) ) { // if form is submitted, process it
for($i=1; $i<=$_POST['cats']; $i++) {
if ( isset($_POST["cat$i"] ) ) {
print $i." is checked.<br/>";
print "category = ".$catid."<br/>";
$result = mysql_query("select * from equipment where catid=4")or die(mysql_error());
}
}
} else { // if form isn't submitted, output the form
print "<form action=\"index.php\" method=\"POST\">\n";
if ($result) {
print "<table width=200 border=1>\n";
print "<tr>\n";
print "<th>Â* </th>\n";
print "<th> State </th>\n"; //2 fields in Counties table, State and County
print "<th> County </th>\n";
print "<input type=\"submit\" name=\"submit\" value=\"Go\"/>\n";
print "</tr>\n";
//create table
$i = 0;
while ( $row = mysql_fetch_array($result) ) {
$i++;
print "<tr>\n";
print "<td><input type=\"checkbox\" name=\"cat$i\" value=\"$row[id]\"></td>\n";
echo "<td>{$row['id']}</td>\n";
echo "<td>{$row['name']}</td>\n";
echo "</tr>\n";
}//end while
print "</table>\n";
} else {
echo("<P>Error performing query: " .
mysql_error() . "</P>");
}
print "<input type=\"hidden\" name=\"test\" value=$row[name]>\n";
print "<input type=\"hidden\" name=\"catid\" value='4'>\n";
print "<input type=\"hidden\" name=\"cats\" value=\"$i\"/>\n";
}
?>
here's my code:
//select the table
$result = mysql_query("select * from equipment where catid=4")or die(mysql_error());
if ( isset($_POST['submit']) ) { // if form is submitted, process it
for($i=1; $i<=$_POST['cats']; $i++) {
if ( isset($_POST["cat$i"] ) ) {
print $i." is checked.<br/>";
print "category = ".$catid."<br/>";
$result = mysql_query("select * from equipment where catid=4")or die(mysql_error());
}
}
} else { // if form isn't submitted, output the form
print "<form action=\"index.php\" method=\"POST\">\n";
if ($result) {
print "<table width=200 border=1>\n";
print "<tr>\n";
print "<th>Â* </th>\n";
print "<th> State </th>\n"; //2 fields in Counties table, State and County
print "<th> County </th>\n";
print "<input type=\"submit\" name=\"submit\" value=\"Go\"/>\n";
print "</tr>\n";
//create table
$i = 0;
while ( $row = mysql_fetch_array($result) ) {
$i++;
print "<tr>\n";
print "<td><input type=\"checkbox\" name=\"cat$i\" value=\"$row[id]\"></td>\n";
echo "<td>{$row['id']}</td>\n";
echo "<td>{$row['name']}</td>\n";
echo "</tr>\n";
}//end while
print "</table>\n";
} else {
echo("<P>Error performing query: " .
mysql_error() . "</P>");
}
print "<input type=\"hidden\" name=\"test\" value=$row[name]>\n";
print "<input type=\"hidden\" name=\"catid\" value='4'>\n";
print "<input type=\"hidden\" name=\"cats\" value=\"$i\"/>\n";
}
?>