我正在尝试编写一个查询,但它为整个循环提供了相同的值。每次我必须为$ ckxf [usercookie]获得不同的值,我做错了什么。
$queryxyzzy12=("SELECT * FROM visitorcookiesbrowsing ORDER by id ASC");
$resultxyzzy23=mysql_query($queryxyzzy12) or die(mysql_error());
//var_dump($ckxf);
while($ckxf = mysql_fetch_assoc($resultxyzzy23)){
$querycrtx=("SELECT * FROM cart WHERE userkey='$ckxf[usercookie]' ORDER by datebegan DESC");
$resultcrtx=mysql_query($querycrtx) or die(mysql_error());
$numcrtx=mysql_numrows($resultcrtx);
$ixxy=0;
答案 0 :(得分:2)
您知道只能在一个查询中执行此操作:
SELECT * FROM visitorcookiebrowsing v
LEFT JOIN cart c on c.userkey=v.usercookie
ORDER by v.id ASC, c.datebegan DESC
了解SQL的强大功能:)