0

I have successfully connected to database and published mysql data on web and manually added joke on it.Screenshot of what output looks like is provided here. enter image description here

When i manually enter the corresponding id of joke inside the textbox and press delete button, it deletes the joke corresponding to that it. But when i click on the delete button directly, that joke isn't deleted. How to update value of that textbox ? For the time being, i have made input type of textbox as text so to see whats going inside it. I am using PHP version: 7.1.1 and Apache/2.4.25 (Win32.

<p><a href="?addjoke">Add your own joke</a></p>
<p>Here are all the jokes in the database:</p>
<?php foreach ($jokes as $joke) : ?>
  <form action ="?deletejoke" method='post'>
  <blockquote>
    <p><?php echo htmlspecialchars($joke['text'], ENT_QUOTES, 'UTF-8');?>
    <input type = "text" name = "id" value = "<? php echo $joke['id']; ?>">
    <input type = 'submit' value = 'Delete'>
    </p>
  </blockquote>
</form>

Screenshot of Mysql database is provided here. enter image description here

2
  • where is the php code? Commented Mar 17, 2017 at 9:39
  • delete the space between ? and php Commented Mar 17, 2017 at 11:56

3 Answers 3

2

there is a space between <? and php on the input value it should be <?php; then it should work.

<input type = "text" name = "id" value = "<? php echo $joke['id']; ?>">
Sign up to request clarification or add additional context in comments.

2 Comments

@AbhayaSinghPandey accept the answer, that informs the community that solution was found
five minutes is still remaining before i can accept it as final solution. As soon as time period to perform this action begins, i wll mark it as accepted.
1
<input type="text" name="id" value="<?php echo $joke['id'];?> ">

you should remove the spaces (not just in this line)

Comments

1

Change

<input type = "text" name = "id" value = "<? php echo $joke['id']; ?>">

to

<input type = "text" name = "id" value = "<?php echo $joke['id']; ?>">

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.