UPDATE multiple rows? SOLVED
Posted: Thu Jan 13, 2011 4:55 pm
hey can someone advice me on how to make my update script update multiple rows.
here's what i've got so far:
update.php
and now the handler script: mysql_update.php
When I try this I get nothing, no changes. In the table there is 3 distinct rideNames each have more than 20 rows. Is there a way using the drop down box and ext field like i Have to update all of the distinct rideNames in the table?
Thanks.
here's what i've got so far:
update.php
Code: Select all
<?php
require('connect.php');
$update = mysql_query("SELECT DISTINCT rideName FROM ride ORDER BY rideName DESC" );
$numrows = mysql_num_rows($update);
echo "<form action='mysql_update.php' method='POST'>
<select name='updateRide' >";
while ($row=mysql_fetch_assoc($update))
{
#$rideID = $row ['rideID'];
$rideName = $row ['rideName'];
#$seatNumber = $row ['seatNumber'];
#$time = $row ['time'];
#$price = $row ['price'];
echo "<option value='$id'> $rideName </option>";
}
echo "</select>
<input type='text' name='tochange'>
<input type='submit' name='submit' value='change'>
</form>";
?>
and now the handler script: mysql_update.php
Code: Select all
<?php
require ('connect.php');
$updateRide=$_POST['updateRide'];
$tochange=$_POST['tochange'];
if ($updateRide&&$tochange)
{
$change = mysql_query("UPDATE ride SET rideName='$tochange'
WHERE $id='updateRide'");
}
?>
Thanks.