Now first I dont have a clue about PHP, but I have noticed that when i make a link check I get 2-4 broken links to related images pages which are ex. domain.com/widget/blue-widget/house and this house item dont fit there, means the sub categories are not correct to show house.
Now on site it do show the correct links, with correct sub categories in url to related images, when you view the site and look at source of code in browser, but as said when i make a link check with a tool, it shows those fake links also.
I did have one to fix this problem so it showed correct on site which it also do now, but maybe the "bad code is still on the coding"
here is the coding "i think"
<?php
$img1=$csv->usersSearch("wallpaper_tbl_category",array( 'category_id' => 3),'*','');
$img2=$csv->usersSearchOrder("wallpaper_tbl_sub_category",array( 'category_id' => $img1[0][category_id]),'*','4','rand()');
/*echo "<br />Category name - ".$img1[0][category_name]."<br />
subcategory name - ".$img2[0][sub_category_name]."<br />";*/
if(empty($img2[0][sub_category_id])):
$random_id=rand(32,34);
$img2_id=$random_id;;
else:
$img2_id=$img2[0][sub_category_id];
endif;
$img3=$csv->usersSearchOrder("wallpaper_tbl_sub_sub_category",array( 'sub_category_id' => $img2_id),'*','','rand()');
/*if(empty($img3[0][sub_sub_category_id])):
$random_id=rand(5,8)
$img3_id=$random_id;
else:
$img3_id=$img2[0][sub_sub_category_id];
endif;*/
/*echo "<br />subsubcategory_name - ".$img3[0][sub_sub_category_name];*/
$sub=$csv->usersSearchOrder("wallpaper_tbl_item",array('sub_sub_category_id' => $img3[0][sub_sub_category_id]),'*','4','rand()');
/*echo "<br />item name - ".$sub[0][item_name]."<br />";*/
?>
<div style="padding:8px 60px;" align="center">
<div>
<?php
/*if(count($sub)==4):*/
// var_dump($sub);
for($k=0;$k<count($sub);$k++)
{
$query = "
SELECT wi.item_name, wc.category_name, wsc.sub_category_name, wssc.sub_sub_category_name
FROM `wallpaper_tbl_item` wi
INNER JOIN wallpaper_tbl_category wc ON wi.category_id = wc.category_id
INNER JOIN wallpaper_tbl_sub_category wsc ON wi.sub_category_id = wsc.sub_category_id
INNER JOIN wallpaper_tbl_sub_sub_category wssc ON wi.sub_sub_category_id = wssc.sub_sub_category_id
WHERE
wi.item_id = '" . addslashes(stripslashes($sub[$k]['item_id'])) . "'
AND wi.category_id = '" . addslashes(stripslashes($sub[$k]['category_id'])) . "'
AND wi.sub_category_id = '" . addslashes(stripslashes($sub[$k]['sub_category_id'])) . "'
AND wi.sub_sub_category_id = '" . addslashes(stripslashes($sub[$k]['sub_sub_category_id'])) . "'
";
$result = mysql_query($query) or die(mysql_error());
$imgInfo = mysql_fetch_assoc($result);
$imgHref = 'http://www.mydomain.com/' . str_replace(' ','_', $imgInfo['category_name']) . '/' . $imgInfo['sub_category_name'] . '/' . $imgInfo['sub_sub_category_name'] . '/' . str_replace(' ','_', $imgInfo['item_name']);
/*$img3=$csv->usersSearchOrder("wallpaper_tbl_sub_sub_category",array( 'sub_category_id' => $img2[0][sub_category_id]),'*','','rand()');
echo "<br />subsubcategory_name - ".$img3[$k][sub_sub_category_name];
$sub=$csv->usersSearchOrder("wallpaper_tbl_item",array('sub_sub_category_id' => $img3[$k][sub_sub_category_id]),'*','4','');
echo "<br />item name - ".$sub[$k][item_name]."<br />";*/
/*$img1=$csv->usersSearch("wallpaper_tbl_sub_sub_category",array( 'category_id' => $sub[$k][category_id]),'*','4','rand()');*/
?>
<div style="width:200px;" class="flt_lft sublist">
<a href="<?php echo $imgHref; ?>">
<?php
if($sub[$k][image]!='')
{ $imgsc=$sub[$k][image];
}else{
$imgsc="no_cat.jpg";
}
?>
<?php /*?><img src="../../image.php?width=200&height=150&image=<?php echo $img_root; ?>/item_img/800_600/<?php echo $imgsc; ?>" title="<?php echo $sub[$k][item_name] ?>" class="photo_bg" alt="" border="0" /><?php */?>
<img src="/wall/<?php echo $img1[0][category_name].'/'.$img2[0][sub_category_name].'/'.$img3[0][sub_sub_category_name].'/thumb/'.$imgsc;?>" title="<?php echo $sub[$k][item_name] ?>" class="photo_bg" alt="" border="0" />
</a>
<br />
<a href="<?php echo $_REQUEST['cname'];?>/<?php echo str_replace(' ','_',$sub[$k][item_name]); ?>"><?php echo $sub[$k][item_name]; ?></a>
</div>
<div style="width:25px;" class="flt_lft"><img src="../../images/spacer.gif" alt="" width="15" /></div>
<?php
if(($k+1)%4==0)
{
echo '<div class="clr"><img src="../../images/spacer.gif" alt="" /></div>';
echo '</div><div><img src="../../images/spacer.gif" alt="" height="15"/></div><div>';
}
?>
<?php }
/*else:
echo "fail";
endif;*/
?>