Expand|Select|Wrap|Line Numbers
- <html>
- <head>
- <script type="text/javascript">
- function SetAllCheckBoxes(FormName, FieldName, CheckValue)
- {
- if(!document.forms[FormName])
- return;
- var objCheckBoxes = document.forms[FormName].elements[FieldName];
- if(!objCheckBoxes)
- return;
- var countCheckBoxes = objCheckBoxes.length;
- if(!countCheckBoxes)
- objCheckBoxes.checked = CheckValue;
- else
- // set the check value for all check boxes
- for(var i = 0; i < countCheckBoxes; i++)
- objCheckBoxes[i].checked = CheckValue;
- }
- function pop()
- {
- alert("Do u want to delete this row?");
- }
- </script>
- </head>
- <body>
- <?php include "menu.php";?>
- <center><b>CONTACT INFO</b></center><br>
- <form method="post" onSubmit="<?=$PHP_SELF?>">
- <table border="0" cellpadding="0" cellspacing="0">
- <tr>
- <td>
- <table border="0" cellpadding="0" cellspacing="0">
- <tr>
- <td style="padding-left:20px;padding-bottom:20px;"><a href="createcontact.php" style="text-decoration:none"><input type="button" name="new" value="CREATE CONTACT" style="width:170px;background-image:url(pink.gif)"></a></td>
- <td style="padding-left:20px;padding-bottom:20px;"><a href="createlead.php" style="text-decoration:none"><input type="button" name="new" value="CREATE LEAD" style="width:170px;background-image:url(pink.gif)"></a></td>
- </tr>
- <tr>
- <td style="padding-left:20px;"><a href="createaccount.php" style="text-decoration:none"> <input type="button" name="new" value="CREATE ACCOUNT" style="width:170px;background-image:url(pink.gif)"></a></td>
- <td style="padding-left:20px;"> <a href="createopportunity.php" style="text-decoration:none"> <input type="button" name="new" value="CREATE OPPORTUNITY" style="width:170px;background-image:url(pink.gif)"></a></td>
- </tr>
- </table>
- </td>
- <td style="padding-left:120px;">
- <table cellpadding="8" cellspacing="0" with frame="box">
- <tr>
- <td style="padding-left:10px;padding-bottom:20px;">FIRST NAME</td>
- <td style="padding-left:60px;padding-bottom:20px;"><input type="text" name="fname"></td>
- </tr>
- <tr>
- <td style="padding-left:10px"><input type="submit" name="search" value="SEARCH" style="width:80px;background-image:url(pink.gif)" ></td>
- <td style="padding-left:30px"><input type="reset" name="clear" value="CLEAR" style="width:80px;background-image:url(pink.gif)" ></td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
- <br/><br/>
- <b><center>CONTACT LIST </center></b>
- <br/>
- [php][/php]
- <?php
- include 'connect.php';
- $fn= $_POST[fname];
- if(!$fn==NULL)
- {
- $res = mysql_query("SELECT * FROM createcontact where fname LIKE '%$fn%' ");
- ?>
-
- <input type="button" style="width:130px;background-image:url(pink.gif)" onclick="SetAllCheckBoxes('contacts', 'chkbx', true);" value="SELECT ALL">
- <input type="button" style="width:130px;background-image:url(pink.gif)"onclick="SetAllCheckBoxes('contacts', 'myCheckbox', false);" value="SELECT NONE">
- <input type="submit" name="delete" value="DELETE" id="delete" style="width:130px;background-image:url(pink.gif)" onClick="pop()">
- <?
- include 'connect.php';
- mysql_select_db('sfas',$con);
- if(isset($_POST['delete'])){
- if(sizeof($_POST['chkbx'])){
- foreach($_POST['chkbx'] AS $val){
- $sql = mysql_query("DELETE FROM createcontact WHERE id=".(int)$val)or die(mysql_error());
- }
- }
- if($sql)
- {
- echo "record(s) deleted";
- }
- }
- $sel="SELECT * FROM createcontact";
- $result=mysql_query($sel);
- ?>
- <br/><br/>
- <form name="contacts" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
- <table border="1" align="center" cellpadding="0" cellspacing="0" width="900" style="border:1px solid #ffaacc;"> <tr>
- <td width="50" align="center">
- <input type="checkbox"></td>
- <td>NAME</td>
- <td>TITLE</td>
- <td>A/C NAME</td>
- <td>EMAIL</td>
- <td>PHONE NO</td>
- <td>TEAM</td>
- <td>USER</td>
- </tr>
- <?php
- while($rows=mysql_fetch_array($res))
- {
- ?>
- <tr>
- <td width="50" align="center">
- <input type="checkbox" name="chkbx[]" id="checkbox_<? echo $x; ?>" value="<? echo $rows['id']; ?>"></td>
- <td> <?echo $rows['fname'];?> </td>
- <td><?echo $rows['title'];?></td>
- <td><?echo $rows['acname'];?></td>
- <td><?echo $rows['email'];?></td>
- <td><?echo $rows['phone'];?></td>
- <td><?echo $rows['team'];?></td>
- <td><?echo $rows['assignedto'];?></td>
- </tr>
- <?php
- }
- ?>
- <? mysql_close();?>
- </table>
- <? }
- else
- {
- include 'connect.php';
- mysql_select_db('sfas',$con);
- if(isset($_POST['delete'])){
- if(sizeof($_POST['chkbx'])){
- foreach($_POST['chkbx'] AS $val){
- $sql = mysql_query("DELETE FROM createcontact WHERE id=".(int)$val)or die(mysql_error());
- }
- }
- if($sql){
- echo "record(s) deleted";
- }
- }
- $sel="SELECT * FROM createcontact";
- $result=mysql_query($sel);
- ?>
-
- <input type="button" style="width:130px;background-image:url(pink.gif)" onclick="SetAllCheckBoxes('contacts', 'chkbx', true);" value="SELECT ALL">
- <input type="button" style="width:130px;background-image:url(pink.gif)"onclick="SetAllCheckBoxes('contacts', 'chkbx', false);" value="SELECT NONE">
- <input type="submit" name="delete" value="DELETE" id="delete" style="width:80px;background-image:url(pink.gif)" onclick="pop()">
- <br/><br/>
- <form name="contacts" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" onload="return false;">
- <table border="1" align="center" cellpadding="0" cellspacing="0" width="900" style="border:1px solid #ffaacc;"> <tr>
- <td width="50" align="center"><input type="checkbox"></td>
- <td>NAME</td>
- <td>TITLE</td>
- <td>A/C NAME</td>
- <td>EMAIL</td>
- <td>PHONE NO</td>
- <td>TEAM</td>
- <td>USER</td>
- </tr>
- <?php
- $x = 0;
- while($rows=mysql_fetch_array($result))
- {
- $x++;
- ?>
- <tr>
- <td width="50" align="center">
- <input type="checkbox" name="chkbx[]" id="checkbox_<? echo $x; ?>" value="<? echo $rows['id']; ?>"></td>
- <td> <?echo $rows['fname'];?> </td>
- <td><?echo $rows['title'];?></td>
- <td><?echo $rows['acname'];?></td>
- <td><?echo $rows['email'];?></td>
- <td><?echo $rows['phone'];?></td>
- <td><?echo $rows['team'];?></td>
- <td><?echo $rows['assignedto'];?></td>
- </tr>
- <?php
- }
- ?>
- <? mysql_close();?>
- </table>
- <?php } ?>
- </form>
- </body>
- </html>
if the select all button is clicked all checkboxes should be selected so that we can delete with delete button and select none is clicked none should be selected