Forum Moderators: coopster

Message Too Old, No Replies

PHP variable parsing

I could do with some help

         

irishjonny2003

2:21 pm on Jul 19, 2004 (gmt 0)

10+ Year Member



Hi,

I've just started learning PHP, so bear with me. What I want to do is;

Get results from a database
Display results in table
Allow user to click on results for further details.

The best way I can explain what I want to do is by example, so here goes;

A website that searches a database for CD's it returns the results to a table. The user can then click on the title of a CD and see the track listing on another page.

I can already link to the database and get results from it, but I don't know how get the track listing, Think I've got to pass the variables by the url but I'm really not sure could someone please help.
The more basic the instructions the better as i'm real novice.

Cheers!

coopster

2:44 pm on Jul 19, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, irishjonny2003!

Sounds like you already understand the Basics of extracting data from MySQL using PHP [webmasterworld.com]. Next, all you have to do is loop through the result set and when you display the data you create your links by inserting your <a href> elements.

irishjonny2003

3:10 pm on Jul 19, 2004 (gmt 0)

10+ Year Member



sorry to be stupid i'm not entirely sure how to do that below is an example link I've tried to experiment with;

<a href=\"hwresults.php?variable=$variable\">link me</a>

the results page has the following code;

$variable = $_REQUEST['variable'];

but every time I click the link i get an error 200, to be honest don't know what this is.

The URL is;

[localhost...]

As you can see there is no value assigned to the variable, so is this causing the problem. If I try assign a value eg 1 i get an error 200 on the search page. Where am I going wrong? I really don't have much experience with PHP so I haven't got a clue what I'm doing. Cheers for any help!

Cheers!

figment88

3:19 pm on Jul 19, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<a href=\"hwresults.php?variable=$variable\">link me</a>

Typing the vairable's name does not do anything. You need to echo it:

One style:
<a href=\"hwresults.php?variable=<? echo $variable;?>\">link me</a>

irishjonny2003

3:41 pm on Jul 19, 2004 (gmt 0)

10+ Year Member



Hello

I've figured it out, you're right I was actuatly outputing anything. Is sorted cheers for all your help.