fullyloaded Posted March 7, 2007 Share Posted March 7, 2007 hi i have this code for my site that will connect to my database and grab all my members there id email and ip the problem is that it dont have a button where you can select a member and delete that member can anyone help me with this?i want to add a button and a check box so if i check off a member and click a delete button it will delete that member here is the code thanks <?php mysql_connect("localhost", "name", "pass") or die("could not connect"); mysql_select_db("name"); //Set the page size $PageSize = 10; $StartRow = 0; //Set the page no if(empty($_GET['PageNo'])){ if($StartRow == 0){ $PageNo = $StartRow + 1; } }else{ $PageNo = $_GET['PageNo']; $StartRow = ($PageNo - 1) * $PageSize; } //Set the counter start if($PageNo % $PageSize == 0){ $CounterStart = $PageNo - ($PageSize - 1); }else{ $CounterStart = $PageNo - ($PageNo % $PageSize) + 1; } //Counter End $CounterEnd = $CounterStart + ($PageSize - 1); ?> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel="stylesheet" href="include/style.css" type="text/css"> </head> <?php $TRecord = mysql_query("SELECT * FROM members"); $result = mysql_query("SELECT * FROM members ORDER BY id LIMIT $StartRow,$PageSize"); //Total of record $RecordCount = mysql_num_rows($TRecord); //Set Maximum Page $MaxPage = $RecordCount % $PageSize; if($RecordCount % $PageSize == 0){ $MaxPage = $RecordCount / $PageSize; }else{ $MaxPage = ceil($RecordCount / $PageSize); } ?> <body class="UsePageBg"> <table width="100%" border="0" class="InternalHeader"> <tr> <td width="24%">List of Members</td> <td width="76%"> <div align="right"> <?php print "$RecordCount record(s) founds - You are at page $PageNo of $MaxPage" ?></div> </td> </tr> </table> <br> <table width="100%" border="0" class="NormalTableTwo"> <tr> <td class="InternalHeader" width="4%"> <p align="center">Id</td> <td class="InternalHeader" width="36%"> <p align="center">User</td> <td class="InternalHeader" width="20%"> <p align="center">Email</td> <td class="InternalHeader" width="20%"> <p align="center">Ip</td> </tr> <?php $i = 1; while ($row = mysql_fetch_array($result, MYSQL_NUM)) { $bil = $i + ($PageNo-1)*$PageSize; ?> <tr> <td class="NormalFieldTwo" width="4%"><?php echo $bil ?></td> <td class="NormalFieldTwo" width="20%"><?php echo $row[1] ?></td> <td class="NormalFieldTwo" width="20%"><?php echo $row[2] ?></td> <td class="NormalFieldTwo" width="20%"><?php echo $row[5] ?></td> </tr> <?php $i++; }?> </table><br> <table width="100%" border="0" class="InternalHeader"> <tr> <td> <div align="center"> <?php //Print First & Previous Link is necessary if($CounterStart != 1){ $PrevStart = $CounterStart - 1; print "<a href=staffList.php?PageNo=1>First </a>: "; print "<a href=staffList.php?PageNo=$PrevStart>Previous </a>"; } print " [ "; $c = 0; //Print Page No for($c=$CounterStart;$c<=$CounterEnd;$c++){ if($c < $MaxPage){ if($c == $PageNo){ if($c % $PageSize == 0){ print "$c "; }else{ print "$c ,"; } }elseif($c % $PageSize == 0){ echo "<a href=staffList.php?PageNo=$c>$c</a> "; }else{ echo "<a href=staffList.php?PageNo=$c>$c</a> ,"; }//END IF }else{ if($PageNo == $MaxPage){ print "$c "; break; }else{ echo "<a href=staffList.php?PageNo=$c>$c</a> "; break; }//END IF }//END IF }//NEXT echo "] "; if($CounterEnd < $MaxPage){ $NextPage = $CounterEnd + 1; echo "<a href=staffList.php?PageNo=$NextPage>Next</a>"; } //Print Last link if necessary if($CounterEnd < $MaxPage){ $LastRec = $RecordCount % $PageSize; if($LastRec == 0){ $LastStartRecord = $RecordCount - $PageSize; } else{ $LastStartRecord = $RecordCount - $LastRec; } print " : "; echo "<a href=staffList.php?PageNo=$MaxPage>Last</a>"; } ?> </div> </td> </tr> </table> <?php mysql_free_result($result); mysql_free_result($TRecord); ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
trq Posted March 7, 2007 Share Posted March 7, 2007 What part are you stuck on? Were not here to write code for people. Quote Link to comment Share on other sites More sharing options...
fullyloaded Posted March 7, 2007 Author Share Posted March 7, 2007 hi i know your not here to write code for people what im trying to do is add a delete button so i can select a member and delete it if i want thanks Quote Link to comment Share on other sites More sharing options...
interpim Posted March 7, 2007 Share Posted March 7, 2007 build a link, with the user id as the variable... send it to a script which redirects back to your admin page, or wherever you plan on deleting users from. Have a mysql query select the record based on the user ID, remove it, then return back to the original admin page. "DELETE FROM users WHERE id='$id' " would be the MySQL syntax I do believe... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.