Jump to content


Very simple CMS


2 replies to this topic

#1 cozmika

    Young Padawan

  • Members
  • Pip
  • 1 posts
  • Interests:web designer/developer

Posted 23 February 2008 - 02:40 PM

Hi,

I started to learn PHP, and I'm trying to make very simple CMS. I managed to write scripts for input data, and on main page they are listed. Very simple. Now, I want to make that on main page are titles, which are links to posts, and just a mini description of a post. When somebody clicks on a title that should open new page with that post.

How to make that? If it is too long and hard to explain here, maybe you know some tutorial with it?

Tnx

:biggrin:

#2 BigDog

    Young Padawan

  • Members
  • Pip
  • 277 posts
  • Gender:Male
  • Location:Orange County, California
  • Interests:Running, building computers, PC games and BMX and programming.

Posted 04 March 2008 - 11:56 PM

Sudo code:

Database should contain Id, description, fulltext, author, time...

Insert something for testing purposes.

On the main page, call for all "posts"

Quote

$XXX = mysql_query("SELECT * FROM _____ ORDER BY id DESC");

Then do

Quote

while($row = mysql_fetch_array($XXX))
{
$id = $row['id'];
$title = $row['title'];
$shortpost = $row['description'];
$post = $row['fulltext'];
$author = ... //so forth...
?>
<h1><?=$title?></h1>
<?=$shortpost?>
<?
}

There you go.

#3 tones

    Young Padawan

  • Members
  • Pip
  • 10 posts

Posted 07 March 2008 - 03:42 AM

If i'm reading this right, then you want the page to display the topic title, and then a short description correct? Then you want it so that you click a link and it opens a page showing the full story specific to that post?

If i got that far the try using the switch function.

Quote

<?php
switch ($_GET['act']) {

default:
$a = mysql_query("SELECT * FROM `table` ORDER BY `id`");
if (mysql_num_rows($a) == 0) {
echo ' There are no stories to display! ';
} else {
echo '<table>';
while($b = mysql_fetch_object($a)) {
echo '<tr>
<th><a href="index.php?act=Show&tid='.$b->id.'" target="_self">'.$b->title.'</a><br />'.$b->author.' <br />'.$b->date.'</th>
<td>'.$b->shortdesc.' <a href="index.php?act=Show&tid='.$b->id.'" target="_self">read more ...</td>
</tr> ';
}
echo '</table>';
break;

case 'Show':
$tid = $_GET['tid'];
if (!isset($tid) || !is_numeric($tid)) {
echo '<font color="red"><b>Invalid or no ID given, redirecting you. . .</b></font>';
echo '<meta http-equiv="refresh" content="3;URL=index.php?act=" />';
} else {
$a = mysql_query("SELECT * FROM `table` WHERE `id` = '$tid' LIMIT 1");
if (mysql_num_rows($a) == 0) {
echo '<font color="red"><b>The application matching the id you provided does not exist!</b></font>';
} else {
echo '<table>
<tr>
<td>'.$b->title.'<br />'.$b->author.'<br />'.$b->date.'</td><td>'.$image.'</td>
</tr>
</table>
<table>
<tr>
<td>$b->story</td>
</tr>
</table>
break;
}
?>

Ok this is just an idea of what you could try, if i'm reading it right.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users