Hi,
I hope someone can help a mySQL/PHP newbie.
This is what I'm trying to do:
I've bought a books on PHP/mySQL, but it was onlye very "fresh user" related, and withing two hours i wanted to do more then the book told me.
1: I have managed to create a very simple joke DB, with categories etc. Howverer i would like to joke field to insert the correct paragraph and linebreak in the joke.
E.g I type something like (in a textarea):
Line1
Line 2
Line 4
When the joke is displayed, it returns everything on a single line. Can someone help me with how to do this, or point me to an article describing it?
2:
I would also like to add something like "The latest X jokes", can someone help me with the extraction from mySQL on this?
Really hope someone will take the time to help out.
Best regards, Spear
Newbie: textarea & latest X submited?
Moderator: General Moderators
Well, when your displaying the joke and dont want it to all appear on one line do this:
now when you display the text, it'll have all the line breaks 
And for the latest X jokes the query is:
Then to display the code u just do:

Code: Select all
$joke = nl2br($rowї"joketext"]);And for the latest X jokes the query is:
Code: Select all
$x = 10;
$query="SELECT * FROM jokestable ORDER BY dateadded LIMIT 0,$x";Code: Select all
echo "Latest $x Jokes:<br>";
while ($row = mysql_fetch_array($result)) {
$title = $rowї"title"];
$author = $rowї"author"];
...ect.
echo "$title - $author <br>";
}Thank you..
Hi,

1: Could you or anyone else recomend a good "howto" book that is advanced enough not to leave me pondering after a few hours, but easy enough for a newbie?
2: Lets say i wanted to add a 10 jokes per page, and include a "Next/Previous" button in the categories if it contained more then 10 jokes. Difficult?
Best regards, Spear
Thank you very much for your help! Now everything is almost the way i want it. I have one last question... Or to be honest.. Two questionsfatalcure wrote:Well, when your displaying the joke and dont want it to all appear on one line do this...
1: Could you or anyone else recomend a good "howto" book that is advanced enough not to leave me pondering after a few hours, but easy enough for a newbie?
2: Lets say i wanted to add a 10 jokes per page, and include a "Next/Previous" button in the categories if it contained more then 10 jokes. Difficult?
Best regards, Spear
1. I dunno about any books, i just learn over the WEB.
2. look at this post for the prev-next links: http://liberty.dnsprotect.com/~devnetwo ... 3c304#7163
hope it helps
2. look at this post for the prev-next links: http://liberty.dnsprotect.com/~devnetwo ... 3c304#7163
hope it helps