sory there is some mistake inmy code. Here is the code:
PHP Code:
<html>
<head><title></title></head>
<body>
<form action = search_news.php method = post>
//this link doesn't work. I want, i can search from the search page. Pls help.. :confused:
</table>
<tr> <td >Search</td>
<td><input type = text name = keyword size = 20 ></td>
<td>
</td>
<td><input type = submit name = submit value = Go ><td>
</tr>
</table>
</form>
<?php
$user = "root";
$host = "localhost";
$pass = "";
$connection = mysql_connect($host,$user,$pass);
$query = "select * from news where title like '%$keyword%'
or abstraksi like '%$keyword%'and publish == 'Y'";
$nb_result = mysql_query($query);
$nb_row_found = mysql_num_rows($nb_result);
$rowperpage = 10; //nb news per page
if (empty($offset)){
$offset = 0;
}
if ($nb_row_found==0){
echo "<b>$keyword</b> doesn't matched any news";
exit;
}
else{
echo "<b>$keyword</b><br> found ".$nb_row_found."";
}
//get result
$result = mysql_query("select * from news where title like '%$skeyword%'
or abstraksi like '%$keyword%'order by id limit $offset,$rowperpage");
echo "<table align = center><h2>News found : </h2>";
echo "<table border = 0 >";
while($row_result = mysql_fetch_array($result))
{ echo "<tr>";
echo "<td>";
echo "<a href = view($row_result[id]) >".$row_result[title]."</a>";
/* i want to make a function to view news content which id = $row_result[id] can i call it like this ??? :confused: */
echo $row_result[abstraksi];//abstraksi
echo "<td>";
echo "<tr><td align = right>";
echo "</td></tr>";
}
echo "</table>";
echo "<div align = center>";
if ($offset != 0){
$prevoffset = $offset-$rowperpage;
echo "<a href = $PHP_SELF?offset= $prevoffset>Prev</a><nobr>";
}
//count pages
/*i have get the result of the search but if the result more than 1 page i still don't get link to next page result whats wrong here?? pls help :confused: */
$max_page = ceil($nb_row_found/$rowperpage);
for ($i = 1;$i <= $maxpage;$i++){
$newoffset = $rowperpage * ($i -1);
if ($offset != $newoffset){//print link to page
echo "<a href = $PHP_SELF?offset = $newoffset>$i</a></nobr>";
}
else{//print without link
echo " ".$i." ";
}
if ((!($offset/$rowperpage) + 1 == $max_page)&& $maxpage != 1 ){
$newoffset = $offset + $rowperpage;
echo "<a href = $PHP_SELF?offset = $newoffset>Next</a><nobr>";
echo "</div>";
}
}
?>
</body>
</html>
// how to make an option search news by title or by content? :(
//thank you
in my database i have a field with datetime type how to print just the time or just the date from that type :confused: