Jump to content

PHP Site Back Links


skwap

Recommended Posts

Friends,

 

I just making a games sharing site so i used php & mysql in my script. I want to put auto back link option in bottom of each page.

 

Suppose if a user visit to Games/New Games/Java Games the bottom back link will be like

Back To :

Games > New Games

 

I try to do myself but its not working fine...

below is the code that i made

 

<?php
$path = "files";  //path of stored files.

if(isset($_GET['id'])) { // getting the id of category
$id = $_GET['id'];
}
else {
$id = '0';
}
include ("header.php");
include ("func.php");

connect_db();
$query = mysql_fetch_array(mysql_query("SELECT * FROM `category` WHERE `id` = '$id'"));
$sk = $query['path'];
$dirname = $query['name'];
$sk = explode("/",$sk);
for($i=0;$i<count($sk)-1;$i++){
$level = mysql_fetch_array(mysql_query("SELECT * FROM `category` WHERE `name` = '$sk[$i]'"));
$link = '<a href="index.php">Home</a> &#187; <a href="showcat.php?id='.$level['id'].'"> '.$level['name'].'</a> '; // Here i want to set the back link
}
echo '<div class="norm">'.$dirname.'</div>
<div class="gap"></div>
<div class="left">';
$infolder = $query['name'];
$row1 = mysql_query("SELECT * FROM `category` WHERE `infolder` = '$infolder'");
if(mysql_num_rows($row1) == "0") {
echo 'No Games Found!';
}
while($row = mysql_fetch_array($row1)) {
echo '<img src="img/fold.gif" alt="*"/> <a href="showgame.php?id='.$row['id'].'">'.$row['name'].'</a><br/>
<div class="line"></div>';
}
echo '<div class="update left">
<font color=red size=2><b>'.$link.'</b></font>
</div>
</div>';

include ("footer.php");

?>

 

 

Below is the demo of my database table

 

TABLE NAME : category

 

id            path                                          infolder                              name                      index 

1          files/New Games                            files                              New Games              0

2          files/Java Games                            files                              Java Games              0

3          files/Top Games                              files                              Top Games                0

4          files/New Games/Bike                    New Games                      Bike                      1

5          files/Java Games/Moto GP              Java Games                      Moto GP                1

6          files/Top Games/X Rally                  Top Games                          X Rally                  1

 

 

 

Note : index = 0 is denote as the main directories & 1 = sub directories

 

 

I hope you got what i want to do & i request you to do changes in my code.

 

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/244119-php-site-back-links/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.