Jump to content


Photo

Noob Needs help


  • Please log in to reply
2 replies to this topic

#1 MadDawgX

MadDawgX
  • Members
  • PipPipPip
  • Advanced Member
  • 40 posts

Posted 10 June 2006 - 05:08 PM

Hey there. Im fairly new to PHP and would like some help. Im trying to check for a variable in the address bar.

eg.

http://www.twisterentertainment.org/news.php?page=1

What im trying to do is make an if statement that checks if page = 1 then do a series of html code. I've tried but it doesn't work, here it is.

<?php 
if ($_GET['page'] = 1) { 
?>

// HTML CODE

<?php
}
?>


#2 joquius

joquius
  • Members
  • PipPipPip
  • Advanced Member
  • 319 posts

Posted 10 June 2006 - 05:11 PM

ok I advise to go back over the basic operators.

First, $_GET['var'] is right but = will not given you a true result
you need to use
if ($_GET['var'] == 1)
however you can use $string = 1; to defined a string.

Also, I would advise to check if that HTTP_VAR exists first before putting it in a comparative function.

if (isset ($_GET['var']) && $_GET['var'] == 1)
z..z..z..z..z..z..z..z..

#3 MadDawgX

MadDawgX
  • Members
  • PipPipPip
  • Advanced Member
  • 40 posts

Posted 10 June 2006 - 05:15 PM

Okay thanx, I got it to work.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users