I know this has been done before, but I can't work out how to apply the current answers to my codee.
I have a list, which is being automatically generated, to display current users.
<?php
$username="user1";
$password="password1";
$database="database1";
$table="members";
$host="host1";
mysql_connect($host,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM $table";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
?>
<table class="bordered" width="98%" align="center">
<tr width="100%">
<th width="10%" align="center"><font face="verdana">ID</font></th>
<th width="30%" align="center"><font face="verdana">Username</font></th>
<th width="30%" align="center"><font face="verdana">Password</font></th>
<th width="15%" align="center"><font face="verdana">Delete?</font></th>
<th width="15%" align="center"><font face="verdana">Active?</font></th>
</tr>
<?php
$i=0;
while ($i < $num) {
$f1=mysql_result($result,$i,"id");
$f2=mysql_result($result,$i,"username");
$f3=mysql_result($result,$i,"password");
$f4=mysql_result($result,$i,"allow");
?>
<tr width="100%">
<td width="10%" align="center"><font face="verdana"><?php echo $f1; ?></font></td>
<td width="30%"><font face="verdana"><?php echo $f2; ?></font></td>
<td width="30%"><font face="verdana"><?php echo $f3; ?></font></td>
<td width="15%"><font face="verdana"><img src="../icons/delete.png" align="center">
<?php
$query = "DELETE members where id=$f1 && username=$f2 && password=$f3";
mysql_query($query);
?>
</font></td>
<td width="15%"><font face="verdana"><?php if($f4==1){
print '<html>';
print '<img src="../icons/allow_user.png" width="32" height="32" align="center">';
print '</html>';
}
else {
print '<html>';
print '<img src="../icons/deny_user.png" width="32" height="32" align="center">';
print '</html>';
} ?></font></td>
</tr>
<?php
$i++;
}
?>
The below is the piece of code I'd like to use to delete a user.
<td width="15%"><font face="verdana"><img src="../icons/delete.png" align="center"> <?php $query = "DELETE members where id=$f1 && username=$f2 && password=$f3"; mysql_query($query); ?> </font></td>
I understand that the best way of doing this is to use the image as a link to a php file, using the address to instruct the php delete file, I just can't seem to do it.
I have seen the following tutorial for this, but don't understand it...
http://www.phpeasyst...om/mysql/7.html
Any help would be greatly appreciated.
Thanks in advance, Daniel.
This post has been edited by fuzzy29: 08 October 2010 - 01:56 PM

New Topic/Question
Reply




MultiQuote






|