>Also, how can I make certain columns into links? I'm making a site that >will list college courses. When users decide to browse listings by >discipline, or college, I'd like the titles of the courses to be links to >fuller descriptions of those courses. But I'm >not sure how to do that.
<?php if (!isset($order_by)){ $order_by = 'title'; } $query = "select discipline, college, title from courses order by $order_by "; $courses = mysql_query($query) or error_log(mysql_error()); ?> <TABLE> <TR> <TD><A HREF=<?=$PHP_SELF?>?order_by=discipline</TD> <TD><A HREF=<?=$PHP_SELF?>?order_by=college</TD> <TD><A HREF=<?=$PHP_SELF?>?order_by=title</TD> </TR> <?php while (list($discipline, $college, $title) = mysql_fetch_row($courses)){ echo " <TR>\n"; echo " <TD>$discipline</TD>\n"; echo " <TD>$college</TD>\n"; echo " <TD><A HREF=details.php?title=", urlencode($title), ">$title</A></TD>\n"; echo " </TR>\n"; } ?> </TABLE> Actually, you probably have a course "number" which would be a much better ID to use for the details.php page. :-) If you need to generalize this for a ton of columns, or a lot of tables, there is a function named something not unlike mysql_field_name() in PHP which will let you get the field names of the columns of any table in your database. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php