PHP & MySQL

Soldato
Joined
5 Dec 2003
Posts
2,716
Location
Glasgow
hey I've just managed to get a while loop to go through a recordset to display a table . Thing is I want a link at the end of each row to delete a given row and then refresh the table on the page, what is the best way of doing this?

I have done all my html as php echo statements as opposed to going in and out of php tags all the time. I struggle with the escape characters to put a php variable in html tagd though.
 
Cleanest way would be to do wrap everying in a form, checkbox next to each entry, then do a for loop on the $_POST to work through and clear out the ones you select. Post your code and we'll have a look.
 
Cleanest way would be to do wrap everying in a form, checkbox next to each entry, then do a for loop on the $_POST to work through and clear out the ones you select. Post your code and we'll have a look.

Yeah I would rather if I could just have an onclick event or something to do it so I can just refresh the DIV the table is in rather than the whole page with POST.

Code is in work but from memory something like

<?php

dbconnect yada yada

while ($rs)
echo "<table><tr><td>"
echo $rs("task_id")
echo "</td><td>"
echo $rs("comment")
echo "</td><td>REMOVE</td>
 
Well you could just pass the id to it

Code:
<a href="Javascript:removeTask('<?php echo $rs["task_id"]; ?>');">

then in the function just pass that via a querystring to a php page to remove it.

You'd need to decide how the page would update to show the removed tasks.

You could either get the page that processes the removal to repopulate the table with the updated info, or you could put each entry into divs with individual ids and just hide them as they're deleted, so they're still on the page but hidden until a page refresh.
 
Back
Top Bottom