Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-25-2002, 07:33 PM   PM User | #1
Squintz
Regular Coder

 
Join Date: Jul 2002
Posts: 226
Thanks: 0
Thanked 0 Times in 0 Posts
Squintz is an unknown quantity at this point
Newbie Trying out PHP/MySQL

Ok...I'v started a MySql Db thanx to ipowerwebs easy setup feature and they gave me this PHP code to use for a connection...

Now what do i do with that....

Im trying to make a simple Form that will alow useres to enter their infomation and store it in my db..

It will serve no purpose i just want to do it so i can Add PHP/MySQL to my portfolio...Im really serious about learning this so is there anyone on AOL or AIM that might be able to help me one on one...Or can you guys start a step by step thing in this Thread...

I dont need it all in one day so if you just gave me a new thing to try every day that would make me go WOW! that would be great..
Squintz is offline   Reply With Quote
Old 07-27-2002, 01:45 PM   PM User | #2
SYP}{ER
Regular Coder

 
Join Date: Jun 2002
Location: Ontario, Canada
Posts: 183
Thanks: 0
Thanked 0 Times in 0 Posts
SYP}{ER is an unknown quantity at this point
What you're given is a connection. You put that at the top of your page (or just before you do any queries).

ex:

$db = mysql_connect ("12.34.56.78","me","mypassword") or die ("Unable to connect");
mysql_select_db ("my_database_name") or die ("Cannot select database");

Then you can start querying!

to insert:

$result = mysql_query ("INSERT INTO table_name (field_name1,field_name1) VALUES ('$field_value1','$field_value2')") or die (mysql_error());

That'll insert the values $field_value1 and $field_value2 into the fields field_name1 and field_name2 which are in your table.

Make sure you have a table first, though. If you don't, use phpMyAdmin to make one.

Now to pull it out:

PHP Code:
<table border="0">
<tr>
<td bgcolor="#cccccc">Value of field_name1</td>
<td bgcolor="#cccccc">Value of field_name2</td>
</tr>
<?
$result 
mysql_query ("SELECT * FROM table_name");
while (
$row mysql_fetch_array ($result)){
?>
<tr>
<td><?=$row["field_name1"]?></td>
<td><?=$row["field_name2"]?></td>
</tr>
<? ?>
</table>
That'll print the values of field_name1 and field_name2 in your DB.

Doh! I have to go to work now, so if you need anymore help which I assume you will, you can contact me at "aaronvvright @ hotmail DOT com"

__________________
Offtone.com - In the works...
SYP}{ER is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:06 PM.


Advertisement
Log in to turn off these ads.