Jump to content

[SOLVED] Using Select and Where and ordering results issues


Richzilla

Recommended Posts

I'm trying to show the most recent downloads added to my site and then ordering them by the last 5. The code below doesn't return any results. Any ideas on what i'm doing wrong?

 

$query = "SELECT * FROM Mixes WHERE 'download1'!=NULL ORDER BY 'id' DESC ";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < '5') {
$download1=mysql_result($result,$i,"download1");
$id=mysql_result($result,$i,"id");
$dj=mysql_result($result,$i,"dj");
$rave=mysql_result($result,$i,"event");
$date=mysql_result($result,$i,"date");
?>
<? echo $dj ?><br> 
<? echo $event ?><br>  
<? echo $date ?><br>  
<p align='right'>--------------------</p>
<p class="main_text" align="right"><span class="time_main_text_small">

<?

	 $i++;
}
?>

you need a field for timestamping i used lastDL

 

$query = "SELECT * FROM Mixes WHERE 'download1'!=NULL ORDER BY 'lastDL' DESC limit 0,5";

 

 

Revised:

 

<?php

$query = "SELECT * FROM Mixes WHERE 'download1'!=NULL ORDER BY 'date' DESC limit 0,5";
$result=mysql_query($query);
$num=mysql_numrows($result);
while ($row = FetchAssoc($result,MYSQL_NUM))
$download1=$row["download1"];
$id=$row["id"];
echo "{$row["dj"]}<br>";
echo "{$row["event"]}<br>";
echo "{$row["date"]}<br>";
}

?>
<p align='right'>--------------------</p>
<p class="main_text" align="right"><span class="time_main_text_small">

<?php
}
mysql_close();
?>

is ok to use this syntax to add the timestamp into a new column in my database?

 

$_SERVER['REQUEST_TIME'];

 

$query = ("UPDATE Mixes SET submitter = '$sub' , download1 = '$dl1' , download2 = '$dl2' , download3 = '$dl3' , download4 = '$dl4' , timestamp = 'date(U)' WHERE id = '$mix'");

 

I've tried this and its not working.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.