help with php

  • nightimedweller
  • Newbie
  • Newbie
  • nightimedweller
  • Posts: 7

Post 3+ Months Ago

i know this is extremely simple but i was wondering how you would check for a header variable "loc" and then check "option" and the data that loads on the page.php corresponds to the variable "loc" and "option"

for example loc = 3 option = 5
loads varsity football page
loc = 3 option = 6
loads varsity soccer page

loc is equal to the loc on the menu and option is the number of the auto-incrementing id
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • SpooF
  • ٩๏̯͡๏۶
  • Bronze Member
  • User avatar
  • Posts: 3422
  • Loc: Richland, WA

Post 3+ Months Ago

I'm assuming by header variables your referring to URL query strings.

Ex.
Code: [ Select ]
index.php?loc=3&options=5


Look into using $_GET[]. After you have the values of the varibles you can use condition statments if/ifelse or a switch to determine what to do when certain values are present.
  • nightimedweller
  • Newbie
  • Newbie
  • nightimedweller
  • Posts: 7

Post 3+ Months Ago

yes url query strings sorry, im currently using this but im getting an error im trying to resolve
Code: [ Select ]
if(isset($_GET['loc']))
    {
        $loc = $_GET['loc'];
        if($loc = 3)
        {
            $sports = mysql_query("select * from pages where option =". mysql_real_escape_string($_GET['option']) ." order by header asc");
            while($row = mysql_fetch_array($sports)){
            //print design code
  1. if(isset($_GET['loc']))
  2.     {
  3.         $loc = $_GET['loc'];
  4.         if($loc = 3)
  5.         {
  6.             $sports = mysql_query("select * from pages where option =". mysql_real_escape_string($_GET['option']) ." order by header asc");
  7.             while($row = mysql_fetch_array($sports)){
  8.             //print design code
  • SpooF
  • ٩๏̯͡๏۶
  • Bronze Member
  • User avatar
  • Posts: 3422
  • Loc: Richland, WA

Post 3+ Months Ago

What error are you getting?
  • nightimedweller
  • Newbie
  • Newbie
  • nightimedweller
  • Posts: 7

Post 3+ Months Ago

i fixed it for some reason when i was using

Code: [ Select ]
if($_GET['loc']===3)
{
  1. if($_GET['loc']===3)
  2. {


and not

Code: [ Select ]
if($_GET['loc']==3)
{
  1. if($_GET['loc']==3)
  2. {
  • nuclei
  • Graduate
  • Graduate
  • User avatar
  • Posts: 147
  • Loc: On a mountain

Post 3+ Months Ago

I think you meant where you were using:
Code: [ Select ]
if($_GET['loc'] = 3){

Going by your pasted example anyway.

Post Information

  • Total Posts in this topic: 6 posts
  • Users browsing this forum: No registered users and 107 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.