You are here: Re: Listing table data with an option to delete each individual item. « PHP Programming Language « IT news, forums, messages
Re: Listing table data with an option to delete each individual item.

Posted by Sean Barton on 02/05/06 13:55

i find it best to do thing with id numbers. the table you have shown
will obviously have a primary key for each record. so in php you do the
sql statement something like

$result = mysql_query("select id, name, age, sex from people",$db);
if ($myrow = mysql_fetch_array($result))
{
make the table header information here. ie: titles, name ages sex...
and a row for action
do
{
echo "<tr>
$id =$myrow['id']
<td>$myrow['name']</td>
<td>$myrow['age']</td>
<td>$myrow['sex']</td>
<td><a href = 'delete.php?id=$id>delete</a></td>";

}
while ($myrow = mysql_fetch_array($result))
}

then you make another page that essentially has two or three lines or
modify delete.php in the link fo $_SERVER[PHP_SELF] which come back to
the page you are looking at.

$id = $_GET['id'];
$result = mysql_query("delete from people where id=$id",$db);
header("Refresh: 0; http://full url/whateverfirstpagewascalled.php");

hope this helps, php took me 3 days of looking at examples to learn. do
a few online tutorials and www.php.net is the bible. good luck

Sean Barton

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация