Jump to content


Photo

links with template


  • Please log in to reply
6 replies to this topic

#1 jaronblake

jaronblake
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 06 June 2006 - 08:23 PM

I have something like this
while($row = mysql_fetch_array( $result ))
{
echo '<a href="'.$row['model'].'"><br>';
}

How do i link to a template page that when they click on the model that they want, it will go to a template page and put the rest of the values from that "model" row.

#2 Randy

Randy
  • Members
  • PipPip
  • Member
  • 25 posts
  • LocationNewcastle, UK

Posted 06 June 2006 - 08:41 PM

while($row = mysql_fetch_array( $result )){
    echo '<a href="model.php?m='.$row['model'].'"><br>';
}
model.php
<?php
    $model = $_GET['m'];
    $result = mysql_query("SELECT * FROM `table` WHERE (`model`='$model')");
    echo("Model: $model");
    echo("<br>Price: " . mysql_result($result, 0, "price"));
?>
Very simple example...

#3 jaronblake

jaronblake
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 06 June 2006 - 08:43 PM

[!--quoteo(post=380767:date=Jun 6 2006, 02:41 PM:name=Randy)--][div class=\'quotetop\']QUOTE(Randy @ Jun 6 2006, 02:41 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
while($row = mysql_fetch_array( $result )){
    echo '<a href="model.php?m='.$row['model'].'"><br>';
}
model.php
<?php
    $model = $_GET['m'];
    $result = mysql_query("SELECT * FROM `table` WHERE (`model`='$model')");
    echo("Model: $model");
    echo("<br>Price: " . mysql_result($result, 0, "price"));
?>
Very simple example...
[/quote]

hey thanks. Do you know where I can find some tutorials on that area?

#4 jaronblake

jaronblake
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 06 June 2006 - 11:29 PM

that worked but now i have the problem of doing it within a template. My index.php looks like this
<?php

include("template/header.tpl.html");


include("template/menu.tpl.html");

if (empty($_GET['page'])) {
$page = 'home.php';
} else {
$page = $_GET['page'];
}

if (false == is_file($page)) {
$page = 'file_not_found.php';
}

include($page);

include("template/footer.tpl.html");
?>

this works for all my links if i put in <a href="index.php?page=test.php">

but when i try to access my model i have
<a href="index.php?page=model.php?m='.$row['model'].'">
and it comes up as page not found with this in the address bar
index.php?page=model.php?m=T4R23
if i remove the m=T4R23 it goes into the page but with errors. So i know that the link is good. Any help would be great on how to make this work

#5 jaronblake

jaronblake
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 07 June 2006 - 05:43 PM

Does anyone know how to make this work?

#6 Buyocat

Buyocat
  • Members
  • PipPipPip
  • Advanced Member
  • 267 posts

Posted 07 June 2006 - 09:31 PM

I think the problem is that you're second nonworking url has too many "?"'s; it should be something like this;

<a href="whatever.com/?key1=valu1&key2=val2&key3=val3">etc</a>

You separate the each pair with an "&" not "?", I hope that helps (and don't cross post :P )
Looking for some easy-to-use tools?  Try these, https://sourceforge....jects/utils-php -- I made them myself.  They're distinct tools which are easy to understand and use.  See some examples uses at http://www.anotherearlymorning.com

#7 jaronblake

jaronblake
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 07 June 2006 - 09:35 PM

that worked. and i wont cross post. Im new at this :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users