473,385 Members | 1,676 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Dynamic Page Title - Supposed to Pull from row in DB

Here's the problem that I'm having- I'm trying to pull in 2 fields from my database and place them in the title of the HTML. I'm connecting to the db and selecting everything exactly the same as I am doing below, and it works fine. For some reason it's not pulling in the fields. Any ideas?

Here's the link to the actual page I'm working on.

http://www.roomfulexpress.com/newsit...Y_CD=558167959

Please see below for my code. Thanks!



Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  5.  
  6. <?php
  7.  
  8.   // Get the search variable from URL
  9.  
  10.   $var = @$_GET['FAMILY_CD'] ;
  11.   $trimmed =($var); //trim whitespace from the stored variable
  12.  
  13. //connect to DB
  14. mysql_connect("xxx","xxx","xxx"); //(host, username, password)
  15.  
  16. //specify database
  17. mysql_select_db("xxx") or die("Unable to select database");
  18.  
  19. // Build SQL Query  
  20. $query = "select * from tblFamily where FAMILY_CD like \"%$trimmed%\" order by FAMILY_NAME desc"; // this will only effect the data pulling from the family table
  21.  
  22. $result = mysql_query($query) or die("Couldn't execute query"); // grab results
  23.  
  24. while ($row = mysql_fetch_array($result)) // show results
  25.  
  26. ?>
  27.  
  28. <?php echo("<title>" . $row["FAMILY_NAME"] . " - ". $row["CATEGORY"] . " Furniture Package" . "</title>"); ?>
  29.  
  30. <link href="../css/profile.css" rel="stylesheet" type="text/css" />
  31. <link href="../css/slimbox.css" rel="stylesheet" type="text/css" />
  32. <script type="text/javascript" src="../js/mootools.v1.11.js"></script>
  33. <script type="text/javascript" src="../js/slimbox.js"></script>
  34. <script type="text/javascript">
  35.  
  36. function popUp(URL) {
  37. day = new Date();
  38. id = day.getTime();
  39. eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=1,statusbar=0,menubar=0,resizable=1,width=520,height=600,left = 300,top = 100');");
  40. }
  41. </script>
  42.  
  43. </head>
  44.  
  45. <body>
  46. <div class="container">
  47.  
  48. <?php
  49.  
  50.   // Get the search variable from URL
  51.  
  52.   $var = @$_GET['FAMILY_CD'] ;
  53.   $trimmed =($var); //trim whitespace from the stored variable
  54.  
  55. //connect to DB
  56. mysql_connect("sql002.choiceone.net","roomfulexpress","x47rkv7N"); //(host, username, password)
  57.  
  58. //specify database
  59. mysql_select_db("roomfulexpress") or die("Unable to select database");
  60.  
  61. // Build SQL Query  
  62. $query = "select * from tblFamily where FAMILY_CD like \"%$trimmed%\" order by FAMILY_NAME desc"; // this will only effect the data pulling from the family table
  63.  
  64. $result = mysql_query($query) or die("Couldn't execute query"); // grab results
  65.  
  66. while ($row = mysql_fetch_array($result)) // show results
  67. {
  68. echo("<img src=../images/top.jpg />");
  69. echo("<table width=650px cellpadding=2px cellspacing=1px bgcolor=#F3F1EB>");
  70. echo("<tr class=lightBG>");
  71. echo("<td class=lightBG><h1> ". $row["FAMILY_NAME"] . " - ". $row["CATEGORY"] . " Furniture Package" . "</h1> ". $row["ROOMFUL_CONTAINS"] . " <br/><br/><ul> " . $row["FAMILY_DESC"] .  $row["FAMILY_DESC_2"] .  $row["FAMILY_DESC_3"] .  $row["FAMILY_DESC_4"] . $row["FAMILY_DESC_5"]. $row["FAMILY_DESC_6"] . $row["FAMILY_DESC_7"] . " </ul> </td>");
  72. echo("<TD class=photoBorder width=300px><a href=". $row["FL"] . " rel=lightbox> <img src=" . $row["PR"] . " /><br /><span class=smallFont>+ click to enlarge</a></span><br/><div class=smallerFontLeft><A HREF=javascript:window.print()> <img src=../images/common/print.jpg align=bottom /> click to print this profile</A></div></TD>");
  73. echo("</tr>");
  74. }
  75. echo("</table>");
  76.  
  77.  
  78. // Build SQL Query  
  79. $query2 = "select * from tblItem where FAMILY_CD like \"%$trimmed%\" order by ITEM_NAME desc"; // this will only effect the data pulling from the Item table
  80. $result2 = mysql_query($query2) or die("Couldn't execute query"); // grab results
  81.  
  82.  
  83. {
  84.  
  85. echo("<tr><img src=../images/savepiece.jpg /></tr>");
  86. echo("<table width=650px cellspacing=1px cellpadding=2px border=1px solid #666666>");
  87. echo("<tr class=backgroundColorTR>");
  88. echo("<td width=250px><b>Item Name</b></td>");
  89. echo("<td width=133px><b>Product ID #</b></td>");
  90. echo("<td width=133px><b>Size</b></td>");
  91. echo("<td width=133px><b>Sale Price</b></td>");
  92. echo("</tr>");
  93. }
  94.  
  95.  
  96. while ($row = mysql_fetch_array($result2)) // show results
  97.  
  98. {
  99. echo("<tr class=lightBG>");
  100. echo("<td> ". $row["ITEM_NAME"] .$row["DISCLAIMER"] . " </td>");
  101. echo("<td><!--<a href=itemprofile.php?SKU=". $row["SKU"] . "--> " . $row["SKU"] . "<!--</a>--></td>");
  102. echo("<td> ". $row["SIZE"] . "</td>");
  103.  
  104. echo("<td> ". $row["ITEM_RETAIL_PRICE"] . "</td>");
  105. echo("</tr>");
  106. }
  107. echo("</table>");
  108. // Build SQL Query  
  109. $query3 = "select * from tblPackage where FAMILY_CD like \"%$trimmed%\" order by PACKAGE_DESC"; // this will only effect the data pulling from the Package table
  110.  
  111. $result3 = mysql_query($query3) or die("Couldn't execute query"); // grab results
  112. {
  113. echo("<img src=../images/saveroomful.jpg />");
  114. echo("<table width=650px cellspacing=1px cellpadding=2px border=1px solid #666666>");
  115. echo("<tr class=backgroundColorTR>");
  116. echo("<td width=150px><b>Roomful Package</b></td>");
  117. echo("<td width=100px><b>Roomful ID #</b></td>");
  118. echo("<td width=350px><b>Roomful Contains</b></td>");
  119. echo("<td width=130px><b>Roomful Savings</b></td>");
  120. echo("<td width=120px><b>Sale Price</b></td>");
  121. echo("</tr>");
  122. }
  123. while ($row = mysql_fetch_array($result3)) // show results
  124.  
  125. {
  126.  
  127. echo("<tr class=lightBG>");
  128. echo("<td> ". $row["PACKAGE_DESC"] . "</td>");
  129. echo("<td> ". $row["PKG_ITM_CD"] . "</td>");
  130. echo("<td> ". $row["PACKAGE_CONTENTS"] . "</td>");
  131. echo("<td> ". $row["PACKAGE_SAVE"] . "</td>");
  132. echo("<td> ". $row["PACKAGE_RETAIL_PRICE"] . "</td>");
  133. echo("</tr>");
  134. }
  135. echo("</table>");
  136.  
  137.  
  138.  
  139. ?>
  140. <div class="disclaimer">* Tables and lamps may not be as shown in photo. Please see store for additional details.</div>
  141. </div>
  142. </body>
  143. </html>
Sep 14 '07 #1
6 2274
Lazoris
16
What line specifically are you talking about. and are you trying to post the db stuff at the top of the page title or the actual page title up where it is "-furniture package - windows explorer"?

Im assuming you mean the latter.Which is line 28.

laz
Sep 14 '07 #2
Lazoris
16
Ok i figured out your problem on my test pages. It seems you have to move your line 28:

Expand|Select|Wrap|Line Numbers
  1. <?php echo("<title>" . $row["FAMILY_NAME"] . " - ". $row["CATEGORY"] . " Furniture Package" . "</title>"); ?>
  2.  
to a spot after your Get var for the page info that you want to insert for example if you are getting the var in your db for item x to display more detailed page on item x then your line 28 has to be after the get var for that item or you'll have to tell the page exactly what to get. but im assuming its set up like my test db page is so just move line 28 to the bottom of the page and you should be good to go.
Sep 14 '07 #3
Just tried moving line 28 to the bottom of the page... didn't work. I put it totally at the bottom, below the </body> and </html>...

It's passing thru as blank.

What it should say for the title of the page (in the <title></title> tags) is

'Alexia Bronze - Living Room Furniture Package'

Any other thoughts?
Sep 14 '07 #4
Lazoris
16
Yeah im tapping out. What you need to do is specify to the code where to gather the info for your line 28. Are you pulling this "Alexia Bronze - Living Room Furniture" from a previous link or you just make this one page as a test page? or you just building this page?

basically your coding is correct though, just the page has no idea where to gather the info for your title.

laz
Sep 14 '07 #5
Lazoris
16
I see you got it working. I hope i helped at all.
Grats.

Laz
Sep 14 '07 #6
Just figured it out. Since I'm performing queries to multiple tables, it has to go right before I move to my next table. Also, it requires another db query before I build the html table with the other fields...

[PHP]// Build SQL Query
$query = "select * from tblFamily where FAMILY_CD like \"%$trimmed%\" order by FAMILY_NAME desc"; // this will only effect the data pulling from the family table
$result = mysql_query($query) or die("Couldn't execute query"); // grab results
while ($row = mysql_fetch_array($result)) // show results[/PHP]

Thanks for the ideas!
Sep 14 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: dave | last post by:
I am trying to generate an email from the webpage using code below, which works fine. However I want to be able to include some dyanmic data how do I go about it ?can anybody point me in the...
7
by: ergobob | last post by:
Hello, I have two small PHP scripts running on a test page at: http://www.usernomics.com/ergonomic-products-accessories5.html Both scripts work perfectly when there is one script on a page....
2
by: Goober | last post by:
I have the following default.aspx page that works properly. However, what I want to do is to link the graphics within it (that are hard coded now in the default web page) to our corporate...
6
by: 35th Ave Media | last post by:
Hello, I have about 60+ pages that I need to insert a MAILTO: tag so people can email the page using their email client. The body of the message is going to be the URL of that page. Using ASP,...
1
by: JMann101 | last post by:
I am writing a ASP.NET(VB) application and am having some trouble. I have a datagrid which list users and when an admin clicks "edit" a defined column becomes visible and a dynamic listbox control...
7
by: Abraham Luna | last post by:
how do i stop the dynamic validators from breaking explorer if i use a dynamic validator and move to a different control it breaks explorer and i can type in the page when i'm not supposed to....
2
by: WolfyUK | last post by:
Hello, I have a standard asp:DataGrid called CasesGrid that I wish to write my own paging controls for. The aim is to get something like the following rendered to screen: << First < Previous...
21
by: karen987 | last post by:
I have a news website, with asp pages. It has publishing software which allows you to add articles in a database, and then calls them up from links etc. I have added dynamic meta tags in 2 parts. The...
0
bmallett
by: bmallett | last post by:
First off, i would like to thank everyone for any and all help with this. That being said, I am having a problem retrieving/posting my dynamic form data. I have a form that has multiple options...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.