OK, Thanks
Rather than try and explain the application. You can see it working at [URL=http://]http://narva.co.uk/pages/prod1_1fr.php[/URL] There are about 20 similar pages on the site and it's like a shopping cart idea except it allows customers to select items and place them into a quote basket. I designed it several months ago with only a basic knowledge of PHP using arrays stored in cookies to pass the data between pages. The original code is very very long mainly because I new nothing about loops at the time and there are literally 100's of repetitive if() statements. As an exercise in PHP I am trying to redesign it with more efficient code. The first thing is I will use sessions instead of cookies so here is an example of my new code for the above page using the first 4 products only.
The sort of thing I want to do is eliminate the repeating lines eg. session_register() an the if() statements by putting all the elements $aaa, $aaa1_1Q, $bbb into an array and then loop through them.
<?
//page prod1_1fr.php
session_start();
session_register('aaa1_1Q');
session_register('bbb1_1Q');
session_register('ccc1_1Q');
session_register('ddd1_1Q');
//check for previous values of $aaa1_1Q, $bbb1_1Q etc. and if they dont exist assign a value from form input
if(!$aaa1_1Q){$aaa1_1Q=$aaa;}
if(!$bbb1_1Q){$bbb1_1Q=$bbb;}
if(!$ccc1_1Q){$ccc1_1Q=$ccc;}
if(!$ddd1_1Q){$ddd1_1Q=$ddd;}
?>
<HTML>
<BODY>
<FORM action=<? "$PHP_SELF;" ?> method ="post">
<input name="aaa" type="text" value= "<? echo $aaa1_1Q; ?>">
<input name="bbb" type="text" value= "<? echo $bbb1_1Q; ?>">
<input name="ccc" type="text" value= "<? echo $ccc1_1Q; ?>">
<input name="ddd" type="text" value= "<? echo $ddd1_1Q; ?>">
</FORM
</BODY>
</HTML>
Any help or ideas would be much appreciated.
Thanks
Rob