Re: PHP w/ MySQL and a "?"
| From: | David Robley | Date: | Thu, 10 Aug 2000 02:27:18 +0000 |
| Subject: | Re: PHP w/ MySQL and a "?" | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-11030@lists.php.net to get a copy of this message | ||
On 9 Aug, Jay wrote:
> Hey all,
>
> I am very new at PHP and I was wondering something. I know this is
> probably really basic.
>
> I setup a database in MySQL, I can connect and then pull data. This
> is my code:
>
> <?
>
> $server="localhost";
> $username="nurck";
> $password="------";
> $database="------";
> $table="-----";
>
> @mysql_connect($server, $username, $password) or die("Connection");
> @mysql_select_db($database) or die("Database");
>
> $Result=mysql_query("SELECT * FROM $table");
> while($row = mysql_fetch_array($Result))
>
> {
> $id = $row["ID"];
> $title = $row["title"];
> echo "<font face=arial size=2>$id $title</font><br>";
> }
>
> ?>
>
> Now, that displays all the data in the table.
>
> What I want to do is, in the address bar of IE or NN, have someone
> type in "www.whatever.com/hardware.php3?id=1" and have it send out
> just that row data, not the entire table. Like how Zend or other
> sites are setup using a database.
>
>
> Thanks for any help!
>
> Jay Stauffer
>
Just use the value of id in your SQL query to restrict results.
SELECT * FROM table WHERE field = $id
Cheers
--
David Robley | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/
AusEinet | http://auseinet.flinders.edu.au/
Flinders University, ADELAIDE, SOUTH AUSTRALIA