Jump to content

retriving information from database


dannybrazil

Recommended Posts

Hello

i have a page that im queiring information from database and placing it in a table

then one colum represents something from the database one of the colums is "Title"(of a posting made by a user)

this "Title" is a link to another page that i want to display all the information that the user posted by adding to the link the ID from the database and "echo"-ing it in the second page

 

first is the code line used in the first page :

$link = "http://www.mywebsite.com/next.php?id=$id";

 

it all passed good and the address (of the second page) looks like that :

http://www.mywebpage.com/next.php?34

 

now i wanted to know how can i write a code that will help me to retrive all the information i need from the specific ID in the specific table in the DB ?

 

 

 

thanks

 

Link to comment
https://forums.phpfreaks.com/topic/98024-retriving-information-from-database/
Share on other sites

I'm not really sure what all you are trying to do.  I might need some more info, but the following is a select query that will return all the data associated with $id.

 

 

<?
//The following pulls the variable from the url of the second page.

$id = $_GET['id'];
//The following begins the select query
$result = mysql_query("SELECT * FROM (your db table name) WHERE (column name containing $id) = '$id'");
while ($row = mysql_fetch_array($result)){
//the following sets up the table that will display the data. The while loop will return all rows that have the //same $id.  Note that you should the name of the column where it says column name.  You can display as //many columns as the db table contains.

echo "<TR>";
echo "<TD>$row['column name']</TD>";
echo "<TD>$row['column name']</TD>";
echo "<TD>$row['column name']</TD>";
echo "<TD>$row['column name']</TD>";
echo "</TR>";
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.