sniperscope Posted December 24, 2008 Share Posted December 24, 2008 Hi guys could some tell me what is wrong with this code ? echo $query returns exactly what i want but when i check db, it update only one column which is flag column of last row of query. Here is the Query; mysql_select_db($database_deli24, $deli24); mysql_query($query) or die ("Error in query: $query"); $size = count($_POST['nick_name']); // find out how many records there are to update $i = 0; while ($i < $size) { //make a loop for number of records $name = $_POST['name'][$i]; $is_working = $_POST['is_working'][$i]; $start_hour = $_POST['start_hour'][$i]; $start_min = $_POST['start_min'][$i]; $finish_hour = $_POST['finish_hour'][$i]; $finish_min = $_POST['finish_min'][$i]; $flag = $_POST['asktoadmin'][$i]; $query = "UPDATE shukkin SET is_working='$is_working', name='$name', start_hour='$start_hour', start_min='$start_min', finish_hour='$finish_hour', finish_min='$finish_min', flag='$flag' WHERE name='$name' LIMIT 1"; echo "$i QUERY WAS = = =$query<br><br>"; ++$i; } mysql_close(); End this is result of echo $query UPDATE shukkin SET is_working='1', name='mike', start_hour='18', start_min='40', finish_hour='22', finish_min='40', flag='1' WHERE name='mike' LIMIT 1 if i run this query directly from phpmyadmin sql_also doesn't update without any error. Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted December 24, 2008 Share Posted December 24, 2008 add.. mysql_query($query) or die(mysql_error()); after $query... you're not even running the query O_o where you have the query at the top isn't going to work. It needs to be after $query. Quote Link to comment Share on other sites More sharing options...
d.shankar Posted December 24, 2008 Share Posted December 24, 2008 Goodfinding MasterACE Quote Link to comment Share on other sites More sharing options...
sniperscope Posted December 24, 2008 Author Share Posted December 24, 2008 Excelent, Excelent, Excelent. I just miss the point that i run the query after loop finished. So i took it into loop. Now works perfect. Quote Link to comment Share on other sites More sharing options...
d.shankar Posted December 24, 2008 Share Posted December 24, 2008 Click "Topic Solved" please Quote Link to comment Share on other sites More sharing options...
revraz Posted December 24, 2008 Share Posted December 24, 2008 I don't see how this did not work from phpmyadmin. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.