Jump to content


Photo

Display page title dynamically?


  • Please log in to reply
3 replies to this topic

#1 pmg206

pmg206
  • Members
  • PipPip
  • Member
  • 16 posts

Posted 24 May 2006 - 08:35 PM

I have this inkling this a no-brainer, but my culling through this forum, Google and two Dummies books hasn't brought me to a solution, so I thought I'd give a shout out.

Using Dreamweaver and my Yahoo! MySQL 4.1.14 hosted database, I'm trying to display a record with the page's title taken from database values. The values are inserted into the table fine, located within the body of the page. My strong suspicion is the problem is the <title> tag sits in the head area, thus it's confused.

Or, I'm confused. Thinking {Picture => 1000 words}, the code is below. But the notion is the desired result would be <title>Star Wars (1977)</title> with variables inserted, taken from <title><? $title ?> (<? $year ?></title>.

<?php require_once('Connections/spoil.php'); ?>
<?php
$colname_spoiler_page = "-1";
if (isset($_GET['id'])) {
  $colname_spoiler_page = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
}

if (isset($_GET['id'])) {
  $colname_duckscore = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
}
mysql_select_db($database_spoil, $spoil);
$query_spoiler_page = sprintf("SELECT * FROM titles WHERE id = %s ORDER BY id ASC", $colname_spoiler_page);
$spoiler_page = mysql_query($query_spoiler_page, $spoil) or die(mysql_error());
$row_spoiler_page = mysql_fetch_assoc($spoiler_page);
$totalRows_spoiler_page = mysql_num_rows($spoiler_page);

mysql_select_db($database_spoil, $spoil);
$query_duckscore = sprintf("SELECT * FROM titles right join ducks on titles.ducksid = ducks.id where titles.id = %s", $colname_duckscore);
$duckscore = mysql_query($query_duckscore, $spoil) or die(mysql_error());
$row_duckscore = mysql_fetch_assoc($duckscore);
$totalRows_duckscore = mysql_num_rows($duckscore);
?>

<head>
<title>Frank's Spoiled Movie Endings | <?php echo $row_spoiler_page['title']; ?> (<?php echo $row_spoiler_page['year']; ?>)</title>
... other code ...
</head>

<body>
... code here...
          <td width="500"<strong>Title</strong></td>
          <td width="60"><strong>Year</strong></td>
          <td width="60"><strong>Length</strong>(Minutes)</td>
          <td width="50"><strong><MPAA Rating</strong></td>
          <td width="110"><strong>My Rating</strong></td>
        </tr>
        <tr valign="top"> 
          <td width="500"><strong><?php echo $row_spoiler_page['title']; ?></strong></td>
          <td width="60"<?php echo $row_spoiler_page['year']; ?></td>
          <td width="60"<?php echo $row_spoiler_page['min']; ?></td>
          <td width="50"<?php echo $row_spoiler_page['rating']; ?></td>
          <td><img src="<?php echo $row_duckscore['url']; ?>" alt="<?php echo $row_duckscore['alt']; ?>" /></td>
        </tr>
... more code there...


#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 24 May 2006 - 09:43 PM

There's no obvious reason why your code wouldn't do exactly what you want. Does it do something different? What do you see when you view the generated html code?
Legend has it that reading the manual never killed anyone.
My site

#3 pmg206

pmg206
  • Members
  • PipPip
  • Member
  • 16 posts

Posted 24 May 2006 - 11:03 PM

(whew)... well, at least I'm not losing my marbles in the process. :)

What it does, presently, is...

... yeah, now its working. And I pinky promise I've done nothing between this moment and the last hour when it no workie.

Thanks for your validation, Andy, that I wasn't losing it. And like so many public leaders, I won't question success, merely take credit for it (however misplaced it is in this case). Thanks again!

#4 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 24 May 2006 - 11:12 PM

[!--quoteo(post=376836:date=May 24 2006, 07:03 PM:name=pmg206)--][div class=\'quotetop\']QUOTE(pmg206 @ May 24 2006, 07:03 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]And I pinky promise I've done nothing between this moment and the last hour when it no workie. [/quote]

Glad it worked out for you. Let's blame the earlier problem on Microsoft [img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /]

Legend has it that reading the manual never killed anyone.
My site




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users