Forum Moderators: coopster

Message Too Old, No Replies

Quasi-CMS creation

how do I pass info to other pages?

         

mattyb515

5:39 pm on Apr 6, 2006 (gmt 0)

10+ Year Member



I'm creating a website using mySQL and php. I've done some extensive searching on this site and on the net but can't seem to find what I want. I've got a couple of tables in the db and this is what I'm looking to do. The way it's working now is that someone could click on a link and a new page comes up listing all of the gas fireplaces (for the sake of argument). Below is the code I've done to pull the necessary info. from the db. The formatting isn't complete but it works.


//Query table to get data
$resultID = mysql_query("SELECT model_name, picture_location, short_description FROM fireplaces", $linkID);

//start formatting the table
echo "<table width='0' border='0' cellpadding='0'>";
echo "<tr>";

//print the data inside table
while($row = mysql_fetch_row($resultID))
{
echo "<td width='100'><img src='th.php?name=$row[1]&height=100&width=100'></td>";
echo "<td width='245'>" . $row[0] . "<br><br>" . $row[2] . "</td>";
}
echo "</tr>";
echo "</table>";

Now I want people to click on a pic. and have a new page open up with all of the information about the stove. A description, price, heating capacity, blah blah blah. I have no idea how to do this. The th.php in the <img src tag was an image resizing script that my friend wrote and works perfectly. I'm extrememly new to php/mysql so any help is greatly appreciated. Especially, with the explanation. Thanks in advance.

mattyb515

6:31 pm on Apr 6, 2006 (gmt 0)

10+ Year Member



I was thinking that if I could pass the unique over through the link I could then query the db and pull the appropriate info.

coopster

7:14 pm on Apr 6, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, mattyb515.

You need to wrap the pic in an <a> element with an "href" attribute that points to the new page with all of the information about the stove. The href attribute could be another php page with a query string appended to it that specifies the key information necessary to retrieve that particular stove's details from the database table(s).

mattyb515

12:48 pm on Apr 7, 2006 (gmt 0)

10+ Year Member



I hate to ask this but how exactly do I go about doing that. I'm not too familiar with creating the links in php. I'm still learning and I always get a ton of syntax errors. Here's the line that would need the link:

echo "<td width='100'><img src='th.php?name=$row[1]&height=100&width=100'></td>";

Thank you again for the help.

mattyb515

3:04 pm on Apr 7, 2006 (gmt 0)

10+ Year Member



Well after fumbling my way through I've come up with this link:

echo "<td width='100'><a href=stovedesc.php?=$row[0]><img src='th.php?name=$row[2]&height=100&width=100'></a></td>";

The problem I'm having is actually using the info. that is being passed to stovedesc.php. Nothing comes up. I know that's it's something I'm doing with the $_GET statement but I'm not sure what.

Here's the query I'm running (probably incorrect)

$resultID = mysql_query("SELECT fireplaceid, model_name, picture_location, long_description, price FROM fireplaces WHERE fireplaceid={$_GET['row']}", $linkID);

I am connecting to the db but can't get anything to print. I'm really sorry for my ignorance but the advice and help is greatly appreciated.

coopster

10:42 pm on Apr 7, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Sure. First, nice work. You almost got it, just missed one small thing -- the name/value pair in $_GET query strings.

Rather than just show you right off where the issue lies, have a read through this post and look closely at the discussion and samples I offered.

[webmasterworld.com...]

See if you can get it figured out. If not, just post again and let us know and we'll be happy to get you over the hump.