Jump to content

Help appreciated - PHP & MySQL problem.


prisonic-fairytale

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";
 
$result=mysql_query($sql);
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>
  </td>
    </tr>
<?php
  $sql2="select wl_id,wl_name,wl_desc,wl_url " .
    "from web_links " .
  "where wl_category = " . $row["wlc_id"] .
  " order by wl_name";
 
  $result2=mysql_query($sql2);
  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 ?>
  </table><br>
  <?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.  :)
Link to comment
Share on other sites

Here's what the page currently looks like with the code posted above:
[IMG]http://i47.photobucket.com/albums/f151/angels-whisper/links_current.gif[/img]

And this is what I would like the page to look (obviously with unique links in the second column):
[IMG]http://i47.photobucket.com/albums/f151/angels-whisper/links_desired.gif[/img]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.