|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
From reading past posts I 'think' this should work but it isn't. Help please.
I am trying to update the column 'ourpage' in all rows of the database busdir2 where cat=farming. It reads only rows where cat=farming correctly but isn't getting the ourpage value into the table. **************** $result = mysql_query("SELECT * FROM busdir2 WHERE cat='FARMING' ORDER by state, city, who ASC",$db); if ($myrow = mysql_fetch_array($result)) { do { printf("%s , %s , %s<BR><BR><BR>n", $myrow["cat"], $myrow["ourpage"], $myrow["id"]); { "UPDATE busdir2 SET ourpage = 'newvalue' WHERE id=$id"; } } while ($myrow = mysql_fetch_array($result)); } else { echo "Sorry, no records were found!"; } ************************* The printf() was inserted to check which rows were being picked out. Should it be removed for the update to work? Grasping at straws, stujohnson |
|
#2
|
||||
|
||||
|
Is this your actual code? You're update shoudl be within mysql_query().
Also, I think you can do this update with just one sql statement. $result = mysql_query("UPDATE busdir2 SET ourpage='newvalue' WHERE cat='FARMING'"); Isn't that what you're shooting for? ---John Holmes... |
|
#3
|
|||
|
|||
|
Thanks John.
The above did the trick. stujo |
![]() |
| Viewing: Dev Shed Forums > Databases > MySQL Help > update not going through |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|