Archangel
02-09-2005, 09:24 PM
So yeah, I'm just starting to work with PHP more and I'm trying to interact with a Database. I'm not going to saying it's tougher than ASP (although it seems to be) b/c I know that it's just that I don't know what to do.
I have my code posted below...I'm connect to the DB and (I believe) pulling the data off of it...but how do I pull the data out of the $result? I have a DB with 3 fields...stat_type_id, stat_type_name, and stat_count. I simply want to get the information for the stat_count field where stat_type_id = 1. I just can't figure out how to get it.
Thanks for the help! Here's my code...
<?php
//Connect to Database Server
$link = mysql_connect( "localhost", "User", "Password" );
if (! $link)
die( "Couldn't connect to MySql" );
//Selecting Database
$database = "database_website";
mysql_select_db( $database ) or die ( "Couldn't open $database ".mysql_error() );
$result = mysql_query( "SELECT stat_count FROM t_Stats WHERE stat_type_id=1" );
?>
I have my code posted below...I'm connect to the DB and (I believe) pulling the data off of it...but how do I pull the data out of the $result? I have a DB with 3 fields...stat_type_id, stat_type_name, and stat_count. I simply want to get the information for the stat_count field where stat_type_id = 1. I just can't figure out how to get it.
Thanks for the help! Here's my code...
<?php
//Connect to Database Server
$link = mysql_connect( "localhost", "User", "Password" );
if (! $link)
die( "Couldn't connect to MySql" );
//Selecting Database
$database = "database_website";
mysql_select_db( $database ) or die ( "Couldn't open $database ".mysql_error() );
$result = mysql_query( "SELECT stat_count FROM t_Stats WHERE stat_type_id=1" );
?>