W3C home > Mailing lists > Public > www-talk@w3.org > November to December 2003

deleting records with php and checkboxes

From: Webmaster <webmaster@newsletter-expert.com>
Date: Fri, 19 Dec 2003 14:52:26 +0800
Message-ID: <00cb01c3c5fc$aaa1b260$33a8f2da@davidloo>
To: <www-talk@w3.org>

I have the folowing two php?s to delete records from my database wich is
an event database,
it works typing the id field and clicking delete

I would like to put checkboxes in more than one record at time to delete
then. To make my script more advanced.

How can it be done?

i think i could put a checkbox with the default value "off (or 0)" and make
the delete.php delete the record with the checkbox with value "on (or 1)",
but the details to do this i need to discover
someone has passed by this situation, and could help me?

$db = pg_connect("dbname=thedb user=theuser");
$query = "SELECT * FROM thetable";
$result = pg_exec($db, $query);
if (!$result) {printf ("ERROR"); exit;}
$numrows = pg_numrows($result);
printf ("<table border=1>
printf ("<tr bgcolor='#66CCFF'><td><b>Id</b></td><td><b>City</b></td><td><b>state</b></td><td><b>Location</b></td><td><b>Day</b></td><td><b>Month</b></td><td><b>Time</b></td><td><b>Event</b></td></tr>");
$myrow = pg_fetch_row ($result,$row);
printf ("<tr bgcolor='$bgcolor'><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>
",$myrow[0], $myrow[1], $myrow[2], $myrow[3], $myrow[4], $myrow[5], $myrow[6],$myrow[7]);
while ($row < $numrows);
printf ("</table><br>

Type the id to be deleted.

<form action="delete.php" method="post">
ID to Delete : <input type="text" name="id" size="4" length="4" value=""><br>
<input type="submit" name="submit" value="Deletar">
<input type="reset" name="reset" value="Limpar">

Above is the delete.php

$db = pg_connect("dbname=thedb user=theuser");
$query = "DELETE FROM thetable where id='$id'";
$result = pg_exec($db, $query);
if (!$result) {printf ("ERROR"); exit;}
printf ("<b>Deleted with sucess!</b>");


David K

Received on Friday, 19 December 2003 01:52:21 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:33:05 UTC