所有内容都适用于此代码,但我希望从product.php返回到类别和子类别。
我有3个父类别,page1.php,page2.php和page3.php 还有那些我有子类别page1.php?subcat = 1,2,3,4 page2.php?subcat = 1,2,3,4
这是我用于product.php的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>
抱歉我的英文不好,希望有些人理解我:))
答案 0 :(得分:0)
您想要将文本转换为超链接。喜欢这个?
<?php echo "<a href='category".$categoryid.".php'>".$categoryname."</a>"; ?> /
<?php echo "<a href='category".$categoryid.".php?subcat=".$pnoncategoryid."'>".$noncategoryname."</a>"; ?>