Sweets287 Posted August 14, 2007 Share Posted August 14, 2007 I know very little about PHP code and sort of bumbling along a bit, but the man who helps me with PHP and has written most of my site says that it is not possible to pull a brand name from a database and use it as a page title whilst using a header, but looking at other websites i'ld of thought it would have been possible. Any help would be very grateful. Top of page looks like this <?php # Script 1.3 - details.php session_start(); // Start the session. // Set the page title and include the HTML header. $page_title = 'Product Details'; include_once ('includes/header.inc'); require_once ('includes/mysql_connect.php'); // Connect to the database. $query = "SELECT pid, StockCode, Price, Brand, Title, MainPic, LongDescription, Size, Related1, Related2, Related3, Related4 FROM stock WHERE StockCode = '$StockCode' GROUP BY StockCode"; $result = mysql_query ($query); // Start table with top margin --- > echo "<table width=600 border=0>"; while ($row = mysql_fetch_array ($result,MYSQL_ASSOC)) { #echo "{$row['Size']}"; $option = $row['Size']; #echo $option; & header <html> <head> <title><?php echo $page_title; ?></title> </head> Thanks in advance!! Quote Link to comment https://forums.phpfreaks.com/topic/64923-solved-php-driven-page-titles-with-headers/ Share on other sites More sharing options...
chronister Posted August 14, 2007 Share Posted August 14, 2007 It would be possible, but you would have to run a query before you set the page title variable. You would have to grab the brand name from the database and include it's variable in the $page_title variable. require_once('includes/mysql_connect.php'); //connect to the database // run our query to get the brand $result=mysql_query("SELECT brandname FROM table_name WHERE brand_id='$id'"); while($row=mysql_fetch_object) { $brand_name=$row->brand_name; } // Set the page title and include the HTML header. $page_title = 'Product Details:' . $brand_name; include_once ('includes/header.inc'); require_once ('includes/mysql_connect.php'); // Connect to the database. This is a fairly crude example as I don't know your table names or any database structure, but this is the general idea. You would have to get the brand name from the database first, then set your page title variable. Quote Link to comment https://forums.phpfreaks.com/topic/64923-solved-php-driven-page-titles-with-headers/#findComment-323960 Share on other sites More sharing options...
Sweets287 Posted August 14, 2007 Author Share Posted August 14, 2007 Perfect!! absolute star! Thank you Quote Link to comment https://forums.phpfreaks.com/topic/64923-solved-php-driven-page-titles-with-headers/#findComment-324025 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.