deezy315 Posted May 2, 2009 Share Posted May 2, 2009 I can't figure out why the quantity isn't updating when submit is set. any help greatly appreciated <?php include ('connect.php'); $queryresult = @mysql_query('select id, title, year, type,imdb,copies from dvd '); if (!$queryresult){ exit ('<p>Error in query.'.mysql_error().'</p>'); } while ($row= mysql_fetch_array($queryresult)){ if ($row['copies']>0){ echo '<tr><td>'.$row['title'].'</td><td>'.$row['year'].'</td><td>'.$row['type'].'</td><td>'.$row['copies'].'</td><td><a href=http://www.imdb.com/title/'.$row['imdb'].'>More Info</td></a> <td> <input name="radio" type="radio" value="'.$row['id'].'" method="get" /> </td> </tr>'; ///// Else if there is no stock }else{ echo '<tr><td>'.$row['title'].'</td><td>'.$row['year'].'</td><td>'.$row['type'].'</td><td>'.$row['copies'].'</td><td><a href=http://www.imdb.com/title/'.$row['imdb'].'>More Info</td></a></tr>'; } } ?> <tr> <td colspan="6"> <input name="set" type="submit" value="Place Order" /> </td> </tr> </table> <?php if (isset($_GET['set'])){ $ordered_id= $_GET['radio']; $oldqtyresult= mysql_fetch_array(@mysql_query('select copies from dvd where id= '.ordered_id.'')); $old_qty = $oldqtyresult['copies']; $new_qty = $old_qty - 1; @mysql_query('update dvd set copies= '.$new_qty.' where id= '.$ordered_id.''); } ?> Link to comment https://forums.phpfreaks.com/topic/156583-submit-button-not-doing-anything/ Share on other sites More sharing options...
kenrbnsn Posted May 2, 2009 Share Posted May 2, 2009 Learn proper HTML. The 'method="get"' attribute goes in the '<form>' tag. Ken Link to comment https://forums.phpfreaks.com/topic/156583-submit-button-not-doing-anything/#findComment-824453 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.