0

This is probably an easy question, but am trying to use post to refer to a radion button that I had named with an index of an associative array..but it's not letting me do it..How do I need to do that... here is my initial code

for($row = 0; $row < sizeof($arr);$row++){

    echo ' <form action="order_summary.php" method="post">';
    for ($row = 0; $row < sizeof($arr); $row++) {
        echo '<div class="book-details"><img src="images/'.$arr[$row]['isbn'].'.jpg"      alt="'.$arr[$row]['title'].'" >'.'<br/>'.$arr[$row]['title'].'<br/>by '.$arr[$row]['author'].'<br/><input type="radio" name='.$arr[$row]['isbn'].' value="hardcover" >Hardcover: $'.$arr[$row]['hardcover'].'<br/><input type="radio" name='.$arr[$row]['isbn'].' value="softcover" >Softcover: $'.$arr[$row]['softcover'].'<br/><input type="radio" name="booktype" value="e-     book" >E-Book: $'.$arr[$row]['e-book'].'</div>';
    }
}

echo '<input type="submit" value="Add Selected Items to Cart">';
echo '</form>';

and here is how am trying to put that name into a post variable

$title=$_POST[$arr[$row]['isbn'];

what am i doing wrong

to add to this when I submit it's giving me the following error

Notice: Undefined variable: arr in C:\xampp\htdocs\PhpProject2\order_summary.php on line 8

Notice: Undefined variable: row in C:\xampp\htdocs\PhpProject2\order_summary.php on line 8

Notice: Undefined index: '.['isbn'].' in C:\xampp\htdocs\PhpProject2\order_summary.php on line 8 SUBMIT TEST

Community
  • 1
  • 1
Will Barangi
  • 145
  • 1
  • 2
  • 13

1 Answers1

1

Probably you want the form to be placed outside the for, like this:

echo ' <form action="order_summary.php" method="post">';
for($row = 0; $row < sizeof($arr);$row++){

...
}
mimarcel
  • 695
  • 7
  • 20