Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 306
  • Last Modified:

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,

     view
0
adamssap
Asked:
adamssap
1 Solution
 
dsackerContract ERP Admin/ConsultantCommented:
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).
0
 
adamssapAuthor Commented:
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.  
0
 
strickddCommented:
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.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
adamssapAuthor Commented:
Do you have an example?

Thanks,
0
 
strickddCommented:
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.
0
 
shdwmageCommented:
code example:
foreach($variable1 as $value){
echo "<a href="MyDetailsPage.php?RowId=$value">read more...</a>";
}

Open in new window

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

Thanks.
0
 
strickddCommented:
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
0
 
PranjalShahCommented:
When you click on the link read more, can you give the URL of that page? And please dont post redundant questions.

http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/HTML/Q_27294255.html
0
 
hieloCommented:
assuming that every record in your db has a unique id, then generate:
<a href="details.php?id={$row['id']}">read more...</a>

then on detail.php all you need is:
<?php

if( isset($_GET['id']) && !empty($_GET['id']) )
{
  mysql_connect('localhost','username','password') or die( mysql_error() );
  mysql_select_db('databaseName') or die( mysql_error() );
  $sql='SELECT * FROM TableName WHERE id='.mysql_real_escape_string($_GET['id']);
  $result=mysql_query($sql) or die('Unable to execute <br />'. htmlentities($sql,ENT_QUOTES). '<br />'. mysql_error() );

  while($row=mysql_fetch_assoc($result) ){
    //assuming you have a description field
    echo $row['description'];
  }
}
exit;
?>
0
 
adamssapAuthor Commented:
Thanks a ton.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now