Ask the great God for help with PHP questions.

Source: Internet
Author: User
Tags php and mysql
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

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.