I can't seem to make my image a delete button. If I do it no longer deletes from the data base.
echo "<td>" . "<input type=submit name=delete value=delete></td>";
This is the line of code that I would like to add src = image/delete.png
I can't seem to make my image a delete button. If I do it no longer deletes from the data base.
echo "<td>" . "<input type=submit name=delete value=delete></td>";
This is the line of code that I would like to add src = image/delete.png
You cannot add a src
nor href
attribute to your input (you can, but that won't do anything).
To have an image displayed, either set it as the input background (using CSS), or create a DOM element (<img src="".../>
) and add behaviour to it with javascript (register a click event, perform the request to the server you wan to do).
Use this:
<button type="submit" name="delete" style="padding: 0; border: none;">
<img src="image/delete.png" />
</button>
Just add the Image with CSS:
<style>
#delete {
width: 150px;
height: 50px;
border: none;
color: transparent;
background: url(https://placeholdit.imgix.net/~text?txtsize=20&txt=150%C3%9750&w=150&h=50);
}
</style>
<td><input id="delete" type=submit name=delete value=delete></td>
Try Something like this :-
echo '<td><a href="delete.php"><img src="image/delete.png" /></a></td>' ;
You can put your image as a background of the button using css property -> background-image
. And then use the .btn-class
in the input
field.
<style>
.btn-class{
background-image: url("/path/to/image");
}
</style>
<?php echo "<td>" . '<input type="submit" class="btn-class" name="delete" value="delete"></td>'; ?>