/    Sign up×
Community /Pin to ProfileBookmark

Multiple delete through checkout

Hello,
I am stuck in one of my application module. I have to set multiple delete option in my application.
I have used the below code. The designing is perfectly fine. All what i want to add multiple delete options in it.

Below is the code which i have tried out:

[code=php]
<html>
<head>
<title>Strad Hosting Limited -Web Hosting</title>
<script language=”javascript”>
function validate()
{
var chks = document.getElementsByName(‘checkbox[]’);
var hasChecked = false;
for (var i = 0; i < chks.length; i++)
{
if (chks[i].checked)
{
hasChecked = true;
break;
}
}
if (hasChecked == false)
{
alert(“Please select at least one.”);
return false;
}
return true;
}
</script>
</head>
<body >
<?php
$con=mysqli_connect(“localhost”,”stradsol”,”D#v,b5TnQ!D!”,”stradsol_sales”);
if (mysqli_connect_errno())
{
echo “Failed to connect to MySQL: ” . mysqli_connect_error();
}
$result = mysqli_query($con,”SELECT * FROM Persons”);

echo “<form name=’form1′ method=’post’ action=” onSubmit=’return validate();’>”;
echo “<table border=’1′ style=’
background-color: white;’>
<tr>
<th></th>
<th>id</th>
<th style=’padding-left: 11px;’>Lead Generated Date </th>
<th>name</th>
<th>email</th>
<th>contacts</th>
<th>requirement</th>
<th style=’display:none;’>Company name</th>
<th style=’display:none;’>Address</th>
<th>Next Follow-Up date</th>
<th>Final_Details</th>
<th style=’display:none;’>Status</th>
<th style=’padding-left: 12px; display:none;’>Lead Closed Date</th>
<th>EDIT</th>
<th>Follow-up History</th>
<th>Add Follow-up</th>
<th>Delete Record</th>
</tr>”;

while($row = mysqli_fetch_array($result))
{
echo “<tr>”;
echo “<td><input name=’checkbox[]’ type=’checkbox’ id=’checkbox[]’ value='”.$rows[‘id’].”‘></td>”;
echo “<td>” . $row[‘id’] . “</td>”;
echo “<td>” . $row[‘date’] . “</td>”;
echo “<td><a href=’config_info.php?id=” . $row[‘id’] . “‘>”.$row[‘name’].”</a></td>”;
echo “<td>” . $row[’email’] . “</td>”;
echo “<td>” . $row[‘contacts’] . “</td>”;
echo “<td>” . $row[‘requirement’] . “</td>”;

echo “<td style=’display:none;’>” . $row[‘company_name’] . “</td>”;
echo “<td style=’display:none;’>” . $row[‘address’] . “</td>”;
echo “<td>” . $row[‘startdate’] . “</td>”;
echo “<td>” . $row[‘final_details’] . “</td>”;
echo “<td style=’display:none;’>” . $row[‘status’] . “</td>”;
echo “<td style=’display:none;’>” . $row[‘lead_close’] . “</td>”;
echo “<td><a href=’edit_eg1.php?id=” . $row[‘id’] . “‘>Edit</a></td>”;
echo “<td><a href=’Follow_history.php?id=” . $row[‘id’] . “‘>Follow_history</a></td>”;
echo “<td><a href=’add_follow.php?id=” . $row[‘id’] . “‘>Followup</a></td>”;
echo “<td><a href=’delete.php?id=” . $row[‘id’] . “‘>Delete</a></td>”;
echo “</tr>”;
}
echo “<tr><td><input name=’delete’ type=’submit’ id=’delete’ value=’Delete’></td></tr>”;

$count=mysqli_num_rows($result);
if(isset($_POST[‘delete’])){
for($i=0;$i<count($_POST[‘checkbox’]);$i++){
$del_id=$_POST[‘checkbox’][$i];
$sql = “DELETE FROM Persons WHERE id=’$del_id'”;
echo $sql;
$result2 = mysqli_query($con,$sql);
}
// if successful redirect to delete_multiple.php
if($result2)
{
echo “<meta http-equiv=”refresh” content=”0;URL=edit_table_del.php”>”;
}
}
mysqli_close($con);
echo “</table>”;
echo “</form>”;
?>
<br><br>
<a href=”index2.php”>[ Back To Home ]</a>
</body>
</html>

[/code]

I am stuck, the query is not working i thing. Dont know what i am missing. It will be greatful is some one can help me out with this.

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@ginerjmMar 19.2014 — what does your query look like before execution?
Copy linkTweet thisAlerts:
@SamphywiiMar 20.2014 — Yes it's difficult to say before seeing query before execution
Copy linkTweet thisAlerts:
@ginerjmMar 20.2014 — Do some error checking on your query execution - don't just call functions and expect them to be right. Also - turn on php error checking. Look it up.
×

Success!

Help @jackgoddy123 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...