0

hi i want to direct my website to different pages
If there are competions that are active to show the page list of them else go to other page

i tried this but no luck

<?php
include_once "connect_to_mysql.php";

$extract = mysql_query("select * from tbl_competition WHERE fld_closed='N'");

while ($row = mysql_fetch_assoc($extract))

if ($rows <= 0) {          
header( 'Location: nocompetition.php' ) ;     
}      

if ($rows > 0) {          
 
header( 'Location: competition.php' ) ; 
}
4
Contributors
4
Replies
8
Views
6 Years
Discussion Span
Last Post by branding4you
0

Several things:
no {} about while loop. Need a while anyway??
I assume you're after mysql_num_rows() and redirect on the strength of that.

0

I think you need something like this:

$extract = mysql_query("select * from tbl_competition WHERE fld_closed='N'");

if (mysql_num_rows($extract) > 0) {
    while ($row = mysql_fetch_assoc($extract)) {
        //Do your thing with the data
    }
} else { //No rows from MySQL
    //Put your redirect stuff here
}

And yeah, where are your {} and all the code for what you want to happen during the while() loop?

0

Try that:

<?php
include_once "connect_to_mysql.php";

$extract = mysql_query("select * from tbl_competition WHERE fld_closed='N'");
         
if(mysql_num_rows($extract) < 0){
header( 'Location: nocompetition.php' ) ;     
}
else{
header( 'Location: competition.php' ) ; 
}
?>

Hope that help.

0

thanks i tried the code and added "=" to the if line and its perfect! ..

Thank you

<?php
include_once "connect_to_mysql.php"; 

$extract = mysql_query("select * from tbl_competition WHERE fld_closed='N'"); 

if(mysql_num_rows($extract) <= 0){

header( 'Location: nocompetition.php' ) ;      

}else{

header( 'Location: competition.php' ) ;

}

?>
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.