| | |
Mysql row delete using php
![]() |
•
•
Join Date: Sep 2008
Posts: 159
Reputation:
Solved Threads: 0
Hi i had a big database and need to delete and add to it daily. About 500 rows are there in that table. I add add a check box in every row ( in the output page ) .. Something like this
Now i need to check multiple check boxes and press delete button in the php page. Then the values posted to "process.php" and then delete the rows with "id" s of checked....
I tried many but ...
Please any one help me....
Thanks
Rajeesh
<table>
<?php
$select=select * from table ;
while($row=mysql_fetch_array($select)){;
?>
////// result will come here. Each row contains a check box with a value "id" . Which is from the column id from the database ..and name from 1,2,3....
<?php } ?>
</table>Now i need to check multiple check boxes and press delete button in the php page. Then the values posted to "process.php" and then delete the rows with "id" s of checked....
I tried many but ...
Please any one help me....
Thanks
Rajeesh
Last edited by rajeesh_rsn; Mar 23rd, 2009 at 11:15 pm. Reason: mistake
make the checkbox name "id[]" and then you can process the data using
thats just a simple example, there still are some security issues to take care of
PHP Syntax (Toggle Plain Text)
foreach( $_POST['id'] as $key => $val ) { //delete query using $val as $id }
Last edited by kkeith29; Mar 23rd, 2009 at 11:39 pm.
•
•
Join Date: Mar 2009
Posts: 6
Reputation:
Solved Threads: 0
hi, this is a code for deleteing the entire row from database if we enter the word.... but this code is not working....so reply me as early as possible....
php Syntax (Toggle Plain Text)
<?php if($_POST[Word]=="") { echo "<br><br><br><br> <b>Enter the data in the form</b></font><center>"; echo "<center>"; echo "<form >"; echo "<br>"; echo "<br>";echo "<br>";echo "<br>"; echo "<center><input type=\"button\" onClick=\"history.go(-1)\"name=\"INSERT\" Value=\"GoBack\"></center>"; echo "</form>"; echo "</center>"; exit; } else { $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("my_dict", $con); $sqlQuery = "DELETE * FROM dic WHERE Word='$_POST[Word]'"; if (!mysql_query($sqlQuery,$con)) { die('Error: ' . mysql_error()); } if ($sqlQuery == TRUE) { echo" <br>"; echo"<br>"; echo"<br>"; echo"<br>"; echo "<center><font size=5 color=green><b><br><br>Data deleted successfully</b></font> </center>"; echo" <br>"; echo"<center><input type=\"button\" onClick=\"history.go(-1)\"name=\"INSERT\" Value=\"To Insert The Data GoBack\"></center>"; } else { echo " <center><font size=5 color=green>Data could no deleted</b></font></center>"; } mysql_close($con); } //else end ?>
Last edited by peter_budo; Mar 31st, 2009 at 2:44 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
![]() |
Similar Threads
- Delete multiple rows in mysql with check box (PHP)
- Delete Mysql row from drop down menu form. Help Please (PHP)
- please help. how do i add checkbox values in mysql row (PHP)
- can we use mysql(DELETE...) query in the same page while having anchor tags? (PHP)
- PHP codes to search MySQL (PHP)
- inserting checkbox values in mysql +PHP (PHP)
- mysql DELETE not working (PHP)
- Hello all... Need help updating mysql with php (PHP)
Other Threads in the PHP Forum
- Previous Thread: drop down list
- Next Thread: Want to use two server ..
Views: 2707 | Replies: 4
| Thread Tools | Search this Thread |
Tag cloud for PHP
access ajax apache array arrays beginner binary box buttons cakephp cart check checkbox class cms code cookies database date delete directory display download dropdown drupal dynamic echo email error file files form forms function functions header href htaccess html image images include insert ip java javascript joomla jquery limit link list login loop mail menu methods mlm mod_rewrite multiple mysql order output parse password paypal php problem query radio regex remote results script search security select server session soap sort sorting source sql string system table tutorial update updates upload url user validation validator variable video web website wordpress xml






