Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi,
I am new to php and working on a small project.
I have a php page that reads all info from a mysql database and display it in a html table.
I want to place 2 buttons at the end of the table that when clicked must either accept or reject/delete the entry.

Here is what I have so far:

$query="SELECT * FROM to3rd_temp";<br />
$result=mysql_query($query);<br />
$num=mysql_numrows($result);<br />
<br />
mysql_close();<br />
<br />
echo "<center>Database Output</center><br><br>";<br />
<br />
// Draw table Header<br />
echo "<table border="2"><tr><br />
<td>header 1</td><br />
<td>header2</td><br />
//Removed code to make post shorter<br />
<td>Accept/Reject</td><br />
</tr>";<br />
<br />
//Loop all info in DB<br />
$i=0;<br />
<br />
while ($i < $num) {<br />
<br />
$id=mysql_result($result,$i,"id");<br />
$datesub=mysql_result($result,$i,"datesub");<br />
//Removed code to make post shorter<br />
$value=mysql_result($result,$i,"value");<br />
<br />
echo "<tr> <br />
<td>$datesub</td><br />
<td>$dateocc</td><br />
//Removed code to make post shorter<br />
<td><input type='button' name='button1' value='Accept'> <br />
 <br><br />
<input type='button' value='Reject'><br />
</br></td><br />
</tr>";<br />
<br />
$i++;<br />
}<br />
// Close Table<br />
echo "</table>";<br />
echo "<center><a href="index.php">Back</a></center><br><br>";<br />
</br></br></br></br>



If someone could please assist me to get the buttons to work I would greatly appreciate it.

Thank you.
Posted

You can write 2 functions in php that does the deleting and accepting the values and call them with onClick event of the button.

Give it a try. Let us know if it wont work or you get any errors.


BR//
Harsha
 
Share this answer
 
v2
You should take a look at PHP forms[^]. Following that link you will see a really simple sample that will help you.

Good luck! :thumbsup:
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900