<html>
<head>
<title>
Company Login 
</title>
<style>
li
{
display:inline;
}
</style>
</head>
</html>
<?php

session_start();
echo"Welcome ". $_SESSION["cname"];

$cp= $_SESSION["cname"];
$dbhost='localhost';
$dbuser='shitanshu';
$dbpass='123';
$dbname='placment';
$conn=mysql_connect($dbhost,$dbuser,$dbpass);

if(! $conn)
{
    die('could not connect'.mysql_error());
}
mysql_select_db($dbname);
$sql= "SELECT companyname,jobid,profile FROM compnayjob";
$result=mysql_query($sql,$conn);
$count=mysql_num_rows($result);

?><table width="400" border="0" cellspacing="1" cellpadding="0">
<tr>
<td><form name="form1" method="post" action="delete1.php">
<table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td bgcolor="#FFFFFF">&nbsp;</td>
<td colspan="4" bgcolor="#FFFFFF"><strong>Delete multiple rows in mysql</strong> </td>
</tr>
<tr>
<td align="center" bgcolor="#FFFFFF">#</td>
<td align="center" bgcolor="#FFFFFF"><strong>Company Name</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Job Id</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Profile</strong></td>

</tr>

<?php
while($rows=mysql_fetch_array($result)){

?>

<tr>
<td align="center" bgcolor="#FFFFFF"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['companyname']; ?>"></td>
<td bgcolor="#FFFFFF"><?php echo $rows['companyname']; ?></td>
<td bgcolor="#FFFFFF"><?php echo $rows['jobid']; ?></td>
<td bgcolor="#FFFFFF"><?php echo $rows['profile']; ?></td>

</tr>

<?php
}
?>

<tr>
<td colspan="5" align="center" bgcolor="#FFFFFF"><input name="delete" type="submit" id="delete" value="Delete"></td>
</tr>

<?php

// Check if delete button active, start this 
if($delete){
for($i=0;$i<$count;$i++){
$del_id = $checkbox[$i];
$sql = "DELETE FROM compnayjob WHERE companyname='$del_id'";
$result = mysql_query($sql);
}
// if successful redirect to delete_multiple.php 
if($result){
echo "<meta http-equiv=\"refresh\" content=\"0;URL=delete_multiple.php\">";
}
}
mysql_close();
?>

</table>
</form>
</td>
</tr>
</table>

Have you debugged or echoed to see that the actual SQL statements resovle to?

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.