Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jun 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Display only 1 row - current user

    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.

    PHP Code:
    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

  • #2
    New Coder
    Join Date
    Jan 2006
    Posts
    73
    Thanks
    2
    Thanked 3 Times in 3 Posts
    PHP Code:
    $sql="select * from ".$football->prefix."users where user = '".$member."' order by user"

    while (
    $row mysql_fetch_array($sqlMYSQL_ASSOC)) {
        echo 
    $row["user"];

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

  • #3
    Regular Coder
    Join Date
    Jul 2009
    Posts
    187
    Thanks
    16
    Thanked 8 Times in 8 Posts
    or to save some server processing instead of whiling, just do:

    PHP Code:
    <?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
    Last edited by Jazz914; 06-17-2010 at 02:54 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •