PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?php
require ('connect.php');
$updateRide=$_POST['updateRide'];
$tochange=$_POST['tochange'];
if ($updateRide&&$tochange)
{
$change = mysql_query("UPDATE ride SET rideName='$tochange'
WHERE $id='updateRide'");
}
?>
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.
Last edited by jsk1gcc on Thu Jan 13, 2011 6:42 pm, edited 1 time in total.
I am a little confused, Where are you getting the $id variable, and in your update script why are you saying where $id='updateRide' instead od id='UpdateRide. Is there a column in your table called id?
The answer is you're passing no $id. The way you'd arrive at that answer is by looking at the mysql_error() function and also echo the query before you run it through mysql_query() and look at the SQL you're sending to the database.
<?php
require ('connect.php');
$ride_name=$_POST['ride_name'];
$tochangeRide=$_POST['tochangeRide'];
if ($ride_name&&$tochangeRide)
{
$changeR = mysql_query("UPDATE ride SET rideName='$tochangeRide'
WHERE rideID='$ride_name'");
}
echo "You have updated the ride name to $tochangeRide";
?>