Jeanco
03-27-2004, 07:03 PM
Here's the situation: Right now I have a static title at epasture.com What I want to do is when a particular product, laughable, tutorial, or brainteaser is selected it becomes the title of that page.
I use the ID variable to ID the item from the the database if an item is selected. Every item, regardless of which table it is in has a TITLE record so thats not an issue. The code seems to work fine when there isn't an item selected ($ID < 1). However, when an item is selected it doesn't seem to work. The title doesn't return properly and the whole page is left as a blank white sheet (so no content gets returned either - that code isn't shown here but does work before I tried this so its not the problem).
Here is the code I'm using:
<TITLE>ePasture.com -
<?php /* IF NO TITLE IS DEFINED */
if ($ID < 1) {
echo "Laughables, Brainteasers, Ridiculous Products, Tutorials";
} else { //$ID has a value
if ($content = "laughables.php") { //if we are in the laughables section
$result = mysql_query("SELECT * FROM laughables WHERE ID = {$row['ID']}")
or die("Invalid query: " . mysql_error()); //then select the appropriate laughable
while ($row = mysql_fetch_array($result)) {
echo "{$row['TITLE']}"; // and out put the title
}
} elseif ($content = "brainteasers.php") { //if we are in the brainteasers section
$result = mysql_query("SELECT * FROM brainteasers WHERE ID = {$row['ID']}")
or die("Invalid query: " . mysql_error()); //then select the appropriate brainteaser
while ($row = mysql_fetch_array($result)) {
echo "{$row['TITLE']}"; // and out put the title
}
} elseif ($content = "products.php") { //if we are in the products section
$result = mysql_query("SELECT * FROM products WHERE ID = {$row['ID']}")
or die("Invalid query: " . mysql_error()); //then select the appropriate product
while ($row = mysql_fetch_array($result)) {
echo "{$row['TITLE']}"; // and out put the title
}
} elseif ($content = "tutorials.php") { //if we are in the tutorials section
$result = mysql_query("SELECT * FROM tutorials WHERE ID = {$row['ID']}")
or die("Invalid query: " . mysql_error()); //then select the appropriate tutorial
while ($row = mysql_fetch_array($result)) {
echo "{$row['TITLE']}"; // and out put the title
}
} else {
echo "Laughables, Brainteasers, Ridiculous Products, Tutorials";
}
}
?>
</TITLE>
Please let me know if there is anything else I can provide you to help you help me solve this problem. Any Ideas?
I use the ID variable to ID the item from the the database if an item is selected. Every item, regardless of which table it is in has a TITLE record so thats not an issue. The code seems to work fine when there isn't an item selected ($ID < 1). However, when an item is selected it doesn't seem to work. The title doesn't return properly and the whole page is left as a blank white sheet (so no content gets returned either - that code isn't shown here but does work before I tried this so its not the problem).
Here is the code I'm using:
<TITLE>ePasture.com -
<?php /* IF NO TITLE IS DEFINED */
if ($ID < 1) {
echo "Laughables, Brainteasers, Ridiculous Products, Tutorials";
} else { //$ID has a value
if ($content = "laughables.php") { //if we are in the laughables section
$result = mysql_query("SELECT * FROM laughables WHERE ID = {$row['ID']}")
or die("Invalid query: " . mysql_error()); //then select the appropriate laughable
while ($row = mysql_fetch_array($result)) {
echo "{$row['TITLE']}"; // and out put the title
}
} elseif ($content = "brainteasers.php") { //if we are in the brainteasers section
$result = mysql_query("SELECT * FROM brainteasers WHERE ID = {$row['ID']}")
or die("Invalid query: " . mysql_error()); //then select the appropriate brainteaser
while ($row = mysql_fetch_array($result)) {
echo "{$row['TITLE']}"; // and out put the title
}
} elseif ($content = "products.php") { //if we are in the products section
$result = mysql_query("SELECT * FROM products WHERE ID = {$row['ID']}")
or die("Invalid query: " . mysql_error()); //then select the appropriate product
while ($row = mysql_fetch_array($result)) {
echo "{$row['TITLE']}"; // and out put the title
}
} elseif ($content = "tutorials.php") { //if we are in the tutorials section
$result = mysql_query("SELECT * FROM tutorials WHERE ID = {$row['ID']}")
or die("Invalid query: " . mysql_error()); //then select the appropriate tutorial
while ($row = mysql_fetch_array($result)) {
echo "{$row['TITLE']}"; // and out put the title
}
} else {
echo "Laughables, Brainteasers, Ridiculous Products, Tutorials";
}
}
?>
</TITLE>
Please let me know if there is anything else I can provide you to help you help me solve this problem. Any Ideas?
