deleting multiple rows

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
new to php
Forum Newbie
Posts: 11
Joined: Fri Nov 29, 2002 6:16 am

deleting multiple rows

Post by new to php »

I am trying to delete multiple rows from my database using checkboxes but its not working can someone help me please.

thanx

Here is the code

**form page**

Code: Select all

<form action="delete.php" method="post">
<input type="submit" name="submit"  value="Select First 10 Names">
</form>
**delete.php**

Code: Select all

<?php
include "functions.php";

$page_title = "Delete/Update";

include "startpage.php";


if ($submit =="Select First 10 Names")
{
	
$query = select_entry($first_name,$middle_name,$last_name,$email,$photo);
	
}



function select_entry($first_name,$middle_name,$last_name,$email,$photo)
{

?>

<form method="post">
<hr size=3>
<?php

$query = mysql_query("select * from Names order by Last_Name limit 10"); 
while($row = mysql_fetch_array($query)) 

{
    $first_name= $rowї"First_Name"];
    $middle_name = $rowї"Middle_Name"];
    $last_name = $rowї"Last_Name"];
    $email = $rowї"Email"];
    $photo=$rowї"Photo"];
 ?>    

<table  width="100%" border="0" >
<tr>
<td   align=right width=50%>
<?php 
echo "First Name: <input type=text  name="first_name" size="30" maxlength="40"value="$first_name" ><br>\n";

echo "Middle Name: <input type=text name="middle_name" size="30" maxlength="40" value="$middle_name"><br>\n";        
    
echo "Last Name: <input type=text name="last_name" size="30" maxlength="40" value="$last_name"><br><br>\n";        

echo "Email: <input type=text name="email" size="30" maxlength="40" value="$email" "readonly"><br><br>\n";        

echo "Photo: <input type=text name="photo" size="30" maxlength="70" value="$photo"><br><br>\n";        
 
echo "<input type="checkbox" name="emailї]" value="$email"><b>Delete?</b>\n";

?>
</td>
<td align=right  width=50%>
<?php  
echo "$photo";
?>
</td>
</tr>
</table>
<hr size=3><br>
<?php  
}
?>
<input type=submit name=submit value="Delete Enteries">

<input type=reset>
</form>
<?php  
}

elseif ($submit=="Delete Enteries")

{
	if (is_array($email))
	{
		while (list($key,$value) = each($email))
		{

			$query= mysql_query ("delete from Names where Email='$value'");
			//echo "$valueї$key]"; 
	
		}
	}

}

include "endpage.php"; 
?>
Im using MySQL.
new to php
Forum Newbie
Posts: 11
Joined: Fri Nov 29, 2002 6:16 am

Post by new to php »

include "functions.php";// this file connects to the database.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Hi, I've put your code into [syntax=php][/syntax] and [syntax=php][/syntax] bbcode tags to make it easier for others to read your code.

For more info: faq.php?mode=bbcode

Mac
Post Reply