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?
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 2 of 2 people found this answer helpful. Did you? Yes No |
© Advanced Web Core. All rights reserved