Jump to content

Dynamic Content Default Page


amwd07

Recommended Posts

Hello I wonder if someone can help me here I have created a website with custom CMS

my problem is the default page index.php does not show any content

however index.php?title=about  pulls in the about us content

 

I need to show a default if there is no query to pull in the welcome content

I know I must be missing something simple I have tried creating a second query but it uses the same field to pull in the information and then the welcome appears on all pages

 

// Get secondary data from the database
$query="SELECT * FROM content WHERE title='$title'";
$result=mysql_query($query);
mysql_close();

// Use all of the data obtained from various sources
$content_id=mysql_result($result,$i,"content_id");
$desc=mysql_result($result,$i,"desc");

$main .= "$desc";

Link to comment
https://forums.phpfreaks.com/topic/68711-dynamic-content-default-page/
Share on other sites

must have something wrong here

I am using $main as the template varible I am sure you are on the right track

 

if($title == ""){
   $main .= "$desc"; //or whatever the title is of your default page
}

// Get initial data and assign variables first.
$title = str_replace('-', ' ', $_GET['title']);

// Get secondary data from the database
$query="SELECT * FROM content WHERE title='$title'";
$result=mysql_query($query);
mysql_close();

// Use all of the data obtained from various sources
$content_id=mysql_result($result,$i,"content_id");
$desc=mysql_result($result,$i,"desc");
$title=mysql_result($result,$i,"title"); // also added this?

$site_title = "Paris Cues";
$page_title = "$title";

$main .= "$desc";

your code seemed to of work when I move it below the query

but i face the same problem as soon as I replace welcome with $desc

nothing shows up?

 

<?php
// Get initial data and assign variables first.
$title = str_replace('-', ' ', $_GET['title']);

// Get secondary data from the database
$query="SELECT * FROM content WHERE title='$title'";
$result=mysql_query($query);
mysql_close();

// Use all of the data obtained from various sources
$content_id=mysql_result($result,$i,"content_id");
$desc=mysql_result($result,$i,"desc");

$site_title = "Paris Cues";
$page_title = "$title";

if($title == ""){
   $main .= "$desc"; //or whatever the title is of your default page
}
$main .= "$desc";

....

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.