PHP Programming Loop Question?

Hi,

if i am retrieving the information in the database table using loop (While Loops and For Loops), and i want to add in a submit button in every row. How can i store the ID inside the submit button so i can post to another php page?

As the problem i am facing now is that, with every button display at every row, when i click submit button of one of the row, it supposedly should post the ID to the next page, but it isn’t doing it. Therefore i would like to know how to store the value inside the submit button in a loop.

Thanks so much!! =D
My code will be:

<td>
<form method=’post’ action=’doView.php?id=<?php echo $Course_id; ?>’>
<input type=’submit’ value=’More Information’ name=’<?php echo $Course_id; ?>’ />
</form>
</td>

You need to create the url that you are going to use for the button. The url is just a string with a variable in it. In fact the code for the button will just be a string.

"myPage.php?ID="

Now append to the above string your id. That is it. You may have to escape some quotes to get to that but that is all.

Have fun.

2 Responses to “PHP Programming Loop Question?”

  • Silent says:

    Set the value attribute of each button to the ID of the row.

    Without being able to see your code, I can’t really give you more specific help.
    References :

  • AnalProgrammer says:

    You need to create the url that you are going to use for the button. The url is just a string with a variable in it. In fact the code for the button will just be a string.

    "myPage.php?ID="

    Now append to the above string your id. That is it. You may have to escape some quotes to get to that but that is all.

    Have fun.
    References :

Leave a Reply