Hi... I want to output my data from my database one by one and then each data will highlight itself every other line... for example...
ralph 24 male single
imel 22 female single
john 22 male married
Emil 24 male married
i want "imel" and "emil" to be highlighted and every other line and so on...
I really don't know how to do this... can you help me out pls...
here is my code:
<head>
<title>Test</title>
<style>
A.after:link { color:rgb(0,0,255); text-decoration:none; }
A.after:visited { color:rgb(0,0,255); text-decoration:none; }
A.after:active { color:rgb(0,0,255); text-decoration:none; }
A.after:hover { color:rgb(0,0,160); text-decoration:underline;}
</style>
</head>
<body>
<?
$text ="We could not find any match to your search<br> <p>please click <a href='index.htm'>here</a> to go back.</p> ";
mysql_connect($localhost,$username,$password);
mysql_select_db($dbname);
$limit = 2; // THE NUMBER OF MAXIMUM DATA TO BE DISPLAYED PER PAGE
$products = strtolower($products);
$sqlQuery = "select * from computers where products regexp '$products'";
$result = mysql_query($sqlQuery) or die ($text);
$numrows = mysql_num_rows($result);
$totalrows = mysql_num_rows($result);
print "<p><font face='arial' size='2'>We have found <font color='#FF0000'><strong>$numrows</strong></font> record(s) to your query.</font></p>";
echo "<div align='center'><center>
<table border='0' width='555' cellpadding='0'>
<tr>
<td width='61' align='center' bgcolor='#0066CC'><font face='Arial' size='2'
color='#FFFFFF'><strong>Picture</strong></font></td>
<td width='204' align='center' bgcolor='#0066CC'><font face='Arial' size='2'
color='#FFFFFF'><strong>Brand</strong></font></td>
<td width='140' align='center' bgcolor='#0066CC'><font face='Arial' size='2'
color='#FFFFFF'><strong>Price</strong></font></td>
<td width='142' align='center' bgcolor='#0066CC'><font face='Arial' size='2'
color='#FFFFFF'><strong>Date Posted</strong></font></td>
</tr>
<tr>
<td width='61' align='center' height='5'></td>
<td width='204' align='center' height='5'></td>
<td width='140' align='center'></td>
<td width='142' align='center'></td>
</tr>
</table>";
if(empty($page)){
$page = 1;
}
$limitvalue1 = $page*$limit-($limit);
$sql = "SELECT * from computers where products regexp '$products' LIMIT $limitvalue1, $limit";
$sql_result = mysql_query($sql) or die ("Couldn't execute query");
if ($numrows > 0 )
{ //START OF IF STATEMENT
while ($data = mysql_fetch_array($sql_result)) { //START OF WHILE STATEMENT
$rname = $data["name"];
$raddress = $data["address"];
$remail = $data["email"];
$rproducts = $data["products"];
$rdate = $data ["date"];
$rcategory = $data ["category"];
$rprice = $data ["price"];
echo "<div align='center'><center>
<table border='0' width='555' cellpadding='0'>
<tr>
<td width='61' align='center'></td>
<td width='204' align='left'><font face='Arial' size='1'><span
style='font-family: verdana, arial, helvetica'><a
href='file:///C:/WINDOWS/Desktop/FILES/motor/2123.htm' class='after'>$rproducts</a>
</span></font></td>
<td width='140' align='left'><font face='Arial' size='1'><span
style='font-family: verdana, arial, helvetica'>Php $rprice</span></font></td>
<td width='142' align='left'><font face='Arial' size='1'><span
style='font-family: verdana, arial, helvetica'>$rdate</span></font></td>
</tr>
</table>
</center></div>";
}
}
else {
print "<p><font face='arial' size='2'>Sorry, there was no match found to your query.</font></p>";
}
// THIS IS START OF THE CODE WHERE WE WILL DISPLAY THE CODE LINKS
print "<br>";
if($page != 1) {
$pageprev= $page - 1;
echo "<A HREF=$PHP_SELF?page=$pageprev&products=$products class='after'><img src='2arrow_left.gif' width='12' height='8' alt='2arrow_left.gif (82 bytes)' border='0'></A> "; // if page is not equal to one, prev goes to $page - 1
}
else {
echo "<p>";
//echo "<A HREF=$PHP_SELF?page=$page&products=$products class='after'><img src='2arrow_left.gif' width='12' height='8' alt='2arrow_left.gif (82 bytes)' border='0'></A> "; // Otherwise, PREV reloads the page
}
$numofpages = $totalrows/$limit;
for($i= 1; $i < $numofpages; $i++) {
echo "<font face='Arial' size='1'><A HREF=$PHP_SELF?page=$i&products=$products class='after'>$i</A> </font>"; //make number navigation
}
if($totalrows%$limit != 0) {
echo "<font face='Arial' size='1'><A HREF=$PHP_SELF?page=$i&products=$products class='after'>$i</A> </font>"; ////if there is a remainder, add another page
}
if(($totalrows-($limit$page)) > 0){
$pagenext = $page + 1;
echo "<a HREF=$PHP_SELF?page=$pagenext&products=$products class='after'><img src='2arrow_right.gif' width='12' height='8' alt='2arrow_right.gif (82 bytes)' border='0'></A> "; // if the totalrows - $limit $page is > 0 (meaning there is a remainder), leave the next button.
}
mysql_close();
?>
</body>