Jump to content

Recommended Posts

Why don't you use GET variables to tell the file what was clicked. Something like:

<a href="ukroaddriving.php?road=1">road 1</a>
<a href="ukroaddriving.php?road=2">road 2</a>
<a href="ukroaddriving.php?road=3">road 3</a>

 

Then on ukroaddriving.php have a check to read the GET var:

<?php
$road = $_GET['road'];
?>

Get isn't "Bad" it is just different from post. they both have unique properties to them that you should investigate before you make an assumption about them.  I use GET a lot on my sites and I use POST a lot less on my sites only because I don't have a need for it.  This site uses GET and you can clear see it isn't "bad"

well the idea is :

 

<a href="ukroaddriving.php?road=1">road 1</a>
<a href="ukroaddriving.php?road=2">road 2</a>
<a href="ukroaddriving.php?road=3">road 3</a>

if road 1 {
echo 'road 1'}
elseif road 2{ 
echo 'road 2'}
}else{
echo 'road 3'
}

 

 

 

thats the principal idea just by the page refreshing rather than going to a diffrent process page and then reloading the page to display it...

Yeah that would work, but use the GET vars, also a switch might be good:

<a href="ukroaddriving.php?road=1">road 1</a>
<a href="ukroaddriving.php?road=2">road 2</a>
<a href="ukroaddriving.php?road=3">road 3</a>

if(isset($_GET['road']){
    switch($_GET['road']){
        case '1':
            echo 'road1';
        break;
         case '2':
            echo 'road2';
        break;
        case '3':
            echo 'road3';
        break;
        default:
            echo 'invalid road selected';
        break;
   }
}

Yeah that would work, but use the GET vars, also a switch might be good:

<a href="ukroaddriving.php?road=1">road 1</a>
<a href="ukroaddriving.php?road=2">road 2</a>
<a href="ukroaddriving.php?road=3">road 3</a>

if(isset($_GET['road']){
    switch($_GET['road']){
        case '1':
            echo 'road1';
        break;
         case '2':
            echo 'road2';
        break;
        case '3':
            echo 'road3';
        break;
        default:
            echo 'invalid road selected';
        break;
   }
}

 

if i did the if statements on a different php file would it automatically carry the get accross when the link is pressed or is it to only the page in which the code is on ?

im lost now..

 

say one file is test.php

 

which has

<a href="process.php?road=1">road 1</a>

 

then process.php has:

 

if(isset($_GET['road']){
    switch($_GET['road']){
        case '1':
            echo 'road1';
        break;
         case '2':
            echo 'road2';
        break;
        case '3':
            echo 'road3';
        break;
        default:
            echo 'invalid road selected';
        break;
   }
}

 

would it work ?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.