PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
if(isset($kart))
{
$sql="SELECT * FROM parts WHERE gk_model='$kart'";
$query=mysql_query($sql);
$getKartLoc="SELECT * FROM kartloc";
$getKartQuery=mysql_query($getKartLoc);
while ($generalLoc=mysql_fetch_object($getKartQuery))
{
echo "<b>$generalLoc->kartlocname</b> <br />";
$getSpecLoc="SELECT * FROM kartspecloc WHERE kartloc='$generalLoc->kartloc'";
$getSpecQuery=mysql_query($getSpecLoc);
echo "<ul>";
while ($specLoc=mysql_fetch_object($getSpecQuery))
{
$getImages="SELECT * FROM parts WHERE kartspecloc='$specLoc->speckartloc'";
$getImagesQuery=mysql_query($getImages);
$count=mysql_num_rows($getImagesQuery);
if ($count!=0)
{
echo "<li> $specLoc->name </li>";
while ($images=mysql_fetch_object($getImagesQuery))
{
echo "<img src='/images/parts/".$images->part_number.".jpg'>";
}
}
}
echo "</ul>";
}
}
any recomendations no how to tidy it up? It just seems so darn bloated to me..course I could be being overly critical...
edit: and as an add on to this page..... do you think since I could be potentially be displaying a <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span> load of part pictures on this site, should I use AJAX? (the reason I ask is because I'm thinking of adding expand and minimize buttons so they can expand every category, default every category minimized so less screen space is taken up. )
Just from a first glance - you can make your SQL statements much more efficient by selecting only the fields you want to use rather than using * each time...
$getSpecLoc="SELECT * FROM kartspecloc WHERE kartloc='$generalLoc->kartloc'";
$getSpecQuery=mysql_query($getSpecLoc);
echo "<ul>";
while ($specLoc=mysql_fetch_object($getSpecQuery))
{
$getImages="SELECT * FROM parts WHERE kartspecloc='$specLoc->speckartloc'";
those two queries into a sql join instead , and only have to deal with tehone while() loop ..
hnm..i'll go look into JOIN..never used it before...thanks for the input people if any more ideas strike ya feel free to speak..afte review I think it's just the long variable names bugging me.