define the page and echoing out row from table

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Rob_Scott
Forum Newbie
Posts: 19
Joined: Mon Nov 14, 2011 6:08 am

define the page and echoing out row from table

Post by Rob_Scott »

Hi,

I have a range of products in a table in my database and each of these has their own page,

What i want to be able to do is have one piece of code that recognises what page i am on and then echos out the row in table which relates to the page.

Sorry its probably a simple solution but i am a newbie :)

Rob
maxx99
Forum Contributor
Posts: 142
Joined: Mon Nov 21, 2011 3:40 am

Re: define the page and echoing out row from table

Post by maxx99 »

Thats a bit other way around. If you're already on that page you don't need to check where you are :)
If you want to use same script to generate more pages you can use a parameter passed by url:
http://php.net/manual/en/reserved.variables.get.php
Rob_Scott
Forum Newbie
Posts: 19
Joined: Mon Nov 14, 2011 6:08 am

Re: define the page and echoing out row from table

Post by Rob_Scott »

Its ok I have just figured it out :)

thanks for the help.

I used this code:

<?php

if (arg(0) == 'node' && is_numeric(arg(1))) $nodeid = arg(1);

//echo $nodeid;

include_once("connect_to_mysql.php");

$sqlcommand = "SELECT * FROM cars where link = $nodeid";

$query = mysql_query($sqlcommand) or die(mysql_error());
while ($bert = mysql_fetch_array($query))
{
echo $bert['car_name'] . " <br/> ";
}

?>
Post Reply