Created
October 23, 2012 16:19
-
-
Save simonmorley/3939827 to your computer and use it in GitHub Desktop.
WS Slider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
/************************************************/ | |
/* CODE TO GENERATE THE SLIDE LI'S STARTS HERE */ | |
/************************************************/ | |
/* Base URL to the shop and db details - this will change when site goes live */ | |
$baseurl = "http://shop.xxx.com/"; | |
$dbhost = "x.x.x.221"; | |
$dbname = "xxxxx"; | |
$dbuser = "xxxxx"; | |
$dbpass = "xxxxx"; | |
/* Connect to the database */ | |
mysql_connect($dbhost,$dbuser,$dbpass); | |
mysql_select_db($dbname) or die( "Unable to select database"); | |
$q_stock = mysql_query("SELECT * FROM it_stock WHERE stk_select=1 LIMIT 30"); | |
if (mysql_num_rows($q_stock) >0) | |
{ | |
while ($stk = mysql_fetch_object($q_stock)) | |
{ | |
if(trim($stk->stk_range)=="") | |
{ | |
$imgref = addslashes(str_pad(trim($stk->stk_part),20) . "PI"); | |
$iid = mysql_query("SELECT * FROM it_image WHERE img_ref = '$imgref' ORDER BY img_data DESC"); | |
} | |
else | |
{ | |
$imgref = str_pad(trim($stk->stk_rngorg),10) . "RI"; | |
$imgcolor = $stk->stk_color; | |
$iid = mysql_query("SELECT * FROM it_image WHERE img_ref = '$imgref' AND img_color = '$imgcolor' ORDER BY img_data DESC"); | |
} | |
if (mysql_num_rows($iid) > 0) | |
{ | |
while ($imagerec = mysql_fetch_object($iid)) | |
{ | |
if (trim($imagerec->img_data)=="DEFAULT") | |
{ | |
$imgfile = str_pad($imagerec->img_id,10,"0",STR_PAD_LEFT) . "." . trim(strtolower($imagerec->img_ext)); | |
$prdlink = $baseurl ."item/". urlencode(trim($stk->stk_part)) . "/" . trim($stk->stk_slug); | |
/* Opening div for the slide */ | |
echo "<li>\n"; | |
echo "<div style=\"text-align: center;\">\n"; | |
/* Product image */ | |
echo "<a href=\"$prdlink\" ><img src=\"$baseurl/posit/images/products/carousel/$imgfile\" height=\"200\" /></a><br />\n"; | |
/* Designer */ | |
$qid_md = mysql_query("SELECT * from it_manf WHERE smn_ref = '" . addslashes($stk->stk_manf) . "'"); | |
$manf_q = mysql_fetch_object($qid_md); | |
if ($manf_q) echo "<span style=\"text-transform: uppercase; font-weight: bold; font-size: 9pt;\">" . trim($manf_q->smn_desc) . "</span><br />\n"; | |
/* Description */ | |
echo "<a href=\"$prdlink\" ><span style=\"font-size: 9pt;\">" . trim($stk->stk_desc) . "</span></a><br />\n"; | |
/* Price */ | |
echo "<span style=\"font-size: 9pt;\">£ " . number_format($stk->stk_retail/pow(10,$stk->stk_pdec),$stk->stk_pdec) . "</span><br />\n"; | |
/* Closing div for slide */ | |
echo "</div>\n"; | |
echo "</li>\n"; | |
break; | |
} | |
} | |
} | |
} | |
} | |
/**********************************************/ | |
/* CODE TO GENERATE THE SLIDE LI'S ENDS HERE */ | |
/**********************************************/ | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment