display images in two columns
#1
Posted 10 February 2013 - 03:38 PM
now its
1
2
3
4
instead of
12
34
<div id="welcome">
<H3> </H3>
</div>
<div id="homeCols">
<div id="catCol">
<div>
<b class="orageBG">
<b class="orageBG5"></b>
<b class="orageBG4"></b>
<b class="orageBG3"></b>
<b class="orageBG2"></b>
<b class="orageBG1"></b></b>
<div id="catCol2">
<h3>Categories</h3>
<div> <b class="orageBG"> <b class="orageBG1"></b> <b class="orageBG2"></b> <b class="orageBG3"></b> <b class="orageBG4"></b> <b class="orageBG5"></b></b>
<div class="orageBGfg">
<?
$sql = "SELECT DISTINCT category FROM forsale_content ORDER BY category ASC";
$result = mysql_query($sql);
while ($record = mysql_fetch_object($result)) {
$query = "SELECT COUNT(*) FROM forsale_content WHERE category='$record->category' AND status='online'";
$numentries = mysql_query($query) or die("Select Failed!");
$numentry = mysql_fetch_array($numentries);
?>
<div id="cat"><a href="?q=cat-view&category=<? echo"$record->category";?>"><? echo "$record->category";?></a> (<? echo $numentry[0]; ?>)</div>
<?
}
?>
</div>
<b class="orageBG"> <b class="orageBG5"></b> <b class="orageBG4"></b> <b class="orageBG3"></b> <b class="orageBG2"></b> <b class="orageBG1"></b></b> </div>
</div>
</div>
</div>
<div id="newestCol">
<h3>Newest Listings</h3>
<?
$sql = "SELECT * FROM forsale_content WHERE status='online' ORDER BY id DESC LIMIT 15";
$result = mysql_query($sql);
echo "<table><tr>";
$count = 1;
while ($record = mysql_fetch_object($result)) {
?>
<div id="newestBlock">
<div id="newTitle">
<a href="?q=detail&id=<? echo "$record->id";?>">
<img src="<? echo "$record->photo";?>" width="300" />
<?php if($record->price != "") { ?>
<?php } ?>
<?
if ($count++ % 2 == 0) {
echo "</tr><tr>";
}
}
echo "</tr></table>";
?>
</div>
</div>
<div id="newDate"></div>
</div>
</div>
</div>
#2
Posted 10 February 2013 - 03:49 PM
How to Get Good Help: How to Ask Questions | Don't be a help vampire
Debugging Your Code: Debugging your SQL | What does a php function do? | What does a term mean? | Don't see any errors?
Things You Should Do: Normalize Your Data | use print_r() or var_dump()
Lulz: "Functions should not have side effects." - trq
Please take a look at my new PHP/Web Dev blog: The Web Mason - Thanks!!
#3
Posted 10 February 2013 - 09:34 PM
(Silly var names for educational purposes only)
<?php
// set up your empty column HTML string holders
$col-A-html-string = "";
$col-B-html-string = "";
while ($record = mysql_fetch_object($result)) {
// build each item (we are staying inside PHP here)
$item-html-string = "";
$item-html-string .= "<h2>" . $record->title . "</h2>";
$item-html-string .= "<p>" . $record->info . "</p>";
..etc...
// flip flop and deposit each item into one or other of the holders
if ($count++ % 2 == 0) {
$col-B-html-string .= $item-html-string;
} else{
$col-A-html-string .= $item-html-string;
}
}
?>
// finally drop the column string vars into the appropriate locations
<div class="col-A"><?php echo col-A-html-string ?></div>
<div class="col-B"><?php echo col-B-html-string ?></div>
#4
Posted 10 February 2013 - 11:24 PM
How to Get Good Help: How to Ask Questions | Don't be a help vampire
Debugging Your Code: Debugging your SQL | What does a php function do? | What does a term mean? | Don't see any errors?
Things You Should Do: Normalize Your Data | use print_r() or var_dump()
Lulz: "Functions should not have side effects." - trq
Please take a look at my new PHP/Web Dev blog: The Web Mason - Thanks!!
#5
Posted 11 February 2013 - 07:11 AM
#6
Posted 11 February 2013 - 09:40 AM
How to Get Good Help: How to Ask Questions | Don't be a help vampire
Debugging Your Code: Debugging your SQL | What does a php function do? | What does a term mean? | Don't see any errors?
Things You Should Do: Normalize Your Data | use print_r() or var_dump()
Lulz: "Functions should not have side effects." - trq
Please take a look at my new PHP/Web Dev blog: The Web Mason - Thanks!!
#7
Posted 11 February 2013 - 11:56 AM
Of course, it wouldn't be hard to get monospace code formatting going on the posts, right? On a site for code t'would be a nice "extra".
#8
Posted 11 February 2013 - 12:09 PM
OP, I'm marking this solved unless you come back and have a problem still.
How to Get Good Help: How to Ask Questions | Don't be a help vampire
Debugging Your Code: Debugging your SQL | What does a php function do? | What does a term mean? | Don't see any errors?
Things You Should Do: Normalize Your Data | use print_r() or var_dump()
Lulz: "Functions should not have side effects." - trq
Please take a look at my new PHP/Web Dev blog: The Web Mason - Thanks!!
#9
Posted 11 February 2013 - 12:58 PM
#10
Posted 11 February 2013 - 03:30 PM
But I got it.
Edited by Tychonaut, 11 February 2013 - 03:31 PM.
#11
Posted 11 February 2013 - 03:44 PM
How to Get Good Help: How to Ask Questions | Don't be a help vampire
Debugging Your Code: Debugging your SQL | What does a php function do? | What does a term mean? | Don't see any errors?
Things You Should Do: Normalize Your Data | use print_r() or var_dump()
Lulz: "Functions should not have side effects." - trq
Please take a look at my new PHP/Web Dev blog: The Web Mason - Thanks!!
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











