Hello I’m trying to give each of these button names a uniquely numbered name. There can be up to 50 of these button pairs and each pair will refer to one order. (This is for the admin page of a practice estore im building) Anyway, where their name is currently “dele_ord” and “ship_ord” I would like it to be (somehow) Dele_ord($i) So that each button is numbered ie: dele_ord34
Once i have this setup I will use an if(isset($_POST(dele_ordXX){…} to run database queries that will delete or modify the orders associated with the buttons.
Im very new to php and mysql and want to learn it better.
$i=1;
while($i<=50)
{
echo '<h5>'.$row['o_id'].' || '.$row['first_name'].' || '.$row['last_name'].' || '.$row['prod_id'].' || '.$row['prod_title'].' || '.$row['prov'].' || '.$row['city'].' || '.$row['street'].' || '.$row['s_instruct'].' || '.$row['order_time'].' || '.$row['ship_status'].'</h5>';
echo'<form action="admin.php" method="post" class="dele_o"><input type="button" name="delete_ord" value="Delete Order"></form>';
echo'<form action="admin.php" method="post" class="ship_o"><input type="button" name="ship_ord" value="Ship Order"></form> <br />';
$row = mysqli_fetch_array($result);
$i++;
}
mysqli_close($link);
?>
You don’t need a separate
<form>tag for each button, you can have multiple submit buttons with different names in the same form.Anyway, to answer your question, if you use double quotes “…” instead of single ‘…’ for your echo commands, then php allows you to embed variables within your string, for example:
That will output
Note how I’ve used \ to escape the double quotes in the string, although you could also just use single quotes for your HTML attributes instead if you prefer.