Results 1 to 4 of 4

Thread: trying to get only one row

  1. #1
    Join Date
    Jan 2007
    Location
    The stage
    Posts
    568
    Thanks
    23
    Thanked 6 Times in 6 Posts

    Default trying to get only one row

    Now that the time is all fixed I am having a problem with displaying the info. This system is similar to myspace's and facebook's one.
    I only want to display one row
    i developed this system but it isn't working...
    PHP Code:
    <?php
                
    }
                
    mysql_select_db("markmon_getaband_feeds"$con);

                
    $result mysql_query("SELECT * FROM status WHERE user_id='$id'");

                while(
    $row mysql_fetch_array($result))
                
    $i=0;
                  {
                 if(
    $i<1){
                 echo 
    $row['message'];
                 echo 
    "  ";
                 
    $time $row['time'];
                 
    $current time();
                 
    $passed $current-$time;
                if(
    $passed<=10){
                     echo 
    "a few seconds ago...";
                    }
                if(
    $passed>10 && $passed<60){
                     echo 
    $passed " seconds ago";
                    }
                if(
    $passed>=60 && $passed<=120){
                        echo 
    round($passed/60) . " minute ago";
                    }
                if(
    $passed>=121 && $passed<599){
                        echo 
    round($passed/60) . " minutes ago";
                    }
                if(
    $passed>600){
                    echo 
    round($passed/600) . " hours ago";
                    }
                if(
    $passed>86400 && $passed<172800){
                    echo 
    "yesterday.";
                 }
                if(
    $passed>172800){
                    echo 
    " On " $row[weekday];
                    }
                
    $i=40;
                }

                else{
                }
                }
                
    ?>
    i get this result "24832729 hours ago On"
    thanks up front
    Last edited by Rockonmetal; 10-08-2008 at 07:17 PM.

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Here:
    Code:
    <?php
                }
                mysql_select_db("markmon_getaband_feeds", $con);
    
                $result = mysql_query("SELECT * FROM status WHERE user_id='$id'");
               $xa = 0;
    
                while($row = mysql_fetch_array($result) && $xa<=1)
                $i=0; $xa+=1;
                  {
                 if($i<1){
                 echo $row['message'];
                 echo "  ";
                 $time = $row['time'];
                 $current = time();
                 $passed = $current-$time;
                if($passed<=10){
                     echo "a few seconds ago...";
                    }
                if($passed>10 && $passed<60){
                     echo $passed . " seconds ago";
                    }
                if($passed>=60 && $passed<=120){
                        echo round($passed/60) . " minute ago";
                    }
                if($passed>=121 && $passed<599){
                        echo round($passed/60) . " minutes ago";
                    }
                if($passed>600){
                    echo round($passed/600) . " hours ago";
                    }
                if($passed>86400 && $passed<172800){
                    echo "yesterday.";
                 }
                if($passed>172800){
                    echo " On " . $row[weekday];
                    }
                $i=40;
                }
    
                else{
                }
                }
                ?>
    Jeremy | jfein.net

  3. #3
    Join Date
    Jan 2007
    Location
    The stage
    Posts
    568
    Thanks
    23
    Thanked 6 Times in 6 Posts

    Default

    It still doesn't work... here is the code now:
    PHP Code:
    <?php session_start();?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <link href="../css/menu.css" media="screen" rel="stylesheet" type="text/css" />
    <link href="../css/main.css" media="screen"  rel="stylesheet" type="text/css" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />


     
    <title>Getaband.net: Get out there and play!</title>
    </head>
    <body>
    <?php
    $email 
    $_SESSION[''];
    $password $_SESSION[''];
    $id $_SESSION[''];
    $con mysql_connect("localhost","","");
    if(!
    $con)
      {
      die(
    'Could not connect: ' mysql_error());
      }

    mysql_select_db("markmon_getaband_users"$con);

    $result mysql_query("SELECT * FROM users WHERE id='$id'");

    while(
    $row mysql_fetch_array($result))
      {
    ?>
    <center>
    <table align="center" width="750">
    <tr>
    <td colspan="2" align="center">
    <img src="../media/banner.png" /></td>
    </tr>
    <tr>
    <td height="196" width="180" valign="top">
    <div class="arrowgreen">
        <ul>
            <li><a href="index.php" title="Home">Home</a></li>
            <li><a href="../blog.php" title="Team Blog">Team Blog</a></li>
            <li><a href="../musicianscp/tour.php" title="Tour Getaband.net">Take a tour</a></li>
        </ul>
    </div>
    <br />
    <div class="arrowgreen">
        <ul>
            <li><a href="edit.php?edit=profile" title="Edit your profile">Edit your profile</a></li>        
              <li><a href="edit.php?edit=pictures" title="Edit your pictures">Edit your pictures</a></li>
            <li><a href="edit.php?edit=media" title="Edit your media">Edit your media</a></li>        
              <li><a href="edit.php?edit=settings" title="Edit your settings">Edit your settings</a></li>
               <li><a href="edit.php?edit=account" title="Edit your account">Edit your account</a></li>
            <li><a href="edit.php?edit=blog" title="Edit your blog">Edit your blog</a></li>
              <li><a href="inbox.php?display=home" title="Your Inbox">Your Inbox</a></li>
              <li><a href="requests.php?display=home" title="Your Requests">Your Requests</a></li>
            
               

        </ul>
    </div>
    <br />
    </td>
      <td align="left" valign="top">
          <div class="profilebox">
            <fieldset>
              <span class="subheader">What are you doing right now?</span>
                <br /><span class="status" id="status">
    <?php
                
                
    }
                
    mysql_select_db("markmon_getaband_feeds"$con);

                
    $result mysql_query("SELECT * FROM status WHERE user_id='$id'");
               
    $xa 0;

                while(
    $row mysql_fetch_array($result) && $xa<=1)
                  {
                 
    $a1 $row['time'];
                 
    $current time();
                 
    $passed $current-$a1;
                if(
    $passed<=10 && $passed>0){
                     echo 
    "a few seconds ago...";
                    }
                if(
    $passed>=11 && $passed<=59){
                     echo 
    $passed " seconds ago";
                    }
                if(
    $passed>=60 && $passed<=120){
                        echo 
    round($passed/60) . " minute ago";
                    }
                if(
    $passed>=121 && $passed<599){
                        echo 
    round($passed/60) . " minutes ago";
                    }
                if(
    $passed>=600){
                    echo 
    round($passed/600) . " hours ago";
                    }
                if(
    $passed>86400 && $passed<1727999){
                    echo 
    "yesterday.";
                 }
                if(
    $passed>=172800){
                    echo 
    " On " $row[weekday];
                    }
                else{
                    echo 
    "Error Getting Time";
                    }
                
    $xa=1;
                }
                
    ?>
                <br />
              <form action="../forms/update_status.php" method="post">
                <input type="text" name="status" size="50" value="What are you doing right now?" onFocus="if(this.value=='What are you doing right now?')this.value='';">
                <input type="submit" value="Update"  class="button"/>
                </form>
            </fieldset>
            <br /><span class="status"><b>Friend's Name</b> is currently doing this.
            <a href="../forms/comment_updates.php?id=1&ref=home">Comment</a></span>
            <br />
            <span class="status"><b>Friend's Name</b> is currently doing this.
            <a href="../forms/comment_updates.php?id=2&amp;ref=home&amp;for=status">Comment</a></span></div>
        <p>&nbsp;</p></td>
    </table>
    </center>

    <div>

    </div>

    </body>
    </html>
    I still get: "2039153 hours ago On "
    I also cleared out the rows and added a new one... Though i still get this message...

  4. #4
    Join Date
    Jan 2007
    Location
    The stage
    Posts
    568
    Thanks
    23
    Thanked 6 Times in 6 Posts

    Default

    script now works I had to change a couple of things though...
    Instead of the old while, I now have this:
    PHP Code:
    while(($row mysql_fetch_array($result)) && $xa<=1
    Then
    PHP Code:
    if($passed>=600 && $passed<=86400){ 
    and then took out the error message...

Bookmarks

Posting Permissions

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