Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

78 users online



A few things i need to know for my cms system

A few things i need to know for my cms system

Currently viewing this thread: 1 (0 members and 1 guests)


Page 1 out of 2
mooosh

mooosh

Neverside Newbie
Status: Offline!

A few things i need to know for my cms system

Okay so i'm in the process of creating a Content management system using mysql and php.

The basic structure is i have a form for inputting the articles, a page that displays the articles, then a list of the articles.

So far i've managed to make it input the articles and display them fine, and display the lists fine also.

The problem i can't quite figure out is, my articles are sorted by an id tag that's auto_increment, and to display i do mysql_query("SELECT * FROM review ORDER BY id DESC LIMIT 8");

What i want to know is how do i make it so that if i have over 8 articles it does something like Order by id desc limit 8, order by id desc limit 8 starting from highest id-8, and then the next one highest id-16, but does it automatically?

Also, on my submit form it submits the articles plain text, i was wondering how instead of having to put in all the "<p></p>" or "<br>" it would do it automatically when you just press return for a new line or paragraph...

Any help apreciated, thanks

victorvp

victorvp

Victor van Poppelen
Status: Offline!

Do you mean you want the first page to show the first 8 articles, the next page to show the next 8 articles, etc? If that's what you're looking for I'd just go:

PHP:

<?php

if ($_GET['st']){
    
$start $_GET['st'];
}
else{
    
$start '0';
}

$result mysql_query('SELECT COUNT(*) FROM review'$conn) or die(mysql_error());
$numrows mysql_fetch_row($result);

if(
$numrows[0] == '0'){
    echo(
'No articles');
}

$result mysql_query('SELECT * FROM review ORDER BY id DESC LIMIT ' $start ', 8'$conn) or exit(mysql_error());
while(
$row mysql_fetch_assoc($result)){
    echo(
$row['id'] . ' ' $row['content'] . '<br /><br />');
}

echo(
'<hr />');

$startP $start 8;
$startN $start 8;

if(
$startN $numrows[0]){
    
$previous 'Previous</a> | ';
}
else{
    
$previous 'Previous</a>';
}

if(
$startP >= 0){echo('<a href="whatever.php?st=' $startP '">' $previous);}
if(
$startN $numrows[0]){echo('<a href="whatever.php?st=' $startN '">Next</a>');}

?>

___________________

Say it with me now: SIGNATURE GUIDELINES!

mooosh

mooosh

Neverside Newbie
Status: Offline!

Not quite but almost, if there were 16 articles, the first page would show the last 8 articles, the second page would show the first 8 articles.

Kind of a newest first order.

SimpleRules

SimpleRules

Test
Status: Offline!

The simplest way in my eyes to achieve that, would remove 8 from the Total Articles (Count) for every page. Instead of using pagination like
?start=8 , use ?start=2 , so 8x2 would be 16, so you want to get 8 rows starting at (Total-16).

It makes mathamatical logic, and is easy to achieve Smile

mooosh

mooosh

Neverside Newbie
Status: Offline!
Originally posted by SimpleRules:

The simplest way in my eyes to achieve that, would remove 8 from the Total Articles (Count) for every page. Instead of using pagination like
?start=8 , use ?start=2 , so 8x2 would be 16, so you want to get 8 rows starting at (Total-16).

It makes mathamatical logic, and is easy to achieve Smile

How would i implement this in code, i'm getting a bit stuck right now...

xiaodao

xiaodao

Neverside Newbie
Status: Offline!

victorvp did a good script, i think better use it, anyway, a paging system is ideal for this kind of site.as for the last question, i think you just press enter for a break, then call nl2br() function to output

mooosh

mooosh

Neverside Newbie
Status: Offline!
Originally posted by xiaodao:

victorvp did a good script, i think better use it, anyway, a paging system is ideal for this kind of site.as for the last question, i think you just press enter for a break, then call nl2br() function to output

nl2br()??

Sorry been a long time since i delt with php and i didn't do it very in depth

Oh and victorvp's code ended up being exactly what I was looking for, cheers mate.

Last edited by mooosh, March 22nd, 2005 10:17 PM (Edited 1 times)

Waldir

Waldir

God's Son
Status: Offline!

2 ways to make it add the <br>:

1:

PHP:

<?php
    $_POST
['text'] = str_replace "\r\n","<br>"$_POST['text'] );
?>

2:

PHP:

<?php
    $_POST
['text'] = nl2br($_POST['text']); 
?>

___________________

"The secret to creativity is knowing how to hide your sources." -- Albert Einstein

mooosh

mooosh

Neverside Newbie
Status: Offline!

*edit*

Don't worry, i sorted it out.

Last edited by mooosh, March 22nd, 2005 10:54 PM (Edited 1 times)

Waldir

Waldir

God's Son
Status: Offline!

ok than, thead closed.

___________________

"The secret to creativity is knowing how to hide your sources." -- Albert Einstein

Page 1 out of 2
Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.0097 seconds.