Web Hosting Talk







View Full Version : PHP & MySQL - Storing & Display Data


Jamie Harrop
01-22-2005, 10:42 AM
I am trying probably the most simple thing that can be done with PHP & MySQL together.

That is, allow for the visitor to fill out a form, have the contents stored in a database and then have the contents of the database displayed on a page.

I have followed two tutorials, completing them both on my local machine with phpmyadmin and both have received parse errors. It certainly isn't a mistake by me because all I am doing is copying and pasting the code it gives me.

So, would someone be so kind to show me the SQL needed for the database and the PHP needed for both submit_message.php, store_message.php and display_message.php or point me to a tutorial they know that works so I can see if it is me who is making a mistake.

effusionx1
01-22-2005, 11:07 AM
Have you read this?

http://www.php.net/manual/en/ref.mysql.php

Oshaka
01-22-2005, 11:07 AM
I can help.. What errors are you getting, what version of PHP 4.X or 5?

codewalkers.com under code section can help you with some nice tutorials!

Their is also the php manual! http://us4.php.net

Good luck, Josh.

kooshin
01-22-2005, 11:09 AM
All right here is a code which you can use. You make a simple form which will be used for submitting what ever you want to submit and the table and its columns ready for getting that news then displaying it from it .

the code to insert info into the data base

$result = mysql_query("INSERT INTO table(title, content)VALUES('$heading', '$content' ) ")

or die(mysql_error());
echo"Information inserted into the database";


code for displaying information onto a page
$query = "SELECT title, content FROM table ".
$result = mysql_query($query) or die("Failed to query");
$row = mysql_fetch_array($result, MYSQL_ASSOC);

then you can write any place something like <?=$content;?> and <=$title;?> to display the title and content.
Note this is just an example so you can customize it to suit your needs.Even though I myself is not good at php and mysql but am trying to learn them at the moment so I hope that helps . Thanks,