With the code below I have the plant information printing out first and then all of the availability printing out last. Is there any way I can get both printing together, but not have duplicate pictures and information for the numerous sizes that sometimes list per plant. Ex. Buxus Green Velvet may have quantities for 3 gallon, 5 gallon, 24-30 inch, etc. I do not need the plant info and pictures printing out for each of these sizes. I just want the size and availability listed together under the ONE picture and info. Thanks for any assistance you can provide me.
<?php
$aLight = array(
'Part Sun Shade' => 'Part Sun Shade',
'Full Sun' => 'Full Sun',
'Full Shade' => 'Full Shade',
);
$aColours = array(
'bronze fall color' => 'bronze fall color',
'burgundy fall color' => 'burgundy fall color',
'orange fall color' => 'orange fall color',
'purple fall color' => 'purple fall color',
'red fall color' => 'red fall color',
'yellow fall color' => 'yellow fall color',
'blue flower' => 'blue flower',
'burgundy flower' => 'burgundy flower',
'lavender flower' => 'lavender flower',
'lilac flower' => 'lilac flower',
'magenta flower' => 'magenta flower',
'mixed flower' => 'mixed flower',
'orange flower' => 'orange flower',
'pink flower' => 'pink flower',
'purple flower' => 'purple flower',
'red flower' => 'red flower',
'rose flower' => 'rose flower',
'white flower' => 'white flower',
'yellow flower' => 'yellow flower',
'blue green foliage' => 'blue green foliage',
'green foliage' => 'green foliage',
'purple foliage' => 'purple foliage',
'red foliage' => 'red foliage',
'variegated foliage' => 'variegated foliage',
'yellow foliage' => 'yellow foliage',
'green fruit' => 'green fruit',
'orange fruit' => 'orange fruit',
'purple fruit' => 'purple fruit',
'red fruit' => 'red fruit'
);
$aType = array(
'DECIDUOUS VINE' => 'DECIDUOUS VINE',
'EVERGREEN SHRUB' => 'EVERGREEN SHRUB',
'DECIDUOUS SHRUB' => 'DECIDUOUS SHRUB',
'EVERGREEN TREE' => 'EVERGREEN TREE',
'DECIDUOUS TREE' => 'DECIDUOUS TREE',
'BROADLEAF EVERGREEN SHRUBS' => 'BROADLEAF EVERGREEN SHRUBS'
);
asort($aLight);
asort($aType);
?>
<form name="plantsearch" id="myform" method="post">
<fieldset>
<legend>LIGHT REQUIREMENTS</legend>
<?php
// You could write a function to handle this since it'll be reused for colour. I won't bother
foreach ($aLight AS $key => $light)
{
$checked = '';
if (isset($_POST['light']) && in_array($light, $_POST['light']))
{
$checked = ' checked="checked"';
}
printf(' <input type="checkbox" id="light_%s" name="light[]" value="%s"%s />' . PHP_EOL, str_replace(' ', '_', $key), $key, $checked);
printf(' <label for="light_%s">%s l </label>' . PHP_EOL, str_replace(' ', '_', $key), $light);
}
?>
</fieldset>
<p>
<fieldset>
<p align="center"> </p> <legend>COLOR ATTRIBUTES - each plant is listed by only one attribute</legend>
<?php
foreach ($aColours AS $key => $colour)
{
$checked = '';
if (isset($_POST['colour']) && in_array($colour, $_POST['colour']))
{
$checked = ' checked="checked"';
}
printf(' <input type="checkbox" id="colour_%s" name="colour[]" value="%s"%s />' . PHP_EOL, str_replace(' ', '_', $key), $key, $checked);
printf(' <label for="colour_%s">%s l </label>' . PHP_EOL, str_replace(' ', '_', $key), $colour);
}
?>
</fieldset>
<p>
<fieldset>
<p align="center"> </p><legend>PLANT TYPE</legend>
<?php
foreach ($aType AS $key => $type)
{
$checked = '';
if (isset($_POST['type']) && in_array($type, $_POST['type']))
{
$checked = ' checked="checked"';
}
printf(' <input type="checkbox" id="type_%s" name="type[]" value="%s"%s />' . PHP_EOL, str_replace(' ', '_', $key), $key, $checked);
printf(' <label for="type_%s">%s l </label>' . PHP_EOL, str_replace(' ', '_', $key), $type);
}
?>
</fieldset>
<p>
<p>
<p align="center"> </p><input type="submit" name="submit" value="SEARCH PLANTS" />
</p>
</form>
(must choose at least one Light, Fall Color and Type)
<p align="center"> </p>
<div align="center"><hr width="300" size="1" noshade="noshade" /></div>
<div align="center"><b>SUMMARY OF RESULTS</b>
</div>
<p align="center"> </p>
<div align="center">
<?php
// Lets filter out the junk
function notEmpty($x)
{
return !empty($x);
}
// Make your connections here
mysql_connect("", "", "") or die(mysql_error());
mysql_select_db("") or die(mysql_error());
foreach($_POST['light'] As $sLight) {
printf("%s<br>", $sLight);
}
foreach($_POST['colour'] As $sColours) {
printf("%s<br>", $sColours);
}
foreach($_POST['type'] As $sType) {
printf("%s<br>", $sType);
}
if (isset($_POST['submit']))
{
$aWhere = array(
&$sLight,
&$sColours,
&$sType
);
$sWhere = '';
if (isset($_POST['light']))
{
$sLight = 'findplantsdb.Light IN (\'' . implode("', '", $_POST['light']) . '\')';
}
if (isset($_POST['colour']))
{
$sColours = 'findplantsdb.Color IN (\'' . implode("', '", $_POST['colour']) . '\')';
}
if (isset($_POST['type']))
{
$sType = 'findplantsdb.Type IN (\'' . implode("', '", $_POST['type']) . '\')';
}
$aWhereFilter = array_filter($aWhere, 'notEmpty');
if (count($aWhereFilter) > 0)
{
$sWhere = ' WHERE ' . implode(' AND ', $aWhere);
}
$sQry = 'SELECT findplantsdb.Name, findplantsdb.Patent, findplantsdb.Common, findplantsdb.Hname, findplantsdb.SName, findplantsdb.Color, findplantsdb.Light, findplantsdb.Zone, findplantsdb.Picname, findplantsdb.Notes, plantsdb.type, plantsdb.size, plantsdb.yard, plantsdb.field, plantsdb.total FROM findplantsdb LEFT JOIN plantsdb ON (plantsdb.name = findplantsdb.Name)' . $sWhere;
$qry = mysql_query($sQry) or die('check to see if you have selected at least one from each category');
if (mysql_num_rows($qry) > 0)
{
while ($row = mysql_fetch_assoc($qry))
{
echo "<h4> ", $row['Name'], " ", $row['Patent'], "</h4> ",$row['Common'], "<p> Height: ", $row['Hname'], "<br> Spread: ", $row['Sname'], "<br> Color: ", $row['Color'], "<br> Light: ", $row['Light'], "<br> Zone: ", $row['Zone'], "<p> <img src=http://www.domain.com/mobile/",$row['Picname'], " /> <p><p>", $row['Notes'], "<p><p> <hr width='50%' size='1' color='#A3A3A3'><p>";
}
mysql_data_seek($qry, 0);
while ($row = mysql_fetch_assoc($qry)) {
Print "<table border=0 cellspacing=2 cellpadding=0 align='center'>";
Print "<font size=2 face='Arial'>";
while($row = mysql_fetch_array( $qry )) { Print "<tr>";
Print "<td>".$row['Name'] . "</td>";
Print "<td>-Size: ".$row['size'] . "</td>";
Print "<td>-Type: ".$row['type'] . "</td>";
Print "<td>-Yd: ".$row['yard'] . "</td>";
Print "<td>-Fld: ".$row['field'] . "</td></tr>"; } Print "</table>";
}
}
else
{
print '<p><div>No matching records</div></p>';
}
}
?>