2012-11-08 114 views
-1

一切與此代碼一起工作,但我想有一個從product.php鏈接回到類別和子類別。PHP產品頁面使類別和子類別的鏈接

我有3個父類別,page1.php,page2.php和page3.php 也爲那些我有子類別page1.php?subcat = 1,2,3,4 page2.php?subcat = 1,2 ,3,4

這是使用PHP代碼IAM到product.php

if (isset($_GET['id'])) { 
$id= $_GET['id']; 
$result2 = mysql_query("SELECT * FROM products WHERE id='$id' LIMIT 1"); 
$count = mysql_num_rows($result2); 
if ($count > 0) { 
while($row = mysql_fetch_array($result2)){ 
$pid = $row["id"]; 
$pname = $row["name"]; 
$pprice = $row["price"]; 
$pnoncategoryid = $row["noncategoryid"]; 
$pdesc = $row["desc"]; 
} 

// gjeje emrin e categorise dhe nencategorise 
$result3=mysql_query("select * from noncategory WHERE ncid=$pnoncategoryid"); 
while($row=mysql_fetch_array($result3)){ 
$noncategoryname = $row["ncname"]; 
$categoryid = $row["categoryid"]; 
} 

$result4=mysql_query("select * from category WHERE cid=$categoryid"); 
while($row=mysql_fetch_array($result4)){ 
$categoryname = $row["cname"]; 
} 
//mbaro 

在類別和子類別我想有鏈接:

<h3><?php echo $pname; ?></h3> 
<div class="pbr"></div> 
<h4>Category:</h4> 
<p class="price"><?php echo $categoryname; ?>/<?php echo $noncategoryname; ?></p> 
<div class="pbr"></div> 
<h4>Description:</h4> 
<p class="desc"><?php echo $pdesc; ?></p> 
<div class="pbr"></div> 
<h4>Price:</h4> 
<p class="price"><?php echo $pprice; ?> <?php echo _valuta_ ?></p> 

對不起我的英文不好,希望some1明白我 :))

+0

什麼是$ _GET [ '身份證']做,應該不會是$ _GET [ 'SUBCAT'] –

+0

你得到通過ID的產品,它具有SUBCAT(noncat)作爲參數,並從noncat你父母(貓)對不對? – Neograph734

+0

@BrandenStilgarSueper $ _GET ['id']用於product.php?id = 1和$ _GET ['subcat']用於category.php?subcat = 1 – RednBlack

回答

0

您想要將文本轉換爲超鏈接。喜歡這個?

<?php echo "<a href='category".$categoryid.".php'>".$categoryname."</a>"; ?>/
<?php echo "<a href='category".$categoryid.".php?subcat=".$pnoncategoryid."'>".$noncategoryname."</a>"; ?> 
+0

與此類似,但php頁面名稱與$ categoryname不相同! – RednBlack

+0

我已更新它。如果$ categoryid = 3,則爲 – Neograph734

+0

; echo Category1.php – RednBlack

相關問題