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
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
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
Share on other sites

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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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