Jump to content

MySql Query ??


Coldman

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/105156-mysql-query/
Share on other sites

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
;

Link to comment
https://forums.phpfreaks.com/topic/105156-mysql-query/#findComment-538512
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/105156-mysql-query/#findComment-538531
Share on other sites

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.