Hi everyone,

I am working on one application in which i am using many checkboxes for many records like we use in our mail .
Like in our inbox mail folder if we want to delete more than one mail , after checking that mail in checkbox , we click on delete selected mail button , it deletes that mail.

Like this i want to use this type of checkbox in for everyproduct and when we click on checkboxes.

I will let you know the format for this-----------

1. product info checkbox
2.product info checkbox
3.product info checkbox
4.
5.
here is one button "delete selected"

now i want that when i will click on delete selected button , i can delte that all records which i have selected from checkboxes
ALL this i want to delete that records from database. and all should be in php,html and mysql query.


so please help me . i have written all code of this problem is that it is not working still.

thanks,
gagan

Hi everyone,

I want to use php code as like our mail application we delete all selected mail in our mailbox which one we have select through checkboxes.

I am posting code of my addlink.php file. Please help me. It is very urgent for me.

<?

include("admin_session_check.php");

if($_POST['Submit8']!=""){

$_SESSION[firstinput]=$_POST['firstinput'];

$_SESSION[secondinput]=$_POST['secondinput'];

//$a=$_POST['catagory'];

//echo $a;

 }

include_once("includes/db.php");

if($_POST['Submit2']!="")

{

$sql1="select Url,Title from addlink where Url='".$_POST['url']."' or Title='".$_POST['title']."'";

$res1=mysql_query($sql1,$link);

//$query=

$num=mysql_num_rows($res1);



if($num==0){

$sql="insert into addlink(ID,cat_ID,Url,description,Title,Name,Email,date)

values('','$_POST[cat_id]','$_POST[url]','$_POST[description]','$_POST[title]','$_POST[name]','$_POST[email]',curdate())";

if (!mysql_query($sql,$link))

  {

  die('Error: ' . mysql_error());

  }

}

$sql6 = mysql_query("delete FROM description where ID='".$_POST['id']."'");

$msg="Record Is Submitted";

//mail()

$mailto=$_POST['email'];

$subject="Link Submission Confirmation";

$massage="Hello ".$_POST[name].",<br><br><br> Your link Submission request has been approved on 

http://www.huntor.org<br><br><br>

<br><br><br><b>We submit your link on page</b> 		   

<br>&nbsp;&nbsp;\"http://www.huntor.org/index.php?sub_cat_id=$_POST[cat_id]\"<br><br> 

&nbsp;&nbsp;<br><br>Thanks 

and Regard<br>Support Team<br>huntor.org<br><br> &nbsp;info@huntor.org";

  $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

	         $headers .='From:huntor' . "\r\n";

mail($mailto,$subject,$massage,$headers);

}

if($_POST['Delete']!="")

{

//$sql6 = mysql_query("delete FROM description where cat_ID='".$_POST['cat_id']."'");
$sql6 = mysql_query("delete FROM description where ID='".$_POST['id']."'");

$msg="Record Deleted";

}

?>



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<title>Untitled Document</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<script language="javascript" src="../javascript/cal2.js"></script>

<script language="javascript" src="../javascript/cal_conf2.js"></script>

<link href="../css/cascading.css" rel="stylesheet" type="text/css">

</head>



<body>

<table width="100%"  border="0" cellspacing="0" cellpadding="0">

  <tr>

    <td width="23%" valign="top"><table width="100%"  border="0" cellspacing="0" cellpadding="0">

      <tr>

        <td>&nbsp;</td>

      </tr>

    </table>

    <? include_once("left_menu.php");?></td>

    <td width="77%"><table width="100%"  border="0" cellspacing="0" cellpadding="0">

      <tr>

        <td><form action="addlink.php" method="post" name="formdate">

         <select name="category" class="footerlink" >

            <option value="0" selected>ALL</option>

			 </option><? $sql2="select * from tbl_cat where sub_cat_id='0' order by cat_name asc";

					   $query2=mysql_query($sql2,$link);

					   while($row2=mysql_fetch_array($query2)){

					   ?>

                      <option  value="<?=$row2[0]?>"><?=$row2[2]?> </option>

					  <?  $cat_id=$row2[0];

					   $sql5="select * from tbl_cat where sub_cat_id='$cat_id' order by cat_name asc";

					   $query5=mysql_query($sql5,$link);

					   while($row5=mysql_fetch_array($query5)){ ?>

                      <option  value="<?=$row5[0]?>"> |_<?=$row5[2]?></option><? } } ?>

          </select>

         <input type="text" name="firstinput" size=20 class="footerlink" value="<? echo $_SESSION['firstinput']?>" readonly>      

         <small><a href="javascript:showCal('Calendar1')" class="redfont">Select Date</a> <input type="text" name="secondinput" size=20 class="footerlink" value="<? echo $_SESSION['secondinput']?>" readonly>		        

         <small><a href="javascript:showCal('Calendar2')" class="redfont">Select Date</a></small>

          <input name="Submit8" type="submit" class="footerlink" value="Submit">

        </form></td>

      </tr>

      <tr>

        <td align="center" class="count"><?=$msg?></td>

      </tr><?  

	  $rowsPerPage =25;



// by default we show first page

$pageNum = 1;



// if $_GET['page'] defined, use it as page number

if(isset($_GET['page']))

{

    $pageNum = $_GET['page'];

}



// counting the offset

$offset = ($pageNum - 1) * $rowsPerPage;

if($_POST['category']==0){ //echo "hi";

$query = " SELECT * FROM description where date between '".$_SESSION[firstinput]."'

AND '".$_SESSION[secondinput]."' order by ID asc LIMIT $offset, $rowsPerPage"; }

else

{

$query = " SELECT * FROM description where cat_ID='".$_POST['category']."' and date between '".$_SESSION[firstinput]."'

AND '".$_SESSION[secondinput]."' order by ID asc LIMIT $offset, $rowsPerPage"; }

$result = mysql_query($query) or die('Error, query failed789');


?>
<form action="addlink.php" method="post" name="form1">
<? 
// print the random numbers

while($row = mysql_fetch_array($result))

{  

 
 
?>

      <tr><td><table width="100%"  border="1" cellspacing="0" cellpadding="0">

          <tr>

            <td width="76%"><? echo "<span class=categorieslink>$row[Title]</span><br>";?><? echo "<span class=descriptiontext> $row[description]</span><br>";?><a href="<?=$row[Url]?>" target="_blank"><? echo "<span class=redfont>$row[Url]</span><br>";?></a><? echo "<span class=sidetxt> $row[Name]</span><br>";?><? echo "<span class=sidetxt> $row[Email]</span><br>";?> <? $sql01 = "Select * from tbl_cat where id=$row[cat_ID]";
$result01 = mysql_query($sql01,$link) or die('Error is '. mysql_error());
while($object= mysql_fetch_array($result01)) { 
$cat=$object['cat_name'];
//echo "<span class=sidetxt> $object[sub_cat_id]</span><br>"; 
if ($object['sub_cat_id'] == 0) {
 
echo "<span class=sidetxt> $cat</span><br>"; 
} else {

$sql02 = "Select * from tbl_cat where id=$object[sub_cat_id] and sub_cat_id=0";
$result02 = mysql_query($sql02,$link) or die('Error is '. mysql_error());
while($object2= mysql_fetch_array($result02)) { 
echo "<span class=sidetxt> $object2[cat_name]</span>"; }
echo "<span class=sidetxt>__$cat</span><br>";
}
} ?></td>

            <td width="12%" align="center"><input name="id" type="hidden" value="<?=$row['ID']?>"><input name="cat_id" type="hidden" value="<?=$row['cat_ID']?>"><input name="url" type="hidden" value="<?=$row['Url']?>"><input name="description" type="hidden" value="<?=$row['description']?>"><input name="title" type="hidden" value="<?=$row['Title']?>"><input name="name" type="hidden" value="<?=$row['Name']?>"><input name="email" type="hidden" value="<?=$row['Email']?>"><input name="Submit2" type="submit" class="footerlink" value="Submit"></td>

            <td width="12%" align="center"><input type="checkbox" name="<?=$row['ID']?>" value="1">&nbsp;
			 </td>

        

         </tr> 

        </table></td>

      </tr><? } ?> 
	  
	  <tr>
	      <td>&nbsp;</td>
	  </tr>
	  <tr>
	  <td align="right" class=sidetext><input type="button" value="Delete Selected Links" name="dellink" class="footerlink"></td>
	  
	  </tr>
	  
	  </form>

      <tr>

        <td><? 

		if($_POST['category']==0){

$query   = "SELECT COUNT(ID) AS numrows from description where date between '".$_SESSION[firstinput]."'

AND '".$_SESSION[secondinput]."' order by ID asc"; }

else

{

$query = " SELECT COUNT(ID) AS numrows from description where cat_ID='".$_POST['category']."' and date between '".$_SESSION[firstinput]."' AND '".$_SESSION[secondinput]."'  order by ID asc"; }

		

$result  = mysql_query($query) or die('Error, query failed124');

$row     = mysql_fetch_array($result, MYSQL_ASSOC);

$numrows = $row['numrows'];



// how many pages we have when using paging?

$maxPage = ceil($numrows/$rowsPerPage);



// print the link to access each page



 $self="addlink.php";

$nav  = '';



for($page = 1; $page <= $maxPage; $page++)

{

   if ($page == $pageNum)

   {

      $nav .= " $page "; // no need to create a link to current page

   }

   else

   {

      $nav .= " <a href=\"$self?page=$page\" class=text_1>$page</a> ";

   }

}

if ($pageNum > 1)

{

   $page  = $pageNum - 1;

   $prev  = " <a href=\"$self?page=$page\" class=text_1>[Prev]</a> ";



   $first = " <a href=\"$self?page=1\" class=text_1>[First Page]</a> ";

}

else

{

   $prev  = ' '; // we're on page one, don't print previous link

   $first = ' '; // nor the first page link

}



if ($pageNum < $maxPage)

{

   $page = $pageNum + 1;

   $next = " <a href=\"$self?page=$page\" class=text_1>[Next]</a> ";



   $last = " <a href=\"$self?page=$maxPage\" class=text_1>[Last Page]</a> ";

}

else

{

   $next = ' '; // we're on the last page, don't print next link

   $last = ' '; // nor the last page link

}



// print the navigation link

if($numrows!=0){ 

echo "<span class=sidetext>Pages :</span>";}echo"<span class=text_1> $first  $prev  $nav  $next  $last</span>"; 

?></td>


      </tr>
	  
	  
	  

    </table></td>

  </tr>

</table>

</body>

</html>

Hi please help me to for this i can delete all select records with using button delete all links.

Thanks
Gagan

are there any error message on your code?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.