Displaying each record in its own webpage
Moderator: General Moderators
Displaying each record in its own webpage
Hello everyone. I'm trying to display each record of a mysql database in its own webpage. I read somewhere that this can be accomplished with a template by passing columnnames through a URL, but I can't find any documentation on how to do this. If anyone can give me tips, hints or point me in the right direction, I'd appreciate it. Thanks!
Re: Displaying each record in its own webpage
A simple set up would be like this:
The url to the page being: http://www.mydomain.com/record.php?id=23
Of course, there's a bit more to it than that - protection against SQL injection & all that - but that's the basic idea.
The url to the page being: http://www.mydomain.com/record.php?id=23
Code: Select all
$id = $_GET['id'];
$query = "SELECT * FROM `table` WHERE `id` = '$id'";
//get the results & echo themReal programmers don't comment their code. If it was hard to write, it should be hard to understand.
Re: Displaying each record in its own webpage
Pickle, thanks for the tip. I tried that code but keep getting a "Parse error: syntax error, unexpected T_ECHO"
Here's what how I wrote the code:
$id = $_GET['id'];
$query = "SELECT * FROM inventory WHERE `id` = '$id'";
/* get the results & echo them */
$result = mysql_query($query)
or die ("Couldn't execute query.")
/* display fields */
echo "$itemname";
Am I missing something?
Here's what how I wrote the code:
$id = $_GET['id'];
$query = "SELECT * FROM inventory WHERE `id` = '$id'";
/* get the results & echo them */
$result = mysql_query($query)
or die ("Couldn't execute query.")
/* display fields */
echo "$itemname";
Am I missing something?
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Displaying each record in its own webpage
Yes, a semicolon ;raquelm wrote:Am I missing something?
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: Displaying each record in its own webpage
Got it, and it works perfectly, thanks!