Popular Posts

There was an error in this gadget

Dec 11, 2011

Show data from mysql in cell(PHP)

<table>
<tr><th>Search Jobs By Categories</th></tr>
<tr><td>
<?php

$query = "SELECT id, job_category_name FROM job_category WHERE id!=1 ORDER BY _sort ASC";
$result = mysql_query($query) or die ("Query failed");

//get the number of rows in our result so we can use it in a for loop
$numrows = (mysql_num_rows ($result));


// loop to create rows
if($numrows >0){
echo "<table width ='100%' border = '1' cellspacing = '0' cellpadding = '0'>";
// loop to create columns
$position = 1;
while ($friendList = mysql_fetch_array($result)){
if($position == 1){echo "<tr>";}
echo "<td><a href='../search_jobs/jobs_by_category.php?id=".$friendList['id']."'><br />".$friendList['job_category_name']."</a><br /></td> ";
if($position == 2){echo "</tr> "; $position = 1;}else{ $position++;}
}//while

$end = "";
if($position != 1){
for($z=(3-$position); $z>0 ; $z--){
$end .= "<td></td>";
}
$end .= "</tr>";
}

echo $end."</table> ";
}//if

?>


</td></tr>
</table>

No comments:

Post a Comment