Have an account? Sign in
Login  Register  Facebook
I'm having trouble with my function....
<?php
function check_page(){
        $sql = "SELECT * FROM page";
        $res = mysql_query($sql) or die(mysql_error());  
        while($row = mysql_fetch_assoc($res)){
            $title = $row['title'];
            $page = $row['page'];
        }      
    }
?>
I'm trying to get it so that the page goes according to the input in the database. I've tried
<title><?php $obj->check_page($title); ?></title>


(It's in a class file) And I can't seem to get it to work... Any thoughts?
Started: September 17, 2011 Latest Activity: September 17, 2011 php mysql function
1 Answer
you have to determine the page which you want to select:
\"SELECT * FROM page where id = \'page id\'\"
then why you using while() and its just one input? just use
    function check_page($id){
        $sql = \"SELECT * FROM page where id = \'$id\'\";
        $res = mysql_query($sql) or die(mysql_error());  
        $row = mysql_fetch_assoc($res);
        
        return $row;
    }
and using:
<?php
	$page = $obj->check_page(5);//select the page which have id = 5
?>
<title><?php $page[\'title\']; ?></title>

Posted: MacOS
In: September 17, 2011

Your Answer

xDo you want to answer this question? Please login or create an account to post your answer