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
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";

Link to comment
Share on other sites

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";

....

?>

Link to comment
Share on other sites

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.