I'm trying to build a directory for a website. Kinda like Yahoo's directory page where it lists the various categories. But, I'm having trouble putting together a script to retrieve the categorie list, cut it in half (or so if it's an odd number) and insert the results into a two columned table, so it looks even.
Right now I got:
/* mySQL Connection */
mysql_connect($dbserver,$dbuser,$dbuserpassword) or DIE("Cannot connect to server.");
@mysql_select_db($dbname) or DIE("Cannot select database");
$result = mysql_query("SELECT id,coltest_value FROM col_test");
while($data[]=mysql_fetch_array($result)) {
print '11 Entries - Values 1,2,3,4,5 & a,b,c,d,e,f';
$totrows = mysql_num_rows($result);
$half = ceil($totrows/2.0);
}
I havn't gotten any further. I've added:
echo 'Half: ' .$half;
echo '<br>totrows: ' .$totrows;
To see what the values of the variables are, and I get this:
11 Entries - Values 1,2,3,4,5 & a,b,c,d,e,f
Half: 6
totrows: 11
eleven times....
So, I the script runs correctly, problem is, I don't know how to go about getting it to print out the results of the table. I've been thinking of a while or for loop, but not sure how to impliment one. Anyone have an idea?