Jump to content


Photo

If..Else Result


  • Please log in to reply
6 replies to this topic

#1 cdtc

cdtc
  • Members
  • Pip
  • Newbie
  • 8 posts

Posted 14 July 2006 - 10:55 AM

I am sure it is a simple answer, but in a IF..Else Statement how do I redirect to a one page if there is a result from my database or redirect to another if there is no result?
CDTC (Cool Digital Technology)
www.cdtc.co.uk

#2 brown2005

brown2005
  • Members
  • PipPipPip
  • Advanced Member
  • 943 posts

Posted 14 July 2006 - 10:57 AM

if($result = 1)
{
header("location: http://gotopage.com");
}
else
{
header("location: http://gotopage2.com");
}

#3 brown2005

brown2005
  • Members
  • PipPipPip
  • Advanced Member
  • 943 posts

Posted 14 July 2006 - 10:57 AM

using that

if use post your SELECT STATEMENT I CAN WRITE IT PROPER...

#4 GingerRobot

GingerRobot
  • Staff Alumni
  • Advanced Member
  • 4,086 posts
  • LocationUK

Posted 14 July 2006 - 10:59 AM

yes, it might vary slightly depending on what you are retrieving from the database.

#5 cdtc

cdtc
  • Members
  • Pip
  • Newbie
  • 8 posts

Posted 14 July 2006 - 11:01 AM


$strSQL="SELECT * FROM School WHERE ([School Code Number] = '" .$_POST['schoolcode']."')";
CDTC (Cool Digital Technology)
www.cdtc.co.uk

#6 brown2005

brown2005
  • Members
  • PipPipPip
  • Advanced Member
  • 943 posts

Posted 14 July 2006 - 11:06 AM

$strSQL="SELECT * FROM School WHERE ([School Code Number] = '" .$_POST['schoolcode']."')";
$strRows = mysql_num_rows($strSQL);

if ($strRows  > 0)
{
header("location: http://gotopage.com");
}
else
{
header("location: http://gotopage1.com");
}

i think

#7 cdtc

cdtc
  • Members
  • Pip
  • Newbie
  • 8 posts

Posted 14 July 2006 - 11:09 AM

Thats Great thanks!!

(look out for www.creaseyIT.co.uk launch date sept 1st)
CDTC (Cool Digital Technology)
www.cdtc.co.uk




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users