Forum Moderators: coopster

Message Too Old, No Replies

Having a little trouble with quotes..

quotes

         

bono

9:33 am on Jun 20, 2005 (gmt 0)

10+ Year Member



Hi, im tryin to write a xml snippet to go within a hidden field in a form. i think what im doing wrong is somehing to do with quotes.. can somebody help..

echo "<input type=hidden name=order value='";
// create xml snippet
echo "<order class=com.Order>";
echo "<orderlines class='com.Orderline'>";

foreach($cart->get_contents() as $item) {
echo "<OrderLine>";
echo "<prod_code>".$item['id']."</prod_code>";
echo "<quantity>".$item['qty']."</quantity>";
echo "<item_amount>".($item['price'])."</item_amount>";
echo "</orderline>";
}
echo "</orderlines>";
echo "</order>";
echo "'>";

mcibor

10:56 am on Jun 20, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, the problem is truly with quotes: in fourth line you finish the quote of value. I recommend this way:
<?php
...
?>
<input type="hidden" name="order" value="<order class=com.Order><orderlines class='com.Orderline'>
<?php
foreach($cart->get_contents() as $item) {
echo "<OrderLine>";
echo "<prod_code>".$item['id']."</prod_code>";
echo "<quantity>".$item['qty']."</quantity>";
echo "<item_amount>".($item['price'])."</item_amount>";
echo "</orderline>";
}
?>
</orderlines></order>'>

or with your way: echo "<input ... value=\"";
echo ...
echo "\">"; // the \" writes the quote sign and doesn't end the string

Best regards
Michal Cibor

bono

10:27 am on Jun 23, 2005 (gmt 0)

10+ Year Member



thanks.. worked a treat..