Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Output in horizontal not vertical

Status
Not open for further replies.

abovetopsecret

Programmer
Jan 16, 2008
61
GB
I have a list coming from the database that outputs itself in vertical line, can anybody look at this piece of code and help me to get it outputting horizontally in 4's then after 4it goes to the next line.

Code:
<?php
$cnt = 0;
echo "<td>";
while($cnt < $top_count) {
$qw=mysql_query("select * from tbl_touroperators where Nom_Top = '$top_array[$cnt]'");
$rw=mysql_fetch_assoc($qw);
echo "<ul class='navHotel'>";
echo "<li class=\"middletext\"><a href=\"[URL unfurl="true"]http://"[/URL] . $rw[Web_Top] .  "\" class=\"bigweblinks\" target=\"_blank\">" . $top_array[$cnt] . "</a></li>\n";
echo ($cnt % 1 === 0 || $cnt === $top_count - 1) ? "</ul>\n" : "";
$cnt = $cnt+1;
}
echo "</td>";
?>

There is no CSS controlling the <ul> tage either, even though it conatins a couple of classes for text styles and all.

Ta
 
Ive had a bash using the css below, and it isnt quiet right, and cant get it to only pump out 4.

Code:
.navHotel {
	PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 10px 0px 0px; PADDING-TOP: 0px; LIST-STYLE-TYPE: none; 
}

.navHotel LI {
	PADDING-RIGHT: 0.5em; PADDING-LEFT: 0.5em; FLOAT: left; PADDING-BOTTOM: 0px; MARGIN: 0px 0.5em 0px -0.5em; BORDER-LEFT: #000 1px solid; LINE-HEIGHT: 1.1em; PADDING-TOP: 0px; BACKGROUND-COLOR: #fff; LIST-STYLE-TYPE: none;
}
.navHotel LI A {
	COLOR: #666666; TEXT-DECORATION: none; BACKGROUND-COLOR: #fff;
}
.navHotel LI A:hover {
	COLOR: #ff5900;/*; BACKGROUND-COLOR: #ff5900*/
}

Sorry to post twice, but still potching on it.

 
looks ok from my browser.

the easiest way to stack columns is to use css. just set a container to the desired total width and then each item within the container you need to make sure it's a block element, floated (usually left) and given a margin of, say, 24%.
 
you sure it looks ok, to me i got 5 on top line then because there no restriction it got 6 on second line and its squashed up, forcing the line below to wobble.

I was thinking of cutting each line to 5, then i wouldnt have that problem.

but will try your suggestion now.

Thanks
 
got it thanks, its a sort of done job, but if it works out in any other order it doesnt fall like that on that page. But it will do.

Thanks again
 
Try the HTML CSS forums, but more appropriate than here
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top