Ok, I have made a few changes, whether they are for the better or not I will take advice. Currently in my fetchmeta.php file I have
PHP Code:
$sql = "SELECT*
`description`, `keywords`, `author`, `copyright`, `email`, `rating`, `robots`, `revisit`, `expires`, `distribution`*
FROM `meta_data` WHERE `meta_id` = { $page_id } " ;
$query = $db -> query ( $sql );
if( $query == false ) {
die( "<pre>" . print_r ( $db -> errorInfo (), 1 ). PHP_EOL . $query . "</pre>" );
}
while( $row = $query -> fetch ( PDO :: FETCH_ASSOC )) {
echo "<meta name=\"keywords\" content=\" { $row [ 'keywords' ]} \" />\n" ;
echo "<meta name=\"copyright\" content=\" { $row [ 'copyright' ]} \" />\n" ;
echo "<meta name=\"author\" content=\" { $row [ 'author' ]} \" />\n" ;*
echo "<meta name=\"email\" content=\" { $row [ 'email' ]} \" />\n" ; **
echo "<meta name=\"Distribution\" content=\" { $row [ 'distribution' ]} \" />\n" ;*
echo "<meta name=\"Rating\" content=\" { $row [ 'rating' ]} \" />\n" ;*
echo "<meta name=\"Robots\" content=\" { $row [ 'robots' ]} \" />\n" ;
echo "<meta name=\"Revisit-after\" content=\" { $row [ 'revisit' ]} \" />\n" ;
echo "<meta name=\"expires\" content=\" { $row [ 'expires' ]} \" />\n" ;
echo "<title>" . $row [ 'title' ] . "</title>\n" ;
}
The title still is not working although have tried inside the while loop as well as outside.
The results from this code gives me every page meta information on the homepage.
Can anyone advise please, thanks.
look and ye shall see
Well obviously from when I removed the * from the select statement and did not call the title it obviously would not show, so now I have the following
PHP Code:
$sql = "SELECT
`description`, `keywords`, `author`, `copyright`, `email`, `rating`, `robots`, `revisit`, `expires`, `distribution`, `title`
FROM `meta_data` WHERE `meta_id` = { $page_id } " ;
However I still do not get the relevant meta or title when using the navmenu which is the original issue. As I have said previously I have tried placing a page id on each page but whereas in the static site it worked it did not do anything in the dynamic site.
Can someone advise please, driving me mad.
Thanks.
Dsiplay dynamic meta/title info on requested page in dynamic site : back to basics
I have still not managed to get the query right to display the meta info and title for the page requested. I have stripped the code back to its very basic to ensure I was getting an output. As you see in the query I have selected a particular id and I get the correct output depending on the number entered. Can someone advise me as to how I ensure that query collects the information depending on the page requested by the user.
PHP Code:
include 'connect.php' ; $sql = "SELECT `description`, `keywords`, `author`, `copyright`, `email`, `rating`, `robots`, `revisit`, `expires`, `distribution`, `title` FROM `meta_data` WHERE meta_id = 3" ; $query = $db -> query ( $sql ); if( $query == false ) { die( "<pre>" . print_r ( $db -> errorInfo (), 1 ). PHP_EOL . $query . "</pre>" ); } while( $row = $query -> fetch ( PDO :: FETCH_ASSOC )) { echo "<meta name=\"keywords\" content=\" { $row [ 'keywords' ]} \" />\n" ; echo "<meta name=\"copyright\" content=\" { $row [ 'copyright' ]} \" />\n" ; echo "<meta name=\"author\" content=\" { $row [ 'author' ]} \" />\n" ; echo "<meta name=\"email\" content=\" { $row [ 'email' ]} \" />\n" ; echo "<meta name=\"Distribution\" content=\" { $row [ 'distribution' ]} \" />\n" ; echo "<meta name=\"Rating\" content=\" { $row [ 'rating' ]} \" />\n" ; echo "<meta name=\"Robots\" content=\" { $row [ 'robots' ]} \" />\n" ; echo "<meta name=\"Revisit-after\" content=\" { $row [ 'revisit' ]} \" />\n" ; echo "<meta name=\"expires\" content=\" { $row [ 'expires' ]} \" />\n" ; echo "<title>" . $row [ 'title' ] . "</title>\n" ; }
Thanks
Some help would be appreciated
I have tried to alter the query to call in the $page_id of each page but cannot seem to get the sql statement right. So far I have
PHP Code:
$sql = "SELECT `description`, `keywords`, `author`, `copyright`, `email`, `rating`, `robots`, `revisit`, `expires`, `distribution`, `title` FROM `meta_data` WHERE meta_id = '/page.php?page_id= $page_id ' LIMIT 1" ; $query = $db -> query ( $sql ); if( $query == false ) { die( "<pre>" . print_r ( $db -> errorInfo (), 1 ). PHP_EOL . $query . "</pre>" ); } if(isset( $page_id ) == $meta_id ){ while( $row = $query -> fetch ( PDO :: FETCH_ASSOC )) { echo "<meta name=\"keywords\" content=\" { $row [ 'keywords' ]} \" />\n" ; echo "<meta name=\"copyright\" content=\" { $row [ 'copyright' ]} \" />\n" ; echo "<meta name=\"author\" content=\" { $row [ 'author' ]} \" />\n" ; echo "<meta name=\"email\" content=\" { $row [ 'email' ]} \" />\n" ; echo "<meta name=\"Distribution\" content=\" { $row [ 'distribution' ]} \" />\n" ; echo "<meta name=\"Rating\" content=\" { $row [ 'rating' ]} \" />\n" ; echo "<meta name=\"Robots\" content=\" { $row [ 'robots' ]} \" />\n" ; echo "<meta name=\"Revisit-after\" content=\" { $row [ 'revisit' ]} \" />\n" ; echo "<meta name=\"expires\" content=\" { $row [ 'expires' ]} \" />\n" ; echo "<title>" . $row [ 'title' ] . "</title>\n" ; } return $meta_id ; }
I am not getting anything returned due to a notice at the start regarding undefined variable $meta_id but the query is also incorrect.
Can someone advise how I need to write this query to echo out the correct meta/title info please? Thanks in advance
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks