SQL PHP help

ok im trying to get this down but i keep running into problems… first off i have a table named tc_pat in which i want to display only the items from todays date. So if you were to log in you would only see the items for the current day:

here is what i got:

$appoint = “SELECT * FROM tc_pat WHERE date = ‘$today’”;

this is what i am using to try and display:

<p><? ehco "$appoint" ?></p>

am i way off ???

i am new to this so any help is appriciated.

are you way off… yes. I don’t know how much you know about database and using PHP to access the data stored in a database, so I guess I will start at the beginning…


<?

$linkID = mysql_connect("HOSTNAME", "USERNAME", "PASSWORD"); //connect to the DB

mysql_select_db("DATABASENAME"); //select which database

$query = "SELECT * FROM tc_pat WHERE date='$today'"; //tell the code what to get from the database

$resultID = mysql_query($query, $linkID); //issue the query

if($resultID)
{
      for($x=0;$x<mysql_num_rows($resultID);$x++)
      {
             $row = mysql_fetch_assoc($resultID);
             print $row['fieldname'];
      }
}
else
{
      print mysql_error($linkID);
}

mysql_close($linkID);

?>

I can’t really exlpain much of it because most of it is pretty much self explanitory. Check the manual at www.php.net for specific information on what each command does… and check out this book:

sorry this can’t be more comprehensive… i gotta get going…

thanks man i knew how to connect i just wasnt sure about getting the info but i definatly got the information i was looking for thanks alot.:slight_smile: