/    Sign up×
Community /Pin to ProfileBookmark

Display MySQL results in a single row

Hi guys, need help with the following issue:

[code=php]
<?php
if(!isset($action)) {
$query=mysql_query(“SELECT * FROM products ORDER BY id LIMIT 6”) or die (“Cant select products: ” . mysql_error());
while($rows=mysql_fetch_array($query)) {
echo “<div class=’view_block_produs’>”;
echo “<a href=’index.php?go=products&action=view&catid=$catid&id=$rows[id]’ class=’view_produs_link’>$rows[name]</a><br>”;
echo “<div style=’padding-top: 10px;’>”;
echo “<a href=’index.php?go=products&action=view&catid=$catid&id=$rows[id]’><img src=’./product_img/$rows[img_small]’ border=’0′ class=’img_small’></a>”;
echo “<span class=’produs_view_small_block’><b>Stoc</b>: $rows[stock]<br> $rows[code]</span>”;
echo “</div>”;
echo “</div>”; }
}
?>
[/code]

The problem is that I have to display those two boxes (from one div to another) in a single row, not one under another. Thus, I need 6 boxes displayed in 3 rows by 2 boxes in each row. How can I solve the problem?

Thanks a lot.

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@jasonahouleMar 06.2007 — Sounds more like a CSS question than PHP. Can you post the styles you are using (i.e. "view_block_produs") so we can take a look? You will want to float the <div> elements and set their width.
Copy linkTweet thisAlerts:
@NogDogMar 06.2007 — <i>
</i>&lt;div class='view_block_produs' [color=red]style='float: left; clear: left;'[/color]&gt;

&lt;div style='padding-top: 10px; [color=red]float: left; clear: right;[/color]'&gt;
Copy linkTweet thisAlerts:
@werredauthorMar 06.2007 — Thanks a lot for the help, guys.

But anyway, the point is that I have to repeat the while sequence with a single DIV and I don't think that that is a solution, NogDog.
Copy linkTweet thisAlerts:
@werredauthorMar 06.2007 — Thanks guys, the problem is solved now.
×

Success!

Help @werred spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...