Passing variables between pages

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
ECJughead
Forum Newbie
Posts: 13
Joined: Fri Mar 07, 2008 9:14 am

Passing variables between pages

Post by ECJughead »

Code: Select all

<?php
    $type_set = @mysql_query('SELECT id, type FROM types');
        if (!$type_set) {
    exit('<p>Error performing query: ' . mysql_error() . '</p>');
        }
    while ($row = mysql_fetch_array($type_set)) {
    echo "<option value=\"{$row['id']}\">{$row['type']}</option>";
    }
?>
Using the above code, I need to be able to pass the chosen option ('type') through a url (something.php?type=xxx) where xxx='type'

My page was working before when I only used HTML and listed each option separately with <a href> tags and writing each 'type' out at the end of the url. This variable is used in a query in the next url page. I thought creating a drop-down list with a submit button would take up less room and look nicer. Can it be done?
User avatar
deejay
Forum Contributor
Posts: 201
Joined: Wed Jan 22, 2003 3:33 am
Location: Cornwall

Re: Passing variables between pages

Post by deejay »

ECJughead
Forum Newbie
Posts: 13
Joined: Fri Mar 07, 2008 9:14 am

Re: Passing variables between pages

Post by ECJughead »

So instead of "method="post", use "get"?

I've tried a few things and I still can not get it to pass a variable along to a new page
Post Reply