craig101
05-11-2011, 11:20 AM
I'm tearing my hair out here (well would be if i had any) i want Div's next to each other, its basically displaying items that has been returned from a search, so there could be a maximum of 4 div's next to each other, or just one alone, this is the PHP, inside a while loop
while ($lookup[$lc] != "") {
$qry = "SELECT * FROM Stock WHERE LOOKUP = '$lookup[$lc]'";
$result = mysql_query($qry);
$row = mysql_fetch_array($result);
$stocktype = $row['STOCKTYPE'];
$img = $row['IMAGE'];
if ($img == "") {
$img = "Images/nia.jpg";
} else {
$img = "Images/" . $img;
}
list($width, $height, $type, $attr) = getimagesize($img);
if ($width > $height) {
$no = $width / 100;
$h = $height / $no;
$w = 100;
} else {
$no = $height / 100;
$w = $width / $no;
$h = 100;
}
echo "<div class\"wrapper\">";
echo "<img src= $img width=$w height=$h/>";
echo "</div>";
$lc++;
}
and the CSS
.wrapper {
position: relative;
float: left;
padding:3px;
width: 150px;
}
while ($lookup[$lc] != "") {
$qry = "SELECT * FROM Stock WHERE LOOKUP = '$lookup[$lc]'";
$result = mysql_query($qry);
$row = mysql_fetch_array($result);
$stocktype = $row['STOCKTYPE'];
$img = $row['IMAGE'];
if ($img == "") {
$img = "Images/nia.jpg";
} else {
$img = "Images/" . $img;
}
list($width, $height, $type, $attr) = getimagesize($img);
if ($width > $height) {
$no = $width / 100;
$h = $height / $no;
$w = 100;
} else {
$no = $height / 100;
$w = $width / $no;
$h = 100;
}
echo "<div class\"wrapper\">";
echo "<img src= $img width=$w height=$h/>";
echo "</div>";
$lc++;
}
and the CSS
.wrapper {
position: relative;
float: left;
padding:3px;
width: 150px;
}