In my current project I am using a combination of PHP, MySQL, and JavaScript.
Using PHP I have a search setup to return results in this format:
<name><price><add/subtract buttons><cost input box>
Cost is a textbox. Now, I've setup my PHP to set the name of each textbox to prod$id ($id being the product's id in the mysql db). I've done this because javascript will not recognise just a number for the document.form.inputboxname.value function.
Now the problem lies in reading the results once the submit button is pushed. I need to be able to loop through in PHP like so:
$sql = "SELECT COUNT(*) FROM products";
$res = mysql_query($sql);
$num = mysql_num_rows($res);
for($i;$i >= $num;$i++){
if(isset($prod{$i})){
if($prod{$i} != 0){
$prods .= "$i,";
$quants .= "$prod{$i},";
}
}
Now I know php won't read $prod{$id} as $prod1, $prod2, etc how can I get it to read as that? would something like this work:
if(isset("$prod" . $i)
?
Mark