Re: Filter Data based on Username
- From: "ZeldorBlat" <zeldorblat@xxxxxxxxx>
- Date: 30 Jan 2006 08:45:25 -0800
<?php
$username_xtr2 = "-1";
if (isset($_POST['username'])) {
$username_xtr2 = (get_magic_quotes_gpc()) ? $_POST['username'] :
addslashes($_POST['username']);
}
mysql_select_db($database_xcomm, $xcomm);
$query_xtr2 = sprintf("SELECT * FROM xtr WHERE %s = '%s'",
$username_xtr2,$username_xtr2);
$xtr2 = mysql_query($query_xtr2, $xcomm) or die(mysql_error());
$row_xtr2 = mysql_fetch_assoc($xtr2);
$totalRows_xtr2 = mysql_num_rows($xtr2);
?>
//dynamic text:
<?php echo $row_xtr2['firstname']; ?>
You only call mysql_fetch_assoc() once, hence you only get the first
row. If you call mysql_fetch_assoc() again you'll get the next row.
So, if you want to find the one where id = 7 or something, you could do
this:
while(($row_xtr2 = mysql_fetch_assoc($xtr2)) !== false) {
if($row_xtr2['id'] == 7) {
echo $row_xtr2['firstname'];
break;
}
}
.
- Follow-Ups:
- Re: Filter Data based on Username
- From: pmAgony
- Re: Filter Data based on Username
- References:
- Filter Data based on Username
- From: pmAgony
- Re: Filter Data based on Username
- From: ZeldorBlat
- Re: Filter Data based on Username
- From: pmAgony
- Re: Filter Data based on Username
- From: pmAgony
- Filter Data based on Username
- Prev by Date: Re: want a back button to get to the last page...
- Next by Date: Re: want a back button to get to the last page...
- Previous by thread: Re: Filter Data based on Username
- Next by thread: Re: Filter Data based on Username
- Index(es):