Topic awaiting preservation: Silly mysql question (Page 1 of 1) |
|
---|---|
Paranoid (IV) Inmate From: 1393 |
posted 09-20-2006 19:27
When I have code: mysql_query("UPDATE " . TABLE_USERS . " SET user = ''"); It seems to update all rows under "user"... which is what I want; my question, is that the proper way to update all rows within the table? I'm testing with a very small number of rows but eventually it will be huge and I don't want problems in the futre. Thanks. code: mysql_query("SELECT * FROM " . TABLE_USERS); ... naturaly. |
Maniac (V) Inmate From: |
posted 09-20-2006 20:03
Yes. |
Maniac (V) Mad Scientist with Finglongers From: Germany |
posted 09-20-2006 20:10
Now... why would you ever update *all* the rows? |
Paranoid (IV) Inmate From: 1393 |
posted 09-20-2006 21:11
Cool thanks! |
Paranoid (IV) Inmate From: 1393 |
posted 09-23-2006 04:53
Ok, now I'm having trouble on the other side... sort of... code: for ($i = 0; $i < $num_rows; $i++) { $hits = mysql_result($result, $i, "total_hits"); mysql_query("UPDATE " . TABLE_USERS . " SET temp_hits = " . $hits); } I'm grabbing "total_hits" from row $i out of the database, how do I update "temp_hits" w/ only the total hits from row $i... the above example will populate all "temp_hits" to the number in the last row. If that makes any sense... |
Paranoid (IV) Inmate From: 1393 |
posted 09-23-2006 16:30
duh code: for ($i = 0; $i < $num_rows; $i++) { $hits = mysql_result($result, $i, "total_hits"); $id = mysql_result($result, $i, "id"); mysql_query("UPDATE " . TABLE_USER_HITS . " SET temp_hits = " . $hits . " WHERE id = " . $id); } I guess I just needed some sleep... I'll try not to ask questions late at night anymore |