Not a Member Yet,
Click here to Register

ID: 101
Viewed: 19263
Added: Mar 25, 2002
Version:
Snippet uploaded by: snippet
Written By: snippet
Demo: Sorry, no demo



User Rated at: 2 Stars2 Stars
Rate This:

Thank you for your vote. Please wait...

It appears you already voted for this snippet

It appears your vote value was empty

This little script is a short way to see the contents of a table in a MySql database.

Change the names to reflect your connection to the database and the field names for the table and categories.

username = the name you need to connect to the database.
password = the password fo the database.
database_name = your name for the database.
table = the name of the table in the database.
field1 = the name of the rows (categories) in that table.

<!---Head--->
none

<!---Body--->


 <?
mysql_connect ("localhost","use\r\name","password");
mysql_select_db ("database_name");

$sql = "select * from table";
$result = mysql_query ($sql);

while ($row = mysql_fetch_array($result))
{
$field1= $row["field1"];
$field2= $row["field2"];

echo "$field1<br>";
echo "$field2<p>";

}
?>


Subject: retrive
[ Reply ]
Comment By: caleb on 19th of December 2009 05:17 AM

my echo is just displaying the code instead of what is in the database. what am i doing wrong?

Subject: re: retrive
[ Reply ]
Comment By: snippet on 04th of January 2010 05:29 AM

If you mean your page is showing php code then your webhost doesn't have php turned on. also make sure you use double quotes and not single quotes.

Subject: thank you
[ Reply ]
Comment By: paul on 16th of April 2010 07:12 PM

hey thanks so much for the script it worked perfect! Great instructions!

Subject: Thankyou!
[ Reply ]
Comment By: on 15th of July 2010 01:04 PM

Thanks so much for this code! It is brilliant!


Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.


Replying to a Comment...


Adding your comment. Please wait...

Thanks for adding your comment!. After further review it will be added.

There was a problem adding your comment. Please try again.

Please complete all the fields in the form before sending.

© 2002 - 2024 snippetlibrary.com All Rights Reserved. Conditions
Do NOT follow this link or you will be banned from the site!