One more newbie question. About foreach..
| From: | Karl-Arne Gjersøyen | Date: | Sun, 23 Jun 2013 15:11:06 +0000 |
| Subject: | One more newbie question. About foreach.. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-321463@lists.php.net to get a copy of this message | ||
Hello again. I Got the solution for my last mention problem. Now I can
update several rows at once by one single submit action.
In my form I have many records and therefor I use an checkbox to just mark
those records I like to update. This work just fine in PHP/HTML5 form and I
got it as I want.
But the problem now is, how to recognize just those selected records by
serialnumber?
include('../../connect.php');
// Foreach get all given serialnumbers as I want it
foreach($serialnumber as $snr){
// I got the number of serialnumbers given in the array
$count = count($serialnumber);
// I thought that a for loop would do the trick together with foreach
// And repeat the $sql = SELECT below but that did not happen.
for($i = 0; $i <= $count; $i++){
// Connect and get only those records with given serialnumber
$sql = "SELECT * FROM explosive WHERE serialnumber = '$snr'";
} // End of for loop
} // End of foreach loop
$result = mysql_query($sql, $connect) or die(mysql_error());
$count = mysql_num_rows($result);
I have tried to search in google and on PHP.net but can't fine anything
that explain my problem.
I like to have new $sql = SELECT queries for every given serialnumber ($snr)
Thanks for your help.
Karl