Coldman Posted May 11, 2008 Share Posted May 11, 2008 Hello i am tring to do an query i have searched the net and i can not find what i need. what i need is this. I have an query that i select all rows from one table and display them on the main page (this par is basic and works good). I want to sign all rows that are new for example all posts that have been posted last 5 days to have an sign that tells that those posts are new. look at this site www(dot)specialjobs(dot)net, see the list of jobs all i want is the new jobs to have an sign that tells they are new. New jobs will be all the jobs that are posted last 5 days. Help please. Quote Link to comment Share on other sites More sharing options...
mezise Posted May 11, 2008 Share Posted May 11, 2008 Hi, this will do what you want to achieve SELECT YourFields FROM YourTable WHERE DATE_ADD(YourDatetime, INTERVAL 5 DAY) > NOW() ORDER BY YourDatetime DESC ; And this query with sign column SELECT IF(DATE_ADD(YourDatetime, INTERVAL 5 DAY) > NOW(), 'NEW', '') AS YourSign FROM YourTable ORDER BY YourDatetime DESC ; Quote Link to comment Share on other sites More sharing options...
Coldman Posted May 11, 2008 Author Share Posted May 11, 2008 Thanks for your replay I tried to configure out but nothing here is my code please let me know how to put that code in this code: $con = mysql_connect("localhost","username","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("database", $con); $result = mysql_query("SELECT * FROM projects where status = 'checked' order by date desc"); while($row = mysql_fetch_array($result)) { $projectid = $row['projectid']; $location = $row['location']; $title = $row['positiontitle']; $company = $row['companyname']; $type = $row['jobtype']; $date = $row['date']; ?> <tr ><td height="50" style="border-bottom: 1px solid #60605e;"><?php echo "<b>$location</b>"; ?> </td><td height="30" style="border-bottom: 1px solid #60605e;"><?php echo "<a href = 'view.php?id=$projectid' style='text-decoration:none; color:#60860d;'><b>$title</b></a><br>$company"; ?></td><td height="50" style="border-bottom: 1px solid #60605e;"><?php echo $type; ?></td></tr> <?php } regards Quote Link to comment Share on other sites More sharing options...
mezise Posted May 11, 2008 Share Posted May 11, 2008 here is my code please let me know how to put that code in this code: I think you have all you need. Try to analize your code, play with it and you will achieve the result very soon. I believe in you. After that your next problem will not be the problem. Good luck! Quote Link to comment Share on other sites More sharing options...
fenway Posted May 12, 2008 Share Posted May 12, 2008 Did you check mysql_error()? "date" is a reserved keyword... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.