0

I am trying to write a query but it gives me same value for entire loop. I must get a different value for $ckxf[usercookie] everytime, what am i doing wrong.

$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;

1 Answer 1

2

You know that you can do this in only one query :

SELECT * FROM visitorcookiebrowsing v 
LEFT JOIN cart c on c.userkey=v.usercookie 
ORDER by v.id ASC, c.datebegan  DESC

Learn the power of SQL:)

Sign up to request clarification or add additional context in comments.

1 Comment

It will also execute a lot faster ;-?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.