Page 1 of 1

MY Big Problem

Posted: Mon Aug 08, 2005 10:55 pm
by Mastermind
Dear Friends,

I have a problem today about php there he is create a web site that will allow the user to enter the user to enter jokes.Each joke should have their own unique identifier and every joke entered should have a corresponding date entry in the database as well as the name of fields..

Posted: Mon Aug 08, 2005 11:48 pm
by josh
and the problem is......?

Posted: Tue Aug 09, 2005 4:02 am
by Grim...
I had a rant about this a while ago.

Here's the problem: you aren't good enough at PHP to attempt this yet.
What you want to do is really simple, so go and pick up a 'beginners PHP' book or look up a PHP tutorial on the net and actually learn the language, rather than just get told the bits of information you need.

Mmm'kay?

Posted: Tue Aug 09, 2005 4:37 am
by patrikG
Grim... wrote:I had a rant about this a while ago.

Here's the problem: you aren't good enough at PHP to attempt this yet.
What you want to do is really simple, so go and pick up a 'beginners PHP' book or look up a PHP tutorial on the net and actually learn the language, rather than just get told the bits of information you need.

Mmm'kay?
Tone down your arrogance, Grim. How about you help mastermind to find the solution, to coach him - or is that beyond what you think posting on this forum is all about?

Posted: Tue Aug 09, 2005 4:47 am
by Grim...
Yes it is - this is the general discussion forum.

Posted: Tue Aug 09, 2005 4:47 am
by Grim...
However, in the spirit of good will, he could do worse than starting here:

http://www.tizag.com/phpT/

Posted: Tue Aug 09, 2005 4:50 am
by patrikG
Save us your attitude, Grim, and start helping people.

Posted: Tue Aug 09, 2005 5:03 am
by Grim...
How is that not helping?

That's a really good beginners tutorial...

Posted: Tue Aug 09, 2005 5:17 am
by Grim...
Okay mastermind, here's what I'd do...

First, set up your database so that the 'jokes' table (or whatever) has a auto-incrementing index, called 'ID', a text field called 'Joke' and a long interger field called 'Date'.

Make a HTML form that asks for the joke (with a text area called 'joke'), and have it submit to a page called 'add.php'.

On add.php, you want something along the lines of:

Code: Select all

<?php

//connect to your database here...

addslashes($joke);
$edate = mktime();

mysql_query ("INSERT INTO jokes (Joke, Date) VALUES ('$joke', '$edate')");

?>

Thanks for the joke!
When you want to get the date out again, use

Code: Select all

<?php
date("M-d-Y", $the_number_from_the_database);
The Id of the joke will be automatically inserted by the database.

This is not tested, but looks okay.

Good luck :)

Posted: Tue Aug 09, 2005 9:59 am
by josh
The OP still hasn't stated his problem. He didn't even ask a question.

Posted: Tue Aug 09, 2005 10:05 am
by Grim...
Yeah, but I got told off, so I figured it would be easier to take a guess.