Welcome to WebmasterWorld Guest from 54.196.175.173

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

PHP to pull from sql

     

webboy1

2:02 pm on Apr 3, 2002 (gmt 0)

10+ Year Member



Hi,

I have recently started learning PHP/SQL techniques.

I am a complete beginner and have recently been on a 3day 1-2-1 course to learn the basics. However, i am having trouble and hope somone can help.

I am basically just trying to pull information from my database. I have a local server on my PC.

I have typed this code within my HTML document:

$db = mysql_connect("localhost","Administrator","password");
mysql_select_db("tuna",$db);
?>

here are the results:

<?php
$result = mysql_query("SELECT firstname FROM brian");
?>

I know the database does work, cause by sheer fluke i got some results up earlier. but didn't save!!! doh!!!

Can someone please tell me how to pull the information ffrom my database please.

regards

webboy

gethan

2:10 pm on Apr 3, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld webboy1,

while ($row = mysql_fetch_array($result)) {
print "I have a row $row[firstname]";
}

Will get you started, another useful function
$num = mysql_num_rows($result);

And even more useful,

[php.net...] -- will make you an expert in no time ;) .... good luck.

webboy1

2:17 pm on Apr 3, 2002 (gmt 0)

10+ Year Member



thanks gethan.

Now i know i definetly have everythng setup correctly cause that code example worked. I was beggining to think i was going mad, when instead it is just rusty PHP skills!!!

thanks man!!

 

Featured Threads

Hot Threads This Week

Hot Threads This Month