Jump to content


Photo

Displaying results horizontally instead of vertically.


  • Please log in to reply
3 replies to this topic

#1 blade_922

blade_922
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 15 September 2006 - 07:47 PM

Firstly the PHP Code



<table class='tablefull' >

<?php

$hotmain=mysql_query("select * from mos_content ORDER BY 'mainhot' DESC LIMIT 2 ") or die(mysql_error());
while ($donnee = mysql_fetch_array($hotmain))
{ $title= $donnee['title'];  
 $introtext=$donnee['introtext'];
$author=$donnee['created_by']; 
$sectionid=$donnee['sectionid']; 
$displayhot=$donnee['displayhot'];
$mainhot=$donnee['mainhot'];
$mainhot_img=$donnee['mainhot_img'];

if ($mainhot==1)

{

echo "<tr><td id='maintitle'> EXCLUSIVE </td></tr>";
echo " <tr><td id='image'> <center> <a href='http://www.pspcave.com/'> <img src='$mainhot_img'></a></center></td></tr>";

echo "<tr><td id='articletitle'><center><a href='http://www.pspcave.com/'>";

echo $title;

echo "</a></center></td></tr>";

}

}

?>

</table>



Ok so now the problem. This code manages to display 2 x the result since i set the Limit to 2. But it displays it one on top of each other, vertically.

Like

[result1]
[result2]

But i want it to display it horizontally, side by side

like
[result1] [result2]
I know the <td> and <tr> tags should be changed. but i have been sitting around messing around with them but have no idea how to do it to display correct.

Regards

#2 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 15 September 2006 - 07:56 PM

It's possible, but not very easy.

I think I have some code somewhere I picked up recently that does it.

I'll look and post if I find it.

Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#3 freakus_maximus

freakus_maximus
  • Members
  • PipPipPip
  • Advanced Member
  • 177 posts

Posted 15 September 2006 - 08:08 PM

Check out the Code Snippet forum here ->

http://www.phpfreaks...ic,95426.0.html

It explains how to do multicolumn displays.

#4 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 15 September 2006 - 08:48 PM

OK, so that code wasn't hard at all... My bad.

I was thinking of something completely different.  Multiple columns but still with results going vertically, like this:

|---|---|
| 1 | 4 |
|---|---|
| 2 | 5 |
|---|---|
| 3 | 6 |
|---|---|

Over complicating things again :)

Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users