Jump to content

vandelay

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

vandelay's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Also I'm using this function to get the time it was posted ago. e.g. 2 days ago: function agoDate( $tDate ) { $time_stamp = time() - strtotime( str_replace( "-", "/", $tDate ) ); if( $time_stamp > 31536000 ) { $ago = round( $time_stamp / 31536000, 0 ) . ' year'; } elseif( $time_stamp > 2419200 ) { $ago = round( $time_stamp / 2419200, 0 ) . ' month'; } elseif( $time_stamp > 604800 ) { $ago = round( $time_stamp / 604800, 0 ) . ' week'; } elseif( $time_stamp > 86400 ) { $ago = round( $time_stamp / 86400, 0 ) . ' day'; } elseif( $time_stamp > 3600 ) { $ago = round( $time_stamp / 3600, 0 ) . ' hour'; } elseif( $time_stamp > 60 ) { $ago = round( $time_stamp / 60, 0) . ' minute'; } else { $ago = $time_stamp . ' second'; } if( $ago > 1 ) { $ago .= 's'; } return $ago; }
  2. Yeah, I'll post the rest of the code: //follow list $followList_sql = "SELECT * FROM follow WHERE username = '$user'"; $getFollow = mysql_query($followList_sql); $getFollow_RecordCount = mysql_num_rows($getFollow); //display message is not following anybody if($getFollow_RecordCount == 0){ echo 'You are not following anyone. You can explore tracks on the <a href="browse.php">browse page</a>.'; echo '<br/>'; echo "Most recent tracks"; echo '<br/>'; $recentTracks_sql = "SELECT * FROM upload WHERE artist != '$user' ORDER BY date DESC LIMIT 0, 5"; $getRecentTracks = mysql_query($recentTracks_sql); $getRecentTracks_RecordCount = mysql_num_rows($getRecentTracks); while ($row = mysql_fetch_array($getRecentTracks)){ $track = $row['song']; echo $track; } } else{ while ($row = mysql_fetch_array($getFollow)){ $follow = $row["follow"]; //check and display follow list $checkUpload_sql = "(SELECT id, artist, song, nothing, date, count FROM upload WHERE artist = '$follow') UNION (SELECT null, username, null2, bulletin, date, null3 FROM bulletin WHERE username = '$follow') ORDER BY `date` DESC"; $getUpload = mysql_query($checkUpload_sql); $getUpload_RecordCount = mysql_num_rows($getUpload); while ($row = mysql_fetch_array($getUpload)){ $song = $row['song']; $bulletin = $row['nothing']; $id = $row['id']; $date = $row['date']; $count = $row['count']; if($song == NULL){ ?> <table id="post"> <tr> <td> <?php echo $bulletin; ?> </td> </tr> <tr> <td> <?php echo agoDate($date) . " ago "; echo '<a href="user.php?user='.$follow.'">'.$follow.'</a>'; ?> </td> </tr> </table> <br/> <?php } else{ ?> <table id="post"> <tr> <td class="song"> <?php echo ''.$song.''; ?> </td> <td class"playButton"> <?php echo '<button onclick=javascript:play('.$id.') id="button" type="button">play</button>'; ?> </td> <td class="playCount"> <?php echo ''.$count.' plays'; ?> </td> </tr> <tr> <td> <?php echo agoDate($date) . " ago "; echo '<a href="user.php?user='.$follow.'">'.$follow.'</a>';?> </td> </tr> </table> <br/> <?php } }
  3. Tried using backticks around date but there was no change in the order. Oh yeah, I hate using UNION too, but unfortunately I've got to use it in this instance.
  4. Hey Keith, thanks for the reply. Yeah, I've tried forcing it with brackets but nothing changed. However, I've not tried changing the date data type. I'll have to change my insert query on another page though because I use the date as a timestamp when a new record is added. I'll try it out now. edit: Tried the second solution but it didn't work. This is driving me crazy!
  5. I've been looking for a solution to this problem for a while now, but I can't find one. Hopefully somebody here can help me out. I have the following statement: $checkUpload_sql = "SELECT id, artist, song, nothing, date, count FROM upload WHERE artist = '$follow' UNION SELECT null, username, null2, bulletin, date, null3 FROM bulletin WHERE username = '$follow' ORDER BY date DESC"; When I display the rows from my database it works, however they are in the wrong order. It isn't ordering it by date. I've run the same query in mysql and it displays and orders them correctly. It's just not working on when I display it on my webpage. Any help would be appreciated.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.