database - How can I see which button has been pressed in php? -
i'm quite new php might seem easy. have table called 'products' , each product in table want create button id of product. have no problem creating buttons can not see of buttons has been pressed.
how can solve this?
this code:
$sql = "select id `products` subcategory = 'laptop' order id desc limit 1"; $query = mysql_query($sql); $id = mysql_result($query,0); for($i=1; $i<= $id; $i++){ $product2 = r::load('products', $i); echo "<input type='submit' name='$product2->id' value='add cart'/>"; }
thank !
assign value button/input
<input type="submit" name="btn" value="button1" /> <input type="submit" name="btn" value="button2" /> <input type="submit" name="btn" value="button3" /> <?php echo filter_input(input_post, 'btn'); ?>
or
<input type="submit" name="btn1" value="button1" /> <input type="submit" name="btn2" value="button2" /> <input type="submit" name="btn3" value="button3" /> <?php if (filter_has_var(input_post, 'btn1')) { echo "button 1 clicked"; } ?>
Comments
Post a Comment