Link to home
Start Free TrialLog in
Avatar of adamssap
adamssapFlag for Afghanistan

asked on

Passing row id into a url to display row data in new page

Hi:

I am new to php programming.  I have a php page which displays data from the database in the form of a table.  In the table I have link.  

What I want is click on the link in the table row and display the row data in another page.

Thanks,

     User generated image
Avatar of dsacker
dsacker
Flag of United States of America image

You can easily make the link as follows:
He said at <a href="myReadMorePage.html" target="ReadMorePage">read more...</a>

Open in new window


That way, it will open up in it's own window (or separate tab), AND if they click on it again, it will simply refresh in the same window (or tab).
Avatar of adamssap

ASKER

I am sorry, I think I was not clear in my question.  I have a link already, but the link must open a new page wihin the same windows and display the row data from the database, which includes more fields.  
The link should be more like:

<a href="MyDetailsPage.php?RowId=<? echo $rowId ?>">read more...</a>

Then on the MyDetailPage.php, use the querystring value of RowId to pull the information.
Do you have an example?

Thanks,
in you code, where you are looping through and printing all the rows, add the row id to the href's target. Then create the details page that makes the database call for ONLY that row's data and displays it. If you can create the grid display, you can create the details display.
code example:
foreach($variable1 as $value){
echo "<a href="MyDetailsPage.php?RowId=$value">read more...</a>";
}

Open in new window

I got the idea.  As I said, I am new to php.  An example will be greatly appreciated.

Thanks.
Here is a pretty straight-forward how to on the topic. It will walk you through step-by-step: http://www.siteground.com/tutorials/php-mysql/database_connection.htm
When you click on the link read more, can you give the URL of that page? And please dont post redundant questions.

https://www.experts-exchange.com/questions/27294255/Link-to-open-database-record-details-in-web-page.html
ASKER CERTIFIED SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks a ton.