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

    Unanswered: while {} echo problems


    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:
    $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:
    $paymentRequest->addItem('0001', 'Notebook prata', 2,430.00); // --- 0001 is increasing if I have more than 1 product 0002...000n
    The new one:
    $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.')';
    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);


  2. #2
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 22
    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.
    (virtually) all sample code I post will almost certainly contain typos, some logic errors and will need debugging. its air code, providing with good intentions but no guarantees it works or is fit for purpose. in essence yer gets what yer pays for...

    PS 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