Re: Filter Data based on Username
- From: "ZeldorBlat" <zeldorblat@xxxxxxxxx>
- Date: 24 Jan 2006 08:03:52 -0800
pmAgony wrote:
> Hello-
>
> After logging in a user, I want to display data relevant to that user
> on my page. Like YTD sales and Goals, etc...
>
> The only data that is showing up where the dynamic text is, is for the
> 1st record in my table.
>
> SELECT * FROM XTR WHERE username = 'username'
>
> shouldn't the only information accessible be that of the users?
>
> <?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']; ?>
>
> How do I add the filter?
>
> TIA-
Did you try echo()'ing the query before you execute it? If you do, it
will probably look something like this (when the value of
$username_xtr2 is "someUser"):
select * from XTR where someUser = 'someUser'
Is that really what you wanted?
.
- Follow-Ups:
- Re: Filter Data based on Username
- From: pmAgony
- Re: Filter Data based on Username
- References:
- Filter Data based on Username
- From: pmAgony
- Filter Data based on Username
- Prev by Date: Re: CRUD Frameowrk in PHP
- Next by Date: Re: Filter Data based on Username
- Previous by thread: Filter Data based on Username
- Next by thread: Re: Filter Data based on Username
- Index(es):