var slideShowSpeed = 5000;
var Pic = new Array();
var Ref = new Array();
var Ref_name = new Array();
var Price = new Array();
<?php
if(isset($_GET['cat']))
{
$cat1=$_GET['cat'];
$cat1 = stripslashes($cat1);
$cat1 = htmlspecialchars($cat1);
$cat1 = trim($cat1);
}
if(isset($_GET['price1']))
{
$price1=$_GET['price1'];
$price1 = stripslashes($price1);
$price1 = htmlspecialchars($price1);
$price1 = trim($price1);
$price2=$price1-1000;
$price3=$price1+1000;
}
$db = mysql_connect ("localhost","mebel-baby-ua","erhdthcbz");
mysql_select_db ("mebel-baby-ua",$db);
/* Выбираем из таблицы все категории где родитель переменная $a */
//$result = mysql_query("SELECT productID, name, Price, url, default_picture FROM MB_category_products INNER JOIN MB_products using(productID) WHERE categoryID='$cat1' ORDER BY RAND() LIMIT 30",$db) or die('Произошла ошибка!');
$result = mysql_query("SELECT pro.productID, name, Price, url, default_picture FROM MB_product_related re INNER JOIN MB_products pro ON re.relatedID = pro.productID INNER JOIN MB_category_products cat ON re.relatedID = cat.productID WHERE re.productID='$cat1' ORDER BY RAND()",$db) or die('Произошла ошибка!');
$myrow = mysql_fetch_array($result);
if (!empty($myrow))
{
/* выводим ы цикле категории */
$n=0;
do
{
$name1=$myrow['name'];
if ((strlen($name1))>20)
{
$name1=(substr($name1, 0, 18));
$name1.='...';
}
$name1 = str_replace('"', '',$name1);
$name1 = str_replace("'","",$name1);
echo "Ref[".$n."] = 'http://www.mebel-baby.com.ua/".$myrow['url'].".html'; ";
echo "Ref_name[".$n."] = '".$name1."'; ";
echo "Price[".$n."] = '".$myrow['Price']."'; ";
$product[$n]=$myrow['default_picture'];
$n=$n+1;
}
while ($myrow = mysql_fetch_array($result));
$k=0;
do
{
$image=$product[$k];
$result = mysql_query("SELECT filename FROM MB_product_pictures WHERE photoID='$image'",$db);
if (!$result)
{
echo "<p>Запрос на выборку данных не прошел! Напишите об этом администратору admin@mebel-baby.com.ua. <strong>Код ошибки:<strong></p>";
exit(mysql_error());
}
if (mysql_num_rows($result) > 0)
{
$myrow = mysql_fetch_array($result);
echo "Pic[".$k."] = 'http://www.mebel-baby.com.ua/products_pictures/".$myrow['filename']."'; ";
$k=$k+1;
}
else
{
$myrow = mysql_fetch_array($result);
echo "Pic[".$k."] = 'http://www.mebel-baby.com.ua/products_pictures/mebel_baby_no_img.jpg'; ";
$k=$k+1;
}
}
while ($k < $n );
}
?>
var t;
var t1;
var b;
var k;
var j = -1;
var p = Pic.length;
var interval = 1000;
function hideSlideShow() {
$('#SlideShow img[width=140]').fadeOut(interval);
$('#title a').fadeOut(interval);
$('#all_price span').fadeOut(interval);
t1=setTimeout(runSlideShow, interval+100);
}
function runSlideShow() {
if (j > (p - 2)) j = -1;
j = j+1;
$('#SlideShow1').attr( { src: Pic[j]});
$('#aaa_link').attr('href', Ref[j]);
$('#aaa').attr('href', Ref[j]);
$('#aaa').text(Ref_name[j]);
$('#price1').text(Price[j]);
if (j > (p - 2)) j = -1;
j = j+1;
$('#SlideShow2').attr( { src: Pic[j]});
$('#bbb_link').attr('href', Ref[j]);
$('#bbb').attr('href', Ref[j]);
$('#bbb').text(Ref_name[j]);
$('#price2').text(Price[j]);
if (j > (p - 2)) j = -1;
j = j+1;
$('#SlideShow3').attr( { src: Pic[j]});
$('#ccc_link').attr('href', Ref[j]);
$('#ccc').attr('href', Ref[j]);
$('#ccc').text(Ref_name[j]);
$('#price3').text(Price[j]);
$('#title a').fadeIn(interval);
$('#SlideShow img[width=140]').fadeIn(interval);
$('#all_price span').fadeIn(interval);
t = setTimeout(hideSlideShow, slideShowSpeed);
interval = 1000;
}
function next()
{
interval = 500;
clearTimeout(t)
clearTimeout(t1)
runSlideShow();
}
function previus()
{
interval = 500;
clearTimeout(t)
clearTimeout(t1)
b=j-6;
if (b<-1)
{
k=p+b;
if (k<-1)
{
j=p+k;
runSlideShow();
}
else
{
j=k;
runSlideShow();
}
}
else
{
j=b;
runSlideShow();
}
}
document.writeln('<div style="background-color:#ea557b;width:100%; height:18px; padding-top:3px; color:#FFF; text-align:center"><b>ДРУГИЕ ПРЕДЛОЖЕНИЯ</b></div><br><br><div id="title" style="width:100%; text-align:center; height:30px; margin-bottom:10px;"><table width="100%" border="0" cellpadding="0" cellspacing="0" ><tr><td width="59"> </td><td align="center" width="160"><a id="aaa" href="#"></a></td><td align="center" width="161"><a id="bbb" href="#"></a></td><td align="center" width="161"><a id="ccc" href="#"></a></td><td width="59"> </td></tr></table></div><div id="SlideShow" style="width:100%; height:105px; margin-bottom:10px;"><div style="float:left; margin-left:19px; position:relative; top:33px;"><img style="cursor:pointer" id="nazad" src="http://www.mebel-baby.com.ua/images_alex/nazad1_1.jpg" width="37" height="37" /></div><div style="float:left; margin-left:10px;"><a id="aaa_link" href="111"><img border="0" id="SlideShow1" src="http://www.mebel-baby.com.ua/products_pictures/mebel_baby_no_img.jpg" width="140" height="105"></a></div><div style="float:left; margin-left:17px;"><a id="bbb_link" href="#"><img border="0" id="SlideShow2" src="http://www.mebel-baby.com.ua/products_pictures/mebel_baby_no_img.jpg" width="140" height="105"></a></div><div style="float:left; margin-left:17px; margin-right:7px;"><a id="ccc_link" href="#"><img border="0" id="SlideShow3" src="http://www.mebel-baby.com.ua/products_pictures/mebel_baby_no_img.jpg" width="140" height="105"></a></div><div style=" position:relative; float:right; margin-right:19px; top:33px;"><img style="cursor:pointer" id="vpered" src="http://www.mebel-baby.com.ua/images_alex/vpered1_1.jpg" width="37" height="37" /></div></div><div id="all_price" style="width:100%; margin-bottom:10px; text-align:center; height:30px; "><!-- Закоментил, так как некоректно выводится валюта <table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="59"> </td><td width="160" align="center"><span style="color:#F00"><b id="price1"></b> <b>грн.</b></span></td><td width="161" align="center"><span style="color:#F00"><b id="price2"></b> <b>грн.</b></span></td><td width="161" align="center"><span style="color:#F00"><b id="price3"></b> <b>грн.</b></span></td><td width="59"> </td></tr></table>--></div>');
runSlideShow()
$('#vpered').click(function () {
next()
});
$('#nazad').click(function () {
previus()
});
$("#vpered").mousemove(function(){
$(this).attr( { src: "http://www.mebel-baby.com.ua/images_alex/vpered2_2.jpg"});
});
$("#vpered").mouseout(function(){
$(this).attr( { src: "http://www.mebel-baby.com.ua/images_alex/vpered1_1.jpg"});
});
$("#nazad").mousemove(function(){
$(this).attr( { src: "http://www.mebel-baby.com.ua/images_alex/nazad2_2.jpg"});
});
$("#nazad").mouseout(function(){
$(this).attr( { src: "http://www.mebel-baby.com.ua/images_alex/nazad1_1.jpg"});
});