| | |
help with delete multiple rows in mysql using checkboxes
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Jan 2009
Posts: 1
Reputation:
Solved Threads: 0
Thak you very much!
guys i just added two small variables because register globals is been removed from new version of php this will work 100%
guys i just added two small variables because register globals is been removed from new version of php this will work 100%
php Syntax (Toggle Plain Text)
<?php $host="localhost"; // Host name $username="root"; // <strong class="highlight">Mysql</strong> username $password=""; // <strong class="highlight">Mysql</strong> password $db_name="mytest"; // Database name $tbl_name="userreg"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name"; $result=mysql_query($sql); $count=mysql_num_rows($result); ?> <table width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <td><form name="form1" method="post" action=""> <table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td bgcolor="#FFFFFF"> </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>Id</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Name</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Lastname</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Email</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['id']; ?>"></td> <td bgcolor="#FFFFFF"><? echo $rows['id']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['name']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['lastname']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['email']; ?></td> </tr> <?php } ?> <tr> <td colspan="5" align="center" bgcolor="#FFFFFF"><input name="delete" type="submit" id="delete" value="Delete"></td> </tr> <? // Check if <strong class="highlight">delete</strong> button active, start this $delete = $_POST[delete]; $checkbox = $_POST[checkbox]; if($delete){ for($i=0;$i<$count;$i++){ $del_id = $checkbox[$i]; $sql = "DELETE FROM $tbl_name WHERE id='$del_id'"; $result = mysql_query($sql); } // if successful redirect to delete_multiple.php if($result){ echo "<meta http-equiv=\"refresh\" content=\"0;URL=test.php\">"; } } mysql_close(); ?> </table> </form> </td> </tr> </table>
Last edited by ersind; Jan 2nd, 2009 at 10:49 am.
0
#19 34 Days Ago
•
•
•
•
Warning: Cannot modify header information - headers already sent by (output started at D:\xampp\htdocs\kregpho.php:2) in D:\xampp\htdocs\kregpho.php on line 72
can any 1 tell me wat this error mean....y should it occur.
And by "sending content", I mean anything that would show up in the browsers "view source" output. Even a white-space before your opening <?php tags would cause this error.
P.S.
Why did you post this into an old, random thread?
Please do not ask for help in a PM. Use the forums.
And use [code] tags!
And use [code] tags!
![]() |
Similar Threads
Other Threads in the PHP Forum
- Previous Thread: need HELP
- Next Thread: Using A List Box in If Statement
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code codingproblem cron curl database date directory display download dynamic echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla limit link login loop mail memmory menu methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem query radio random recursion regex remote script search select send server sessions sms snippet soap source space speed sql static structure syntax system table tutorial up-to-date update upload url validation validator variable video web wordpress xml youtube





