PHP问题求助,请大神帮忙。

php中文网
发布: 2016-06-27 13:18:06
原创
1090人浏览过

//refresh function//refresh item statusfunction refresh(){		$problem = false;	$result = mysql_query("SELECT ITEM_ID FROM ITEM WHERE END > NOW() AND STATUS != 'SOLD'");	if($result)	{			while ($row = mysql_fetch_array($result))		{			$act_id = $row['ITEM_ID'];			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)		{					while ($row = mysql_fetch_array($result))			{				$exp_id = $row['ITEM_ID'];				$win_id = $row['WINNER_ID'];				$time = $row['END'];								// Error here. There is only one row has been displayed. There should be 4 rows actully.                 // Result:  7  0   2013-04-14 00:00:00 				echo $exp_id."<br>";				echo $win_id."<br>";				echo $time."<br>";								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,$win_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 = mysql_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 '<p class = "error">Cannot refresh active item.</p>';	}}
登录后复制


Same query in phpMyadmin, but different result:

SQL query: SELECT ITEM_ID, WINNER_ID, END FROM ITEM WHERE END  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!!!

AI建筑知识问答
AI建筑知识问答

用人工智能ChatGPT帮你解答所有建筑问题

AI建筑知识问答 22
查看详情 AI建筑知识问答

回复讨论(解决方案)

mysql_fetch_array() 函数从结果集中取得一行作为关联数组,或数字数组,或二者兼有 on the line 21 of you  code

mysql_fetch_array() 函数从结果集中取得一行作为关联数组,或数字数组,或二者兼有 on the line 21 of you  code

I don't quite understand... Any suggested solution?
(I don't have chinese input software on this computer, sorry about that...)

i mean the function mysql_fetch_array() just return  one row result 

u use the funciton function mysql_fetch_array() in the code on 21 line has 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() in the code on 21 line has 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

PHP速学教程(入门到精通)
PHP速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号