PHP and MySQL
| From: | Vincent van Os | Date: | Thu, 11 Oct 2001 20:52:31 +0000 |
| Subject: | PHP and MySQL | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-13272@lists.php.net to get a copy of this message | ||
hej there
first i want to tell that im new to php and that im not an native english
speaking person (dutch, the netherlands) so excuse me for my bad english
but now the issue :
im trying to fetch info from an database and put it into checkboxes (source
will follow) that works so far
but then i want to check some boxes and see the result under it when i
press the submit button. im doing this with the var $vun<nummer here>
so check box one wil be $var1 second will be $var2 and so on
this wil stop untill it finds the last row in the table
now i want to walk trough al the $vun* vars to see it the check box is on or
not and if it is the row from the table must be printed below the
checkboxes. im doing this with the $rows var ( $rows =
mysql_num_rows($result); ) and an while loop. i use the $x var to count
($x++) so i can use the $x and the $vun together so it wil result to $vun1
($vun[$x] where $x is "1" ) but that wont work
if someone has the solution please let me know
Vincent van Os
ps below you wil find an simpel version of the source
----------------------begin source-------------------
<?
$user = "foo";
$host = "foo";
$pwd = "foo";
$database = foo;
$table = "foo";
$db = mysql_connect("$host", "$user", "$pwd");
$result = mysql($database,"select * from $table");
$fields = mysql_num_fields($result);;
$rows = mysql_num_rows($result);
$fields = mysql_list_fields("$database", "$table", $db);
$columns = mysql_num_fields($fields);
echo "<BR>";
for ($i = 0; $i < $columns; $i++) {
echo mysql_field_name($fields, $i) . "\n";;
}
echo "<FORM METHOD=POST ACTION=this_page.php>";
$var = "1";
while ($row = mysql_fetch_array($result)) {
echo "$var";
echo "<INPUT TYPE=CHECKBOX NAME=vun$i>$row[src_ip] $row[dest_ip]
$row[drop_ip] $row[reject_ip] $row[allow_ip] ";
$var++;
echo "<BR>";
}
echo "<INPUT TYPE=SUBMIT VALUE=SUBMIT>";
echo "</FORM>";
//
// problem is here
//
$x = 1;
while ( $rows >= $x ) {
echo "$x is $vun[$x]".
$x++;
}
mysql_close;
?>
------------------end source----------------