Call Two MySql Table with A Button - php

I have these table that list all the users of the site. I would like to add a button where in, once that is clicked, the other details of the user will show.
This is my code so far.
echo "<table border=1 align=center><tr class=style2><td>+<td>Student Name<td>Age<td>Address<td>School<td>Email";
$query = mysql_query("SELECT name, age, address, school, email FROM mst_user",$cn) or die(mysql_error());
while($row=mysql_fetch_row($query))
{
echo "<tr class=style8><td>+<td>$row[0]<td align=center> $row[1]<td align=center>$row[2]<td align=center>$row[3]<td align=center>$row[4]";
}
echo "</table>";
The code shows all the user of the site. The <td>+will be a button that when click will show the other details of the user. The other details will show or call a file which is result.php
result.php
$rs=mysql_query("select t.test_name,t.total_que,r.test_date,r.score from mst_test t, mst_result r where
t.test_id=r.test_id and r.login='$login'",$cn) or die(mysql_error());
echo "<h1 class=head1> Result </h1>";
if(mysql_num_rows($rs)<1)
{
echo "<br><br><h1 class=head1> You have not given any quiz</h1>";
exit;
}
echo "<table border=1 align=center><tr class=style2><td width=300>Test Name <td> Total<br> Question <td> Score";
while($row=mysql_fetch_row($rs))
{
echo "<tr class=style8><td>$row[0] <td align=center> $row[1] <td align=center> $row[3]";
}
echo "</table>";
my tables
Any suggestions on how can I achieve it?

Related

Sorting By Checking the Option Button PHP MYSQL

I want to let the user sort the table base on what the user wants.
I have two options for this, sort by name or sort by exam.
code
echo "<table border=1 align=center><tr class=style2><td><input type=radio name=sort value='byname'>Sort By Name<td><input type=radio name=sort value='byexam'>Sort By Exam";
$sort = $_POST['name'];
if ($sort == "byname"){
$sort=mysql_query("select * from mst_adminresult order by login ASC",$cn) or die(mysql_error());
while($row=mysql_fetch_row($sort))
echo "<table border=1 align=center><tr class=style2><td>Student Name <td> Test<br> Question <td> Score";
echo "<tr class=style8><td>$row[1] <td align=center> $row[2] <td align=center> $row[3]/20";
echo "</table>";
}else{
$sort=mysql_query("select * from mst_adminresult order by test_id ASC",$cn) or die(mysql_error());
while($row=mysql_fetch_row($sort))
echo "<table border=1 align=center><tr class=style2><td>Exam<td width=300>Student Name<td> Score";
echo "<tr class=style8><td>$row[1] <td align=center> $row[2] <td align=center> $row[3]/20";
echo "</table>";
}
echo "<table border=1 align=center><tr class=style2><td width=300>Student Name <td> Test<br> Question <td> Score";
while($row=mysql_fetch_row($rs))
{
echo "<tr class=style8><td>$row[1] <td align=center> $row[2] <td align=center> $row[3]/20";
}
echo "</table>";
the problem I am encountering is it doesn't function properly. The default arrangement of the data is listed by the latest exam taker to the last. Now what I am aiming for is, if the user checks the by the name option, it will sort by name. for the by exam, it will be listed by exam.
output:
Your input radio button name="sort" so you need to use $_POST['sort'].
You can use input value as database field name so that we can easily use it in query without if...else condition.
echo "<table border=1 align=center><tr class=style2>
<tr><td><input type=radio name='sort' value='byname'>Sort By Name</td>
<td><input type=radio name='sort' value='byexam'>Sort By Exam</td></tr></table>";
$sort = isset($_POST['sort']) ? $_POST['sort'] : "test_id"; // change of $_POST['name'] to $_POST['sort']
$sortQuery = mysql_query("select * from mst_adminresult order by ".$sort." ASC",$cn) or die(mysql_error());
while($row=mysql_fetch_row($sortQuery))
{
echo "<table border=1 align=center><tr class=style2><td>Student Name</td><td>Test<br> Question</td><td>Score</td></tr>";
echo "<tr class=style8><td>$row[1]</td> <td align=center> $row[2]</td> <td align=center> ". ($row[3]/20) ."</td></tr> ";
echo "</table>";
}
echo "<table border=1 align=center><tr class=style2><td width=300>Student Name</td><td> Test<br> Question </td><td> Score</td></tr>";
while($row=mysql_fetch_row($rs))
{
echo "<tr class=style8><td>$row[1]</td> <td align=center> $row[2]</td> <td align=center> ". ($row[3]/20) ."</td></tr> ";
}
echo "</table>";

Updating a row of SQL with html table

I have the following code:
$sql = "SELECT * FROM Tickets WHERE stat='Open'";
$result = mysql_query($sql);
mysql_close($con);
?>
<!DOCTYPE>
<html>
<body>
<table class="striped">
<tr class="header">
<td>Username</td>
<td>Title</td>
<td>Description</td>
<td>Admin Name</td>
<td>Category</td>
<td>Status</td>
<td>Urgency</td>
<td>Time In</td>
<td> </td>
</tr>
<?php
while ($row = mysql_fetch_array($result)) {
echo "<tr>";
echo "<td>".$row[username]."</td>";
echo "<td>".$row[title]."</td>";
echo "<td>".$row[description]."</td>";?>
<td><select>
<?php
echo "<option value'".$row[admin_name]."'>".$row[admin_name]."</option>";
$sql = mysql_query("SELECT username FROM Users WHERE user_type='admin'");
while ($u = mysql_fetch_array($sql)){
echo "<option value='".$u['username']."'>".$u['username']."</option>";
}
?>
</select></td>
<?php
echo "<td>".$row[category]."</td>";
echo "<td>".$row[stat]."</td>";
echo "<td>".$row[urgency]."</td>";
echo "<td>".$row[time_in]."</td>";
echo "<td><a href='close.php'>Close Ticket</a></td>";
echo "</tr>";
}
?>
</table>
<a href='update.php'>Update</a>
</body>
</html>
I have two links on this page. Both of them need to update a SQL database. The Close ticket link needs to just update the single row, while the update link should update all of them. I am not sure how to get the info from one php to the next. It seems like you can put the individual row information into a Post array for the close ticket link, but I am not sure how. For the update link it needs to take the value of the dropdown in the table and change the admin_name field to that value.

Obtaining data from a table using foreign keys PHP MySQL

I'm trying to output a product from my products table using a foreign key that is in another table because the products are then saved into a user account.
relational tables:
useraccount > savedproduct < products
As many users can have many products and many products can have many users i have made up a table for the inbetween that holds only savedProductId, productId and user_id.
I want to output the product data from the savedproduct table that only has a certain user id attached, if that makes sense.
It practically works but shows all products (twice repeated) instead of just the ones that are under the user id in saved products, my code is here:
NOTE: Please do not say anything about injections, etc., i will be implementing that after i have everything worked out, thank you.
$user_check=$_SESSION['login_user'];
$sqlCommand = "(SELECT * FROM userAccount WHERE email='$user_check')";
$query = mysqli_query($con,$sqlCommand) or die("Error: ".mysqli_error($con));
$column = mysqli_fetch_array($query);
if($column['admin'] != NULL){
echo "<section class='userName'><h3>".$column['firstName']." ".$column['surname']."</h3></section>";
echo "<section class='address'>".$column['addressLine1']."<br />".$column['addressLine2']."<br />".$column['county']."<br />".$column['country']."<br />".$column['postCode']."</section>";
echo "<section class='email'><h3>".$column['email']."</h3></section>";
echo "<section class='passwordUpdate'><a href='update.php?user_id=".$column['user_id']."'>Change Password</a></section>";
echo "<section class='logout'><a href='extras/logoutProcess.php'>Logout</a></section>";
echo "<hr />";
</section>";
Part where I am trying to output the saved products associated with the user id, etc:
}else{
$userIdent=$column['user_id'];
$sqlCommand = "SELECT savedProduct.user_id, product.productName, product.productId, product.productImg, product.price FROM savedProduct, product WHERE savedProduct.user_id=$userIdent LIMIT 2";
$query = mysqli_query($con,$sqlCommand) or die("Error: ".mysqli_error($con));
echo "<section class='userName'><h3>".$column['firstName']." ".$column['surname']."</h3></section>";
echo "<section class='address'>".$column['addressLine1']."<br />".$column['addressLine2']."<br />".$column['county']."<br />".$column['country']."<br />".$column['postCode']."</section>";
echo "<section class='email'><h3>".$column['email']."</h3></section>";
echo "<section class='passwordUpdate'><a href='update.php?user_id=".$column['user_id']."'>Change Password</a></section>";
echo "<section class='logout'><a href='extras/logoutProcess.php'>Logout</a></section>";
echo "<hr />";
echo '<section style="overflow:auto;height:400px;"><table cellpadding="0" cellspacing="0" border="0">
<tr>
<th></th>
<th>Product</th>
<th>Price</th>
</tr>';
while($savedP = mysqli_fetch_array($query)){
echo "<tr>
<td>
<a target='_self' href='fullProductInfo.php?productId=".$savedP['productId']."'>
<img src='http://www.littlepenguindesigns.co.uk/pages/CMX/images/products/".$savedP['productImg']."' alt='".$savedP['productName']."' width='180' height='150' border='0' />
</a>
</td>
<td><a target='_self' href='fullProductInfo.php?productId=".$savedP['productId']."'>".$savedP['productName']."</a></td>
<td>£".$savedP['price']."</td>
</tr>";
}
echo "</table></section>";
}
Every bit of help is appreciated.
if i understood your question correct you only need a right join over these 3 tables.

Not updating in mysql , php

Ok, So I am creating a attendance system and I want to mark a student present or absent, this is my code
<?php
if (isset($_POST['submit'])) {
$present = $_POST['present'];
}
$test3= "SELECT * FROM course_attendance, students, courses, attendance WHERE course_attendance.course_id=courses.course_id AND course_attendance.week_id=attendance.week_number_id AND course_attendance.student_id= students.student_id AND courses.course_id='101' AND attendance.week_number_id='2' ";
$result = mysql_query($test3) or die(mysql_error());
echo "</br><table border='1' align='center'><tr> <th><strong>Student ID</strong></th> <th><strong>First Name </strong></th> <th><strong>Last Name</strong></th> <th><strong>Present</strong></th> </tr> ";
while($rows=mysql_fetch_array($result)){
echo"<form name='Biology_lecture11.php' method='post'>";
echo "<tr><td width='100' align='center'>" .$rows['student_id'].
"</td><td width='120' align='center'>" .$rows['fname'].
"</td><td width='120' align='center'>" .$rows['lname'].
"</td><td><input type='text' name='present' value=" .$rows['present'] . ">";
}
echo "</table>";
?>
<input type='submit' name='Submit' value='Submit' >
</form>
<?php
$sql="UPDATE course_attendance SET present='$present' WHERE course_id='101' AND week_id='2' ";
$result=mysql_query($sql);
if($result){
echo "Successfully logged the attendance";
}
else {
echo"ERROR";
}
?>
The problem is , that it does not update the present field in the database, anyone know whats wrong
This should work for you. This will assign each student a unique present value, which is then checked on postback and if set, it is cleaned and used to update the student record in attendance.
I also extracted echo'd HTML in the PHP to HTML, and moved your form outside of your table (it can cause issues in some browsers).
<?php
// Update present values
if (isset($_POST['submit']))
{
// Get a list of student ids to check
$idsResult = mysql_query("SELECT student_id from students");
while($idRow = mysql_fetch_array($idsResult))
{
// if the textbox for this student is set
if(isset($_POST['present'.$idRow['student_id']]) && !empty($_POST['present'.$idRow['student_id']]))
{
// Clean the user input, then escape and update the database
$cleanedPresent = htmlspecialchars(strip_tags($_POST['present'.$idRow['student_id']]));
$sql = "UPDATE course_attendance SET present='".mysql_real_escape_string($present)."' WHERE course_id='101' AND week_id='2' AND student_id=".$idRow['student_id'];
$result = mysql_query($sql);
if($result){
echo "Successfully logged the attendance for ID ".$idRow['student_id'];
}
else {
echo "ERROR updating on ID ".$idRow['student_id'];
}
}
}
}
$test3= "SELECT * FROM course_attendance, students, courses, attendance WHERE course_attendance.course_id=courses.course_id AND course_attendance.week_id=attendance.week_number_id AND course_attendance.student_id= students.student_id AND courses.course_id='101' AND attendance.week_number_id='2' ";
$result = mysql_query($test3) or die(mysql_error());
?>
<form name='Biology_lecture11.php' method='post'>
</br>
<table border='1' align='center'>
<tr>
<th><strong>Student ID</strong></th>
<th><strong>First Name </strong></th>
<th><strong>Last Name</strong></th>
<th><strong>Present</strong></th>
</tr>
<?php
while($rows=mysql_fetch_array($result)){
echo "<tr><td width='100' align='center'>" .$rows['student_id'].
"</td><td width='120' align='center'>" .$rows['fname'].
"</td><td width='120' align='center'>" .$rows['lname'].
"</td><td><input type='text' name='present".$rows['student_id']."' value=" .$rows['present'] . ">";
}
?>
</table>
<input type='submit' name='Submit' value='Submit'>
</form>
Alternative (better) method: If the present value can be set to a simple 0/1 or true/false, then it would be easier to use a checkbox for each student. In postback, you can then retrieve an array of values from checking each checkbox indicating students who are present, and then update the database table in one query. That also prevents from malicious text input.
Alternative code:
<?php
// Update present values
if (isset($_POST['submit']))
{
// Get a list of student ids to check
$idsResult = mysql_query("SELECT student_id from students");
$presentIds = array();
$absentIds = array();
while($idRow = mysql_fetch_array($idsResult))
{
// If the student's checkbox is checked, add it to the presentIds array.
if(isset($_POST['present'.$idRow['student_id']]))
{
$presentIds[] = $idRow['student_id'];
}
else
{
$absentIds[] = $idRow['student_id'];
}
}
// Convert array to string for query
$idsAsString = implode(",", $presentIds);
// You can set present to whatever you want. I used 1.
$sql = "UPDATE course_attendance SET present='1' WHERE course_id='101' AND week_id='2' AND student_id IN (".$idsAsString.")";
$result = mysql_query($sql);
if($result){
echo "Successfully logged the attendance for IDs ".$idsAsString;
}
else {
echo "ERROR updating on IDs ".$idsAsString;
}
// OPTIONAL: Mark absent students as '0' or whatever other value you want
$absentIdsAsString = implode(",", $absentIds);
// You can set present to whatever you want. I used 1.
$absentQuery = "UPDATE course_attendance SET present='0' WHERE course_id='101' AND week_id='2' AND student_id IN (".$absentIdsAsString.")";
$absentResult = mysql_query($absentQuery);
if($absentResult){
echo "Successfully logged absence for IDs ".$absentIdsAsString;
}
else {
echo "ERROR updating absence on IDs ".$absentIdsAsString;
}
}
$test3= "SELECT * FROM course_attendance, students, courses, attendance WHERE course_attendance.course_id=courses.course_id AND course_attendance.week_id=attendance.week_number_id AND course_attendance.student_id= students.student_id AND courses.course_id='101' AND attendance.week_number_id='2' ";
$result = mysql_query($test3) or die(mysql_error());
?>
<form name='Biology_lecture11.php' method='post'>
</br>
<table border='1' align='center'>
<tr>
<th><strong>Student ID</strong></th>
<th><strong>First Name </strong></th>
<th><strong>Last Name</strong></th>
<th><strong>Present</strong></th>
</tr>
<?php
while($rows=mysql_fetch_array($result)){
echo "<tr><td width='100' align='center'>" .$rows['student_id'].
"</td><td width='120' align='center'>" .$rows['fname'].
"</td><td width='120' align='center'>" .$rows['lname'].
"</td><td><input type='checkbox' name='present".$rows['student_id']."' ";
// NOTE: REPLACE 1 with whatever value you store in the database for being present.
// I used 1 since the update at the top of the code uses 0 and 1.
if($rows['present']=='1')
{
echo "checked='checked' ";
}
// With a checkbox, you don't need to assign it a value.
echo "value=" .$rows['present'];
echo ">";
}
?>
</table>
<input type='submit' name='Submit' value='Submit'>
</form>
One mistake I see is, that you put this:
echo"<form name='Biology_lecture11.php' method='post'>";
in your while-loop. So it is put out more than one time. Try writing that part in the row before your loop.
A couple of issues I see:
1: You're UPDATE code is running every time the page is loaded. Move you update block into the if (isset($_POST['submit'])) {} block.
2: When you print out the students, you create an input called "present" for every student. If you were to fill this in and submit the data, only the last field will be added to the database.
3: You're not updating a specific student. I would change the input field to a checkbox and name it "present[$rows[student_id]]".
Then, once the page is being processed, loop through the key/values of $_POST['present']. and update any students that are in it.
foreach (array_keys($_POST['present']) as $student_id) {
if (is_numeric($student_id)) {
$sql="UPDATE course_attendance SET present='true' WHERE course_id='101' AND week_id='2' and student_id='$student_id'";
}
}
You'll have to modify the UPDATE if the attendance table isn't automatically filled in with students. If every student isn't already there, you'll have to run a query to see if they exist. If they don't insert the row. If they do, update the row.
4: Move the opening tag to before the opening of the table and OUTSIDE of the student loop.
Two things to take in consideration: First, you have form element dupplication. As the comments above said, take out the line
echo"<form name='Biology_lecture11.php' method='post'>";
from the loop.
Second, the UPDATE statatement updates all the students, you need a WHERE token in your SQL statement. Something like this:
<?php
if (isset($_POST['submit'])) {
$present = $_POST['present'];
}
$test3= "SELECT * FROM course_attendance, students, courses, attendance WHERE course_attendance.course_id=courses.course_id AND course_attendance.week_id=attendance.week_number_id AND course_attendance.student_id= students.student_id AND courses.course_id='101' AND attendance.week_number_id='2' ";
$result = mysql_query($test3) or die(mysql_error());
echo "</br><table border='1' align='center'><tr> <th><strong>Student ID</strong></th> <th><strong>First Name </strong></th> <th><strong>Last Name</strong></th> <th><strong>Present</strong></th> </tr> ";
echo"<form name='Biology_lecture11.php' method='post'>";
while($rows=mysql_fetch_array($result)){
echo "<tr><td width='100' align='center'>" .$rows['student_id'].
"</td><td width='120' align='center'>" .$rows['fname'].
"</td><td width='120' align='center'>" .$rows['lname'].
"</td><td><input type='text' name='present' value=" .$rows['present'] . ">";
}
echo "</table>";
?>
<input type='submit' name='Submit' value='Submit' >
</form>
<?php
$sql="UPDATE course_attendance SET present='$present' WHERE course_id='101' AND week_id='2' AND student_id = the_student_id";
$result=mysql_query($sql);
if($result){
echo "Successfully logged the attendance";
}
else {
echo"ERROR";
}
?>
Hope it helps!
you have taken a form inside table tag and inside while loop this will not work, here is correct code.
<?php
if (isset($_POST['submit'])) {
$present = $_POST['present'];
$sql="UPDATE course_attendance SET present='$present' WHERE course_id='101' AND week_id='2' ";
$result=mysql_query($sql);
if($result) {
echo "Successfully logged the attendance";
}
else {
echo"ERROR";
}
}
?>
<form name='Biology_lecture11.php' method='post'>
<table border="1" align="center">
<tr>
<th><strong>Student ID</strong></th>
<th><strong>First Name </strong></th>
<th><strong>Last Name</strong></th>
<th><strong>Present</strong></th>
</tr>
<?php
$test3= "SELECT * FROM course_attendance, students, courses, attendance WHERE course_attendance.course_id=courses.course_id AND course_attendance.week_id=attendance.week_number_id AND course_attendance.student_id= students.student_id AND courses.course_id='101' AND attendance.week_number_id='2' ";
$result = mysql_query($test3) or die(mysql_error());
while($rows=mysql_fetch_array($result)) {
echo "<tr><td width='100' align='center'>" .$rows['student_id']."</td>
<td width='120' align='center'>" .$rows['fname']."</td>
<td width='120' align='center'>" .$rows['lname']."</td>
<td><input type='text' name='present' value=" .$rows['present']."></td></tr>";
}
echo "</table>";
?>
<input type='submit' name='Submit' value='Submit' >
</form>

member control through admin account using php

I am new to php.
I made a member registration on login page and adm too. So inside admin I wanted to get the list of the members and delete the members I dont want. So I took the a code from a sample code for phone book from http://localhost/xamp and editted it to my requirement I am able to retrieve the members but unable to delete the members. See the code below:
<?php
require_once('auth.php');
require_once('../config.php');
//Array to store validation errors
$errmsg_arr = array();
//Validation error flag
$errflag = false;
//Connect to mysql server
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {
die('Failed to connect to server: ' . mysql_error());
}
//Select database
$db = mysql_select_db(DB_DATABASE);
if(!$db) {
die("Unable to select database");
}
?>
<html>
<head>
<meta name="author" content="Kai Oswald Seidler">
<link href="../loginmodule.css" rel="stylesheet" type="text/css">
<title></title>
</head>
<body>
<p>
<h2><?php echo "User list"; ?></h2>
<table border="0" cellpadding="0" cellspacing="0">
<tr bgcolor="#f87820">
<td><img src="img/blank.gif" alt="" width="10" height="25"></td>
<td class="tabhead"><img src="img/blank.gif" alt="" width="150" height="6"><br><b><?php echo $TEXT['phonebook-attrib1']; ?></b></td>
<td class="tabhead"><img src="img/blank.gif" alt="" width="150" height="6"><br><b><?php echo $TEXT['phonebook-attrib2']; ?></b></td>
<td class="tabhead"><img src="img/blank.gif" alt="" width="150" height="6"><br><b><?php echo $TEXT['phonebook-attrib3']; ?></b></td>
<td class="tabhead"><img src="img/blank.gif" alt="" width="50" height="6"><br><b><?php echo $TEXT['phonebook-attrib4']; ?></b></td>
<td><img src="img/blank.gif" alt="" width="10" height="25"></td>
</tr>
<?php
$firstname=$_REQUEST['firstname'];
$lastname=$_REQUEST['lastname'];
$phone=$_REQUEST['phone'];
if($_REQUEST['action']=="del")
{
$result=mysql_query("DELETE FROM members WHERE member_id={$_REQUEST['member_id']}");
}
$result=mysql_query("SELECT member_id,firstname,lastname,login FROM members ORDER BY lastname");
$i = 0;
while($row = mysql_fetch_array($result)) {
if ($i > 0) {
echo "<tr valign='bottom'>";
echo "<td bgcolor='#ffffff' height='1' style='background-image:url(img/strichel.gif)' colspan='6'></td>";
echo "</tr>";
}
echo "<tr valign='middle'>";
echo "<td class='tabval'><img src='img/blank.gif' alt='' width='10' height='20'></td>";
echo "<td class='tabval'><b>".$row['lastname']."</b></td>";
echo "<td class='tabval'>".$row['firstname']." </td>";
echo "<td class='tabval'>".$row['member_id']." </td>";
echo "<td class='tabval'><a onclick=\"return confirm('".$TEXT['userlist-sure']."');\" href='userlist.php?action=del&member_1d=".$row['member_id']."'><span class='red'>[".$TEXT['userlist-button1']."]</span></a></td>";
echo "<td class='tabval'></td>";
echo "</tr>";
$i++;
}
echo "<tr valign='bottom'>";
echo "<td bgcolor='#fb7922' colspan='6'><img src='img/blank.gif' alt='' width='1' height='8'></td>";
echo "</tr>";
?>
</table>
</body>
</html>
I haven't editted it that properly and the looks in all.
Please help me in making it able to delete the members also.
I didn't understand what .$TEXT['userlist-button1'].,'".$TEXT['userlist-sure']. variables are?
I also want to include an approved and disapproved radio button in table for each members.
How can I do that?
Please if you can help me.
This should be a POST via a FORM not a href link (GET).
$TEXT is obviously an array holding the text you want printed.
You need to replace &member_1d in the href with a real & and a real i as &member_id.
$TEXT is an array contaning all the language strings for the selected language.
You find the strings defined unter /lang/yourlanguage.php
In general this is not a very good example to start coding with IMO.
But I think your app may start working, if you make sure, the language files and other include files are available and you change this &member_1d with &member_id
An example of a list of members with delete links:
$query = mysql_query("SELECT member_id,firstname,lastname,login FROM members ORDER BY lastname");
if(mysql_num_row($query)!= 0){ //only continue if there are members in the database
while($row = mysql_fetch_assoc($query)){ //loop through each row in the database
$member_id = $row['member_id'];
$firstname = $row['firstname'];
$lastname = $row['lastname'];
echo '<p>' . $firstname . ' - ' delete '</p>';
}
}
A simple script on delete_member.php to delete the member from the database.
if(isset($_GET['id'])){
$member_id = $_GET['id'];
$query = mysql_query("DELETE FROM members WHERE member_id='$member_id'");
echo '<p>This user was deleted from database</p>';
}
This code is only basic to give an example.
I would however prefer to use a simple form and $_POST for something like this instead of using $_GET which is very vulnerable in this kind of instance.
After getting the list of members use a form with input field to type the id you want to delete.

Categories