Greetings!
I have a website www.lanceronlinejobs.com/our_franchises.php I have a franchise images. I want to display each franchise record from database whenever a user click on franchise link. Here is my code.
ourfranchises.php code:

<?php 
include('fconnection.php');

$sql = mysql_query("SELECT * FROM tbl_franchise ORDER BY id DESC") or die(mysql_error());
$row3 = mysql_fetch_array($sql); 
?>
<a href="franchiseDetails.php?city=<?php echo $row3['city'];?>"><img src="images/lbatkhela.jpg" width="150" height="150" alt="Batkhela" /></a>

----------------------------------------------------------------------

franchiseDetails.php code:

<?php
$id = $_GET['id'];
					
$query = "SELECT * FROM tbl_franchise WHERE id = '$id' ORDER BY id DESC LIMIT 1";

$result = mysql_query($query);

if (!$result) {
echo "NO RECORD FOUND";
} else {

while($row3 = mysql_fetch_array($result)):
?>

Manager Name: <?php echo $row3['manager_name'];?>

Please help me. Any help would be appreciated.

Thanks.

In this line

<a href="franchiseDetails.php?city=<?php echo $row3['city'];?>">

pass your record id instead of city as follows

<a href="franchiseDetails.php?id=<?php echo $row3['id'];?>">
Member Avatar

diafol

I want to display each franchise record from database whenever a user click on franchise link.

DO we assume you mean to display data from ONE record based on the city parameter in the url?

In this line

<a href="franchiseDetails.php?city=<?php echo $row3['city'];?>">

pass your record id instead of city as follows

<a href="franchiseDetails.php?id=<?php echo $row3['id'];?>">

Dear it display one single id for all image links. See the result on http://lanceronlinejobs.com/our_franchises.php

DO we assume you mean to display data from ONE record based on the city parameter in the url?

Yes dear. Please help me out.

Member Avatar

diafol

<?php 
include('fconnection.php');
 
$sql = mysql_query("SELECT * FROM tbl_franchise ORDER BY id DESC") or die(mysql_error());
$row3 = mysql_fetch_array($sql); 
?>
<a href="franchiseDetails.php?city=<?php echo $row3['city'];?>"><img src="images/lbatkhela.jpg" width="150" height="150" alt="Batkhela" /></a>

This will just print one city link (the first one) as you don't have a while loop. No text is shown with this link, just an image. Tooltip (alt) - try using 'title' attribute too.

Is this what you want? Seems wrong to query the whole tbl_franchise table and then just use the first record.

==============

<?php
$id = $_GET['id'];
 
$query = "SELECT * FROM tbl_franchise WHERE id = '$id' ORDER BY id DESC LIMIT 1";
 
$result = mysql_query($query);
 
if (!$result) {
echo "NO RECORD FOUND";
} else {
 
while($row3 = mysql_fetch_array($result)):
?>
 
Manager Name: <?php echo $row3['manager_name'];?>

I'm assuming this is coming from the previous script link. Again this makes little sense as you're ORDERING BY id, but limiting it to one id, which I assume is unique. Odd.

For this recordset, you one have one record, but then go on to loop over it with a 'while'. This makes no sense.

You seem to have mixed up the purpose of using a loop.

BTW: your get variable should be $_GET not $_GET

I recommend you have a look at the php.net site and learn the basics of loops (for, while, do)

Hi, well first thing your passing the variable city to the franchiseDetails.php file, and asking for the id variable...

So just change this and it should work.

<a href="franchiseDetails.php?id=<?php echo $row3['id'];?>"><img src="images/lbatkhela.jpg" width="150" height="150" alt="Batkhela" /></a>

Thanks,
Marais