|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
simple multiple ROW UPDATE?
i have a table that i only want to update two fields. (rate, apy).
for an example i only have two entries. i've posted the code i'm trying to use, but with no luck. can someone please help me? thank you in advance! ---------- <html> <body> <? require "../include/settings.inc"; if ($submit) { // process form $db = mysql_connect($host, $user, $password); mysql_select_db($database,$db); $sql = "UPDATE account_rates SET rate='$platinum', apy='$platinum_apy' WHERE id= 1"; $sql .= "AND SET rate='$checkingplus', apy='$checkingplus_apy' WHERE id= 2"; mysql_query($sql); echo "Thank you! Information has been updated.n"; } else{ // display form ?> <form method="post" action="<? echo $PHP_SELF?>"> Platinum Rate:<input type="Text" name="platinum"><br> Platinum APY:<input type="Text" name="platinum_apy"><br> Checking Plus Rate:<input type="Text" name="checkingplus"><br> Checking Plus APY:<input type="Text" name="checkingplus_apy"><br> <input type="Submit" name="submit" value="Enter information"> </form> <?php } // end if ?> </body> </html> ---------------- |
|
#2
|
|||
|
|||
|
RE: simple multiple ROW UPDATE?
WHERE id= 1
WHERE id= 2 should be: WHERE id= '1' WHERE id= '2' at least thats the way I would write it. If anyone else can elaborate it would be great. |
|
#3
|
|||
|
|||
|
RE: simple multiple ROW UPDATE?
thanks, but either way i write it,
with '1' or without 1, it still doesn't work. |
|
#4
|
|||
|
|||
|
RE: simple multiple ROW UPDATE?
try splitting up the query into two separate ones and see which is causing the problem.
also do you have register globals set to yes in php.ini? If not you will have to pull your post data from $_POST[] variables. Example $sql = "UPDATE account_rates SET rate='$_POST[platinum]'....... |
|
#5
|
||||
|
||||
|
RE: simple multiple ROW UPDATE?
Try to capture the variable $sql before you do mysql_query(), run it on phpMyAdmin. I'm sure that phpMyAdmin will said that the sql statement is bad. If you want to update 2 row with different ID or nothing is same between those 2 row then you have to do the sql execution twice.
|
|
#6
|
|||
|
|||
|
RE: simple multiple ROW UPDATE?
that did it!
sometimes it helps for someone with fresh eyes to see an easy solution. thanks again all! |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Database Help > simple multiple ROW UPDATE? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|