Jump to content

retrieve dynamic variable from post data


sherric

Recommended Posts

how to get the array variable for the selected $row['name']. i've been fighting with this for what seems like days, and just can't get the code lined out. 

 

here's my code:

:-\//select the table

$result = mysql_query("select * from equipment where catid=3")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/>";

 

}

}

 

} else { // if form isn't submitted, output the form

 

print "<form action=\"index2.php\" method=\"POST\">\n";

 

if ($result) {

print "<table width=200 border=1>\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=\"test\"></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=\"catid\" value='3'>\n";

print "<input type=\"hidden\" name=\"cats\" value=\"$i\"/>\n";

print "<tr>";

 

print "<td>";

print "<input type=\"submit\" name=\"submit\" value=\"Go\"/>\n";

print "</td></tr>\n";

 

 

}//end while

print "</table>\n";

 

any help is appreciated!

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.