Jump to content


Photo

Help appreciated - PHP & MySQL problem.


  • Please log in to reply
2 replies to this topic

#1 prisonic-fairytale

prisonic-fairytale
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 09 October 2006 - 01:27 PM

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:

<?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 ?>

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

#2 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 09 October 2006 - 01:31 PM

can you draw a little picture of what you want it to look like, for clarity?
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#3 prisonic-fairytale

prisonic-fairytale
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 09 October 2006 - 01:37 PM

Here's what the page currently looks like with the code posted above:
Posted Image

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users