-2

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

Biswabid
  • 1,378
  • 11
  • 26

5 Answers5

0

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).

ValLeNain
  • 2,232
  • 1
  • 18
  • 37
0

Use this:

<button type="submit" name="delete" style="padding: 0; border: none;">
  <img src="image/delete.png" />
</button>
jobs
  • 63
  • 1
  • 11
  • @DanBracuk cool, didn't know that. I prefer buttons over inputs since: http://stackoverflow.com/questions/7117639/input-type-submit-vs-button-tag-are-they-interchangeable – jobs Feb 21 '17 at 13:51
0

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>
Webdesigner
  • 1,954
  • 1
  • 9
  • 16
0

Try Something like this :-

echo '<td><a href="delete.php"><img src="image/delete.png" /></a></td>' ;
Aman Kumar
  • 4,533
  • 3
  • 18
  • 40
0

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>'; ?>
Chaitali
  • 631
  • 4
  • 12