If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > PHP > while {} echo problems

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old
Registered User
 
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
Reply With Quote
  #2 (permalink)  
Old
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 12,307
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.
__________________
Is taking part in the 'Distinguished Gentlemans' ride. Being neither distinguished nor a gentleman, but I am keen to raise funds for Prostrate Cancer research. At present I'm threatening to ride a Norton 961 wearing a kilt. If you would like to contribute to Prostrate Cancer research then please consider donating via this page:-
http://www.gentlemansride.com/rider/healdem
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On