when someone searches through the search bar it shows all the entries with the same keywords.. but i want it to show from newest entries to oldest how would i do that??? This is the code that i have at the moment <?php $keyword = $_GET['kw']; if(!empty($keyword)){ require('connect.php'); $keyword = mysql_real_escape_string($keyword); $page = intval($_GET['page']); $tpages = ($_GET['tpages']) ? intval($_GET['tpages']) : 1; // 20 by default $adjacents = intval($_GET['adjacents']); $countQuery = "SELECT count(article_id) as count FROM articles WHERE keywords LIKE '%$keyword%'"; $countResult = mysql_query($countQuery); $countArray = mysql_fetch_array($countResult); $count = $countArray['count']; if($count>0){ echo "<p>"; echo $count. ' results found for the keywords "' .$keyword; echo '"'; echo "</p>"; echo "<br />"; $query = "SELECT * FROM articles WHERE keywords LIKE '%$keyword%' OR Description LIKE '%$keyword%'"; $result = mysql_query($query); while($row = mysql_fetch_array($result)) { echo ("<img src='arrow.gif'>"); echo " "; echo '<a style="font-size: 20px" href="'. $row['url'] .'">'. $row['article_name'] .'</a>'; echo "<br />"; echo "<hr />"; } } else{ echo "<p>"; echo 'No results found for the keywords "' .$keyword; echo'"'; echo "</p>"; } } echo "<br />"; if($page<=0) $page = 1; if($adjacents<=0) $adjacents = 4; $reload = $_SERVER['PHP_SELF'] . "?tpages=" . $tpages . "&adjacents=" . $adjacents; include("pagination3.php"); echo paginate_three($reload, $page, $tpages, $adjacents); ?> PHP: Thanks Kurt
Replace this: $query = "SELECT * FROM articles WHERE keywords LIKE '%$keyword%' OR Description LIKE '%$keyword%'"; with $query = "SELECT * FROM articles WHERE keywords LIKE '%$keyword%' OR Description LIKE '%$keyword%' ORDER BY [replace this with field name that contains timestamp] DESC"; If you dont have a field that contains timestamp, then create one.
i sorta cheated and made to colounms, one was the DATE and another i just called posted... so i put the date in both and showed the POSTED as DD/MM/YYYY but pulled them in order of DATE