Forum Moderators: coopster

Message Too Old, No Replies

Display retrieved data in different locations

         

pixeldiver

5:58 am on Jun 29, 2009 (gmt 0)

10+ Year Member



Hi guys,
I am trying to display images retrieved from a query into a table or div's with a title in horizontally format and when there is no more images, start a new row with a different title and so on.

I tried to display a title but it kept repeating.

Any ideas?

Here's the code:

//The query:

$a = '';
$i = '';

if (isset ($_POST['application'])) {
$a = mysql_real_escape_string($_POST['application']);
}
if (isset($_POST['installation'])) {
$i = mysql_real_escape_string($_POST['installation']);
}

mysql_select_db($database_qmi, $qmi);
$query = "SELECT type, img_link_beam, img_link_tubular, img_link_symmetric, img_link_asymmetric, img_link_modular FROM searchmatrix WHERE application_type LIKE'%{$a}%' AND installation_type LIKE'%{$i}%'";
$result = mysql_query($query, $qmi) or die(mysql_error());
$row = mysql_fetch_array($result);
$totalRows = mysql_num_rows($result);
?>

//The results:

<div id="resultsContent">
//-->should start with a title BEAM and display images horizontal
<?php while ($row = mysql_fetch_array($result)) { ?>
<div id="beam"><?php echo $row['img_link_beam']; ?></div>

//-->should start with a title TUBULAR and display images horizontal
<div id="tubular"><?php echo $row['img_link_tutbular']; ?></div>

//-->should start with a title SYMMETRIC and display images horizontal
<div id="symmetric"><?php echo $row['img_link_symmetric']; ?></div>

//-->should start with a title ASYMMETRIC and display images horizontal
<div id="asymmetric"><?php echo $row['img_link_asymmetric']; ?></div>

//-->should start with a title MODULAR and display images horizontal
<div id="modular"><?php echo $row['img_link_modular'];} ?></div>
</div>

Would apreciate any help

omoutop

7:32 am on Jun 29, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



a short sketch (if i get your problem correclty):

$query = .....
$totalRows = ....
if ($totalRows>0)
{
echo title
while ($row = ....)
{
echo images
}
}

pixeldiver

9:40 am on Jun 29, 2009 (gmt 0)

10+ Year Member



Thanks for your effort omoutop,
how can I get those images to display horizontally? I'm able to retrieve them, but they all appear vertically. What exactly do I need to do to get them horizontally.

omoutop

10:15 am on Jun 29, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



for this you need to optimize your css skills

although this is the php area, here is one short demo for what you need

in head:
<style type="text/css">
#gallery { border: solid 0px #115; margin: 1em; padding: 0.5em; }
#gallery ul { display: block; margin: 0px; padding: 0px;}
#gallery li { display: block; height:170px; list-style: none; float: left; margin: 0.25em; padding: 0px; border: solid 1px #111155; background: #F9F9FA; }
#gallery li p { text-align: center; margin: 0px; padding: 0.5em;}
#gallery hr { clear: both; visibility: hidden; margin: 0px; padding: 0px; height: 1px; }
</style>

and where you want the images:
<div id="gallery">
<ul>
<li>image here</li>
<li>image here</li>
<li>image here</li>
</ul>
<hr>
</div>