Jump to content

Recommended Posts

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!!

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.

 

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.