...

View Full Version : Display only 1 row - current user



patsman77
06-16-2010, 10:14 PM
I have a code that works but I want to liit it to only show the row of the current user viewing the page. Can someone show me where I can make the change? Right now it spits out the results for all users, I just want it for the current user viewing the page.



if($football->showPicks == "Y" or $member == $football->admin_username)
{
$sql="select * from ".$football->prefix."users where user != '".$football->admin_username."' order by user ASC";
}
else
{
$sql="select * from ".$football->prefix."users where user = '".$member."' order by user";
}
$rs = $football->dbQuery($sql);
while($row=mysql_fetch_object($rs))
{
$username=$row->user;
$uname=$row->user;
if ($uname=="") {
$uname=$username;
}
if (round($i/2)*2==$i)
{
$color = "#ffffff";
?>
<tr>
<?php }
else
{
$color = "#d0d0d0";
?>
<tr class="alt">
<?php }
$i++;
?>
<td><?php echo $uname; ?></td>
<?php //Display picks for this user, highlight any correct ones.
$total=$football->NumberOfGames($week);
// Get current date and time to determain if a game has started or not
$date = date("m/d/Y");
$time = date("H:i:s A");
$datetime = $football->doDate($date,$time,$football->display_offset);

$sql1="select * from ".$football->prefix."picks, ".$football->prefix."schedule where user = '".$username."' and week = ".$week." and ".$football->prefix."picks.gameid = ".$football->prefix."schedule.gameid order by ".$football->prefix."schedule.gametime, ".$football->prefix."schedule.gameid";
$rs1 = $football->dbQuery($sql1);
$rows = mysql_num_rows($rs1);
if($rows > 0)
{
while($row1=mysql_fetch_object($rs1))
{
$pick=$row1->pick;
$icon=$iconfile[$pick];
$result=$row1->result;
$sresults=$row1->sresults;
$style = "\"border: .2em solid $color;\"";
if($pick=="")
{
$pick="---";
}
// check if system usisng spread
$bcolor = "#006600"; // set win border color
if ($football->usespread == "Y") {
if ($pick != $result and $pick == $sresults) { $bcolor ="#006600"; }
$result=$sresults;
}

if ($pick==$result)
{
// $pick="<strong>".$pick."</strong>";
// Hack to see winner better from Mrtalk
$pick="<font color='#0b7b0b' size=1pt><strong><B>".$pick."</B></strong></font>";
// $style = "\"border: .2em solid $bcolor;\"";
}

if ($result=="TIE")
{
// $pick="<strong>".$pick."</strong>";
// Hack to see winner better from Mrtalk
$pick="<font color='#ff0000' size=1pt><strong><B>".$pick."</B></strong></font>";
// $style = "\"border: .2em solid $bcolor;\"";
}

if ($member != $football->admin_username)
{
// $alllocked = $football->ckAlllocked($week);
// if ($alllocked != true)
if ($row1->gametime >= $datetime and $football->showPicks == "Y" and $member != $username) // has game already started
{
$pick="---";
}
}
if ($pick=="---") {
?>
<td><?php echo $pick; ?></td>
<?php }
else {
?> <td>

<? if ($football->display_graphics == "Y" and $result!="TIE") { ?>
<image src = "images/<? echo $icon; ?>" width="20" style="<? echo $style; ?>" ?> width=20 style=<? echo $style; ?>><br>
<? } ?>
<? if ($football->display_graphics == "Y" and $result=="TIE") { ?>
<image src = "images/<? echo $icon; ?>" width="20" style="<? echo $style1; ?>" ?> width=20 style=<? echo $style1; ?>><br>
<? } ?>

<? echo $pick; ?></td><?
}
}




Any help would be appreciated!

Thanks,

Patsman77

xGIHavoc
06-16-2010, 11:03 PM
$sql="select * from ".$football->prefix."users where user = '".$member."' order by user";

while ($row = mysql_fetch_array($sql, MYSQL_ASSOC)) {
echo $row["user"];
}

I haven't really analyzed your code but that is probably the basic idea of what you need.

Jazz914
06-17-2010, 01:50 AM
or to save some server processing instead of whiling, just do:


<?php
$sql = mysql_query("SELECT * FROM `''.$footbal->prefix."users` WHERE 'users' = '".$member."');
$result = mysql_fetch_row($sql);
?>

You wouldn't need to order this statement, as generaly usernames are unique so ordering one value, is just pointless



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum