0

I have a index.php, it calls a function post_themes_front(), the function gets all the "posts" from the SQL database and creates all the content, including the links. Example: picture A links to www.index.com/picture_a_name

code sample:

while($row = mysql_fetch_array($result))
    {

    echo '

     <div class="post">
        <h2>

        <a href=http://www.meetthemes.com/'. $row['name'] .'" title="'. $row['name'] .'">'. $row['name'] .'</a>
        </h2>

    <div class="infos b20">

     By <em>MeetThemes</em> on <em>'. $row['date'] .'</em>

     <span class="label label-important pull-right">'. $row['views'] .' views</span> 
     <a href="http://www.meetthemes.com/'. $row['name'] .'#comments" class="label label-info pull-right r5" title="Comments">'. $row['comments'] .'</a>
     <a href="http://www.meetthemes.com/'. $row['name'] .'" class="label label-info pull-right r5">'. $row['catagory'] .'</a>
     <a href="http://www.meetthemes.com/'. $row['catagory'] .'" class="label label-info pull-right r5">'. $row['catagory'] .'</a>
  </div>

  <p>
     <a href="http://www.meetthemes.com/'. $row['name'] .'" title="ThemeForest - Silicon - Responsive WordPress Theme">
     <img alt="ThemeForest - Silicon - Responsive WordPress Theme" src="img/'. $row['image_path'] .'" class="post_img" />
     </a>
     </div>
    ';
}

There is no such file as "picture_a_name", id like to create that, when the user clicks on it, and send him there with the apropriate values for comments, link etc, fetched from SQL.

But is it to late to create it on click?

Does it have to be created before that? i could make a function to create the content of all posts in index, and call it on index, and send them there on click but that would take up quite alot of client resources ..... in therms of loading time (I know its server side)...

Any suggestions are welcome

Example of what i want to achive, newone.org the frontpage, contains loads of "posts" which all link to seperate content.

I understand that there are plenty of CMSes that will do this for me, but i dislike using drupal / joomla / wordpress

1 Answers1

0

What you can do is make an .htaccess file which catches all requests to non-existing files, something like this:

<IfModule mod_rewrite.c>
  RewriteEngine On

  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ createContent.php?file=$1 [QSA,L]
</IfModule>

So that, when 'picture_a_name' doesn't exist, the request is redirected to createContent.php?file=picture_a_name. In createContent you can now create the asked content and save it to 'picture_a_name'.

jeppeb
  • 530
  • 4
  • 11