Jump to content

Submit button not doing anything


deezy315

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.