I Have table on browser Like This
Name | Action |
________________________
Septiyo | Edit | Delete |
Fahmi | Edit | Delete |
Tejo | Edit | Delete |
For Edit, usually I use link like this
echo "<a href='edit.php?ID=$data['ID']'>Edit</a>";
With link, I can Include the ID variable and send to other Page.
The question is, if I change The Link with Button html. How can I include the variable?
My Button like this
echo "<input type='button' value='Edit' onclick='window.location=edit.php?ID=$data['ID']'>";
and it not Work.
Can anyone Help me?
Im very Appreciated your Answer.
Thanks.
Why not wrap your button in an <a> with the href set to the php page?
Like so:
echo <a href=yourPage.php><input type="button" value="Edit"></a>
A better option to consider might be taking out the input and styling the link to look like a button. It is standards compliant as well, where the other option may not be.
Do as this:
<a href='edit.php?ID=<?php echo $data['ID']; ?>'>Edit</a>
PHP is processed on the server side. So, it must know that the code you are writing is php and it knows when you put it inside the php tags <?php //php code ?>
That was just pointed the answer for the OP would be:
For you send data through a button you have some ways:
With a form it would be:
<form action="edit.php" method="post">
<input type="hidden" name="ID" value="<?php echo $data['ID']; ?>">
<input type="submit" value="Send">
</form>
Another way would be through some javascript function:
<input
type="button"
onclick="javascript:window.open('edit.php?ID=<?php echo $data['ID']; ?>','','');">
And one more:
<script>
function sendValue(id){
window.location='edit.php?ID=' + id;
}
</script>
<input
type="button"
onclick="javascript:sendValue('<?php echo $data['ID']; ?>')>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With