Jump to content


This topic is now archived and is closed to further replies.


Help appreciated - PHP & MySQL problem.

Recommended Posts

Hi there, apologies if the topic title is a little un-descriptive, but I was unsure of how exactly to word my problem.

I'm developing our company intranet and we have a links page where we can basically view links to webpages we often visit arranged by categories. On my page, I've basically got one table - two rows and the second row is split into two columns: the first table row pulls out the category title from the MySQL database and the row beneath it pulls out the appropriate links from that category and does a loop which then pulls out the nex category, and so on and so forth.

What I'm having trouble doing is, the second row is split into two columns and the second column is going completely unused. What I'd like is for Link 1 to be displayed in the first column, followed by Link 2 in the second column, and for this to be repeated down the loop.

If you would like my current code as a reference:

[code] <?php
    $sql="select wlc_id,wlc_name " .
      "from web_link_categories " .
    "order by wlc_name";
while ($row = mysql_fetch_array($result)) { // start of cateogry loop 
  <table width="100%" border="0" cellspacing="1" cellpadding="5">
<tr bgcolor="#FFEEDD">
  <td width="100%" colspan="2" class="link_cat_header">
    <a name="<?php print($row["wlc_id"]); ?>"><?php print($row["wlc_name"]); ?></a>
    <a href="#top"><img src="images/uparrow.gif" alt="Return to top" width="17" height="17" border="0" style="float:right;"></a>
  $sql2="select wl_id,wl_name,wl_desc,wl_url " .
    "from web_links " .
  "where wl_category = " . $row["wlc_id"] .
  " order by wl_name";
  while ($row2 = mysql_fetch_array($result2)) { // start of link loop
<tr class="link_content">
  <td width="50%" bgcolor="#FFFFCC" class="link_content"><?php print($row2["wl_name"]); ?><br><?php print($row2["wl_desc"]); ?><br><a href="<?php print($row2["wl_url"]); ?>"><?php print($row2["wl_url"]); ?></a></td>
  <td width="50%" bgcolor="#FFFFCC" class="link_content"></td>
</tr><?php } // end of link loop ?>
  <?php } // end of category loop ?>[/code]

Any help I receive will be appreciated. Apologies again as I am a PHP newbie. Cheers for your time.  :)

Share this post

Link to post
Share on other sites
Here's what the page currently looks like with the code posted above:

And this is what I would like the page to look (obviously with unique links in the second column):

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.