Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2009
    Posts
    23

    while {} echo problems

    Hello,

    I have a WHILE loop that works fine, BUT when I add this to it I get an error. I guess my way is NOT how you suppose to do it

    My regular while:
    Code:
    $query_3=mysql_query("SELECT * FROM client_order WHERE Client_id = $cid AND order_number = $order_number ");
    
    while ($row_3=mysql_fetch_assoc($query_3)){
    
    echo 'smt....smt';
    
    }
    I need to add:
    Code:
    $paymentRequest->addItem('0001', 'Notebook prata', 2,430.00); // --- 0001 is increasing if I have more than 1 product 0002...000n
    The new one:
    Code:
    $query_3=mysql_query("SELECT * FROM client_order WHERE Client_id = $cid AND order_number = $order_number ");
    
    while ($row_3=mysql_fetch_assoc($query_3)){
    
    echo '$paymentRequest->addItem("'.$start_number.'", "'.$productName.'", '.$price.')';
    
    $start_number++;
    }
    How to I write the code in a correct way that if I have lets say 3 products is will "print" 3 parts like this:
    $paymentRequest->addItem('1', 'Notebook prata', 2,430.00);
    $paymentRequest->addItem('2', 'Notebook red', 2,430.00);
    $paymentRequest->addItem('3', 'Notebook yello', 2,430.00);

    Thanks

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    12,419
    you need to be carefull dropping in and out of quotes in PHP
    although it will accpet a variable inside quotes eg:-
    PHP Code:
    echo 'A Number is:$ANumericVaraible' 
    you cannot do that with an associative array
    PHP Code:
    echo 'ArrayValue:-",$MyAssocitiveArray['INDEX']; 
    however as I read that statement you are trying to add somethign to an array and output something using echo. that isn't going to work as there is no return form the additem method.
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •