# SQL PHP help

**URL:** <https://forum.kirupa.com/t/sql-php-help/28169>\
**Category:** programming\
**Created:** [August 10, 2003, 10:56pm UTC](https://forum.kirupa.com/t/sql-php-help/28169 "2003-08-10T22:56:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![b\_rich](https://avatars.discourse-cdn.com/v4/letter/b/53a042/32.png) [@b\_rich](https://forum.kirupa.com/u/b_rich)\
**Post date:** [August 10, 2003, 10:56pm UTC](https://forum.kirupa.com/t/sql-php-help/28169/1 "2003-08-10T22:56:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 11, 2003, 1:57am UTC](https://forum.kirupa.com/t/sql-php-help/28169/2 "2003-08-11T01:57:54Z")

</div>

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…

```php

<?

$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](http://www.php.net) for specific information on what each command does… and check out this book:

> **[PHP: Your visual blueprint for creating open source, server-side content](https://www.amazon.com/exec/obidos/tg/detail/-/0764535617/qid=1053751242/sr=8-1/ref=sr_8_1/002-2551283-1162431?v=glance&s=books&n=507846)**
>
> This full color book is the only PHP title available that is designed for the visual learner. It covers over 100 tasks! Including using cookies to monitor the activity of Web site visitors to retrievi ...

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 11, 2003, 2:19am UTC](https://forum.kirupa.com/t/sql-php-help/28169/3 "2003-08-11T02:19:09Z")

</div>

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.🙂
