sherric Posted August 26, 2009 Share Posted August 26, 2009 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! Link to comment https://forums.phpfreaks.com/topic/171968-retrieve-dynamic-variable-from-post-data/ Share on other sites More sharing options...
ram4nd Posted August 26, 2009 Share Posted August 26, 2009 use mysql_fetch_assoc($result) Link to comment https://forums.phpfreaks.com/topic/171968-retrieve-dynamic-variable-from-post-data/#findComment-906823 Share on other sites More sharing options...
sherric Posted August 27, 2009 Author Share Posted August 27, 2009 i have actually looked at that, but couldn't figure out how to plug it into my code. would i use it in lieu of mysql_fetch_array, or as an additional query? Link to comment https://forums.phpfreaks.com/topic/171968-retrieve-dynamic-variable-from-post-data/#findComment-907294 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.