Avatar of MayoorPatel
MayoorPatel

asked on 

Taking the Product ID from the URL and Retriving a Record.

Hi there. Need a bit of help with some SQL.

Users Land on pages like this.

http://www.onlineshopsave.com/products.php?categoryId=1001&productId=1618

I need to grab the whatever the productid is and go to my database table and perform the following query

SELECT USERID
FROM `PRICECOMPARISON_USER_PRODUCT`
WHERE product_id ={product id from url}

All connections to the database are already in place via an include file, so all I need is help with the part of the code that will grab the product id from the url, execute the sql and return the userid to the product page.

Can anyone help?



<?= $info ?>
 
		<table width="95%" cellspacing="1" cellpadding="1" border="0">
			<tr>
				<td colspan="2">
					<a href="<?=SCRIPT_ROOT?>" class=link><?=HOME?></a> <?=getCategoryBreadCrumb($categoryId, " &raquo; <a href=\"{FILEPATH}\" class='link'>{TITLE}</a>")?> &raquo; <a href="<?=getProductPath($productId)?>" class=link><?=$prod["TITLE"]?></a>
				</td>
			</tr>
			<tr>
				<td colspan="2"><hr></td>
			</tr>
			<tr>
				<td valign="top">
					<table width="100%" cellspacing="5" cellpadding="5" border="0">
						<tr valign="top">
							<td width="22%" valign="top" class="td" align="center">
							<?
 
								if ( IS_MULTIPLE_IMAGES_INSTALLED == 1 )
								{
									echo displayProductImage($prod["ID"], $prod["CATEGORY_ID"]);
								}
								else
								{
									$productImagePath = getProductImagePath($prod["ID"], $prod["CATEGORY_ID"]);
									if ( file_exists(PATH.$productImagePath) )
									{
										echo getProductThumbnail($prod["ID"], "#\" onClick=\"window.open('".SCRIPT_ROOT."readfile.php?f=".urlencode($productImagePath)."','ProductImage','left=100,top=50,height=550,width=550,resizable=1,scrollbars=1,status=1')", $prod["TITLE"], '150', '150');										
										echo '<br>'.CLICK_TO_ENLARGE;
									}
									else
									{
										echo "<font size='1'><b>-&nbsp;No&nbsp;Image&nbsp;-</b></font>";
									}
								}
							?>
							</td>
							<td class="td">
								<font class="large"><b><?= $prod["TITLE"] ?></b></font><br>
 
								<b><?=MANUFACTURER?></b> <?= $prod["MANUFACTURER"] ?><br>
								<b><?=MANUFACTURER_CODE?></b> <?= $prod["MANUFACTURER_CODE"] ?><br><br>
 
								<b><?=RATING?></b> <?= getProductRating($prod["ID"]) ?><br>
								<?= getPartialString(strip_tags($prod["DETAIL"]), 450, SCRIPT_ROOT.'products_detail.'.EXTENSION.'?productId='.$productId) ?><br><br>
					
							</td>
						</tr>
					</table>
				</td>
				<td align="right" valign="top">
					<? if ( IS_PRICEHISTORYGRAPH_INSTALLED == 1 ) { ?>
						<img src="<?=SCRIPT_ROOT?>price_trend_graph_image.php?productId=<?=$productId?>&startDate=<?=date('Y-m-d', mktime(0,0,0,date('m')-1,date('d'),date('Y')))?>&endDate=<?=date('Y-m-d')?>&" alt="<?=PRICE_TREND_GRAPH?>" border='0' width='250'><br>
					<? } else { ?>
						<?= getBanner(1000, "S1", $categoryTitle) ?><br>
					<? } ?>
					
					<? if ( IS_WISHLIST_INSTALLED == 1 ) { ?>
					<a href="<?=SCRIPT_ROOT?>visitor_productlist_add.<?=EXTENSION?>?productId=<?=$prod["ID"]?>" class="link"><?=ADD_TO_WISHLIST?></a><br>
					<? } ?>
				</td>
			</tr>
			<tr>
				<td colspan="2">&nbsp;</td>
			</tr>
		</table>
<?
?>
		<table width="98%" cellspacing="0" cellpadding="0" border="0">
			<tr>
				<td nowrap>
					<div class="prodtabs">
						<a href="<?=getProductPath($productId, $prod["FILENAME"], $categoryId)?>" <?=$thisPageName=='products.php'?'id="live"':''?>><?=TAB_PRODUCT_MERCHANTS?></a>
						
						<a href="<?=SCRIPT_ROOT."products_detail.".EXTENSION."?categoryId=".$categoryId."&productId=".$productId?>" <?=$thisPageName=='products_detail.php'?'id="live"':''?>><?=TAB_PRODUCT_DETAILS?></a>
						
						<? if ( IS_PRODUCTFILTERS_INSTALLED == 1 ) { ?>
						<a href="<?=SCRIPT_ROOT."products_specs.".EXTENSION."?categoryId=".$categoryId."&productId=".$productId?>" <?=$thisPageName=='products_specs.php'?'id="live"':''?>><?=TAB_PRODUCT_SPECS?></a>
						<? } ?>
						
						<a href="<?=SCRIPT_ROOT?>product_rating.<?=EXTENSION?>?productId=<?=$prod["ID"]?>" <?=$thisPageName=='product_rating.php'?'id="live"':''?>><?=REVIEWS?></a>
						
						<a href="<?=SCRIPT_ROOT?>products_price_alert.<?=EXTENSION?>?productId=<?=$prod["ID"]?>" <?=$thisPageName=='products_price_alert.php'?'id="live"':''?>><?=ADD_PRICE_ALERT?></a>
						
						<a href="<?=SCRIPT_ROOT?>email_friend.<?=EXTENSION?>?productId=<?=$prod["ID"]?>&return=<?= urlencode(getProductPath($productId)) ?>" <?=$thisPageName=='email_friend.php'?'id="live"':''?>><?=REFER_TO_A_FRIEND?></a>
					</div>
				</td>
			</tr>
			<tr>
				<td class="prodtabsBg"></td>
			</tr>
		</table>

Open in new window

PHP

Avatar of undefined
Last Comment
Cem Türk

8/22/2022 - Mon