473,394 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

PHP Detail page help

I have developed a search facility on my site which is now working as intended and produces pages of relevent records from the search. On the resuly pages I have created href links for records that I wish to use to forward users to a detailed html page for their item. I am planning on doing this using adetail.php script where the id will be taken and used to identify the corresponding file. Only problem is I've never done this before do I just post the id in and change the header part accordingly?
Oct 3 '07 #1
4 2001
Atli
5,058 Expert 4TB
Hi.

If I am understanding you correctly, you only need to create a <a> link that points to your addetail.php, including the ID of the item you want to view.
Then, in the addetail.php, you use the $_GET super-global to get the ID and get the item information.

For example: (doing this in one page, but you get the idea)
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. # Get and validate the itemID
  3. $itemID = $_GET['itemID'];
  4. if($itemID != abs($itemID) or $itemID <= 0) {
  5.   echo("<p>Item ID is invalid.</p>");
  6. }
  7. else {
  8.   # Get and display data from MySQL
  9.   $result = mysql_query("SELECT * FROM myTable WHERE id = $itemID");
  10.   while($row = mysql_fetch_assoc($result)) {
  11.     echo "<b>Item details:</b><br>";
  12.     foreach($row as $key => $value) {
  13.       echo " - $key = $value<br>";
  14.     }
  15.   }
  16. }
  17. ?>
  18.  
  19. <a href="thisPage.php?itemID=1">Show details</a>
  20.  
Oct 3 '07 #2
Hi.

If I am understanding you correctly, you only need to create a <a> link that points to your addetail.php, including the ID of the item you want to view.
Then, in the addetail.php, you use the $_GET super-global to get the ID and get the item information.

For example: (doing this in one page, but you get the idea)
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. # Get and validate the itemID
  3. $itemID = $_GET['itemID'];
  4. if($itemID != abs($itemID) or $itemID <= 0) {
  5.   echo("<p>Item ID is invalid.</p>");
  6. }
  7. else {
  8.   # Get and display data from MySQL
  9.   $result = mysql_query("SELECT * FROM myTable WHERE id = $itemID");
  10.   while($row = mysql_fetch_assoc($result)) {
  11.     echo "<b>Item details:</b><br>";
  12.     foreach($row as $key => $value) {
  13.       echo " - $key = $value<br>";
  14.     }
  15.   }
  16. }
  17. ?>
  18.  
  19. <a href="thisPage.php?itemID=1">Show details</a>
  20.  

It is kind of what I'm aiming for. In my previuos post you were kind enough to help out with also, I had a search form accessing my database to extract all relevent records for criteria. I have a link established for each search output which is..
Expand|Select|Wrap|Line Numbers
  1. echo "<div id=\"right\"><img src=\"".$info['image']."\"><a href=\"detail.php\">".$info['title']."</a></div>\n";
  2.  
but it's linking it through detail.php I need to establish. What to put in detail.php?
Oct 3 '07 #3
Atli
5,058 Expert 4TB
If you'd put the code I posted (leave out the link tho) into your details.php, you could change your links to this, in order to get it working:
Expand|Select|Wrap|Line Numbers
  1. echo "<div id=\"right\"><img src=\"".$info['image']."\"><a href=\"detail.php?itemID=". $info['id']. "\">".$info['title']."</a></div>\n";
  2.  
Assuming that your $info array includes the ID of the item to show.
Oct 3 '07 #4
is it possible to use header location command for this purpose? I already have made up html detail pages and would like to use them.
Oct 5 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Raphael Gluck | last post by:
Hi Everyone I am having some problems with a master detail page i have set up to catalogue brochures from my site. On my master page www.tripakltd.com/brochures.asp users are invited to select...
4
by: John Baker | last post by:
Hi: Stuck on another thing. On a report I am creating, I want to make the detail section one line vertically. However, in design view, I click on the page Footer Bar ,grab it with the "double...
1
by: tesc | last post by:
I'm sure this is pretty simple but I'm having a hard time with it. I have a report that has multiple columns and have to change some of the titles in the page header. As a result, the titles don't...
0
by: Peter | last post by:
On my main page I have a datagrid with a hyperlink column. As soon as I click on the hyperlink a detailed screen should appear where I collect the fields of the selected record. However, I have...
0
by: Benster | last post by:
Hi there, i'm trying to figure out a way to build a master/detail page set (e.g for news items) with next/previous navigation on the detail page. This sounds easier than it appears to be for my...
0
by: Arnold | last post by:
Hi Everyone; In a report, I've essentially recreated a paper sheet by adding various labels--name, date, problem, year, Progress Notes, etc.--and horizontal lines (people have traditionally...
1
by: fixedpower | last post by:
I have an Access 2000 DB for a financial company. I have the table structure completed, but I am having trouble with the report. Basically, I have a Client tbl, a StockShares tbl, and a...
2
by: tbee | last post by:
I have a multicolumn report with one group header section. The header has "new col or row before and after" to make sure the header always starts on a new line. Basically I have two problems: 1....
0
by: Hank | last post by:
I have created hundreds of reports in Access 2000 and most of them use running sums. I have one report that adds the last detail at the bottom of the page - twice. This happens when the detail is...
1
by: Ganesh | last post by:
Hi There, I've a GridView contains hyperlink in each row. If user click that link it will open another detail page with all information. After seeing the details user can go back to search...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.