Refresh Function//refresh Item Statusfunction Refresh () {$problem = false; $result = mysql_query ("Select item_id from ITE M WHERE END > Now () and STATUS! = ' SOLD '), if ($result) {while ($row = Mysql_fetch_array ($result)) {$act _id = $row [' Item_i D '];mysql_query ("UPDATE ITEM SET STATUS = ' ACTIVE ' WHERE item_id = $act _id");} $result = mysql_query ("Select item_id, winner_id, END from ITEM WHERE end <= Now () and STATUS! = ' SOLD '"); if ($result) {W Hile ($row = mysql_fetch_array ($result)) {$exp _id = $row [' item_id ']; $win _id = $row [' winner_id ']; $time = $row [' END '];// Error here. There is the only one row have been displayed. There should be 4 rows actully. Result:7 0 2013-04-14 00:00:00 Echo $exp _id. "
"Echo $win _id."
"Echo $time."
"if ($win _id = = 0) {mysql_query (" UPDATE ITEM SET STATUS = ' EXPIRE ' WHERE item_id = $exp _id ");} Else{mysql_query ("UPDATE ITEM SET STATUS = ' SOLD ' WHERE item_id = $exp _id"); echo "INSERT into Item_sold VALUES ($exp _id, $wi n_id, ' ". $time." ', ' n ') "; mysql_query (" INSERT into Item_sold VALUES ($exp _id, $win _id, ' ". $time." ', ' n ') ");} $result = mysql_query ("Select item_id from ITEM WHERE BEGIN > Now () and STATUS! = ' SOLD ')"), if ($result) {while ($row = my Sql_fetch_array ($result)) {$na _id = $row [' item_id '];mysql_query ("UPDATE ITEM SET STATUS = ' na ' WHERE item_id = $na _id");}} else{$problem = True;}} else{$problem = True;}} else{$problem = true;} if ($problem) {print 'Cannot refresh active item.
';}}
Same query in PhpMyadmin, but different result:
SQL Query:select item_id, winner_id, END from ITEM WHERE end <= Now () and STATUS! = ' SOLD ' LIMIT 0, 30;
Rows:4
item_id winner_id END
2 4 2013-04-14 00:00:00
4 2 2013-04-13 00:00:00
6 1 2013-04-14 00:00:00
7 0 2013-04-14 00:00:00
Anyone can help me to solve the problem? Thanks a lot!!!
Reply to discussion (solution)
The Mysql_fetch_array () function takes a row from the result set as an associative array, or as an array of numbers, or both on the lines of you code
The Mysql_fetch_array () function takes a row from the result set as an associative array, or as an array of numbers, or both on the lines of you code
I don ' t quite understand ... Any suggested solution?
(I don ' t have the Chinese input software on the computer, sorry about ...)
I mean the function mysql_fetch_array () Just return one row result
u Use the Funciton function mysql_fetch_array () of the Code on line have a error ...
Mysql_fetch_array? Fetch a result row as an associative array, a numeric array, or both
http://www.php.net/manual/en/function.mysql-fetch-array.php
u Use the Funciton function mysql_fetch_array () of the Code on line have a error ...
Mysql_fetch_array? Fetch a result row as an associative array, a numeric array, or both
http://www.php.net/manual/en/function.mysql-fetch-array.php
Thanks for taking time to answer my question. But I am new to PHP and MySQL, I cannot solve this myself.
Can you just simply give me a solution?
I mean the function mysql_fetch_array () Just return one row result
I am SO sorry!
Something is wrong in my database connection header file ...
I choosed the wrong database. Now it is fixed.
I mean the function mysql_fetch_array () Just return one row result
I am SO sorry!
Something is wrong in my database connection header file ...
I choosed the wrong database. Now it is fixed.
Congratulation