Make a query that makes a field a link to the entire row

10-08-03, 09:22 AM
|
 |
Aspiring Coder
|
|
Join Date: Oct 2003
Posts: 510
Thanks: 1
Thanked 1 Time in 1 Post
|
|
|
Make a query that makes a field a link to the entire row
I'm wondering if its possible to do this. My table has, lets say, 7 fields per row
( no problem ). I do a query that displays only 3 of those fields ( still no problem ). I want one of the 3 fields I display to act as a link, which will display all 7 fields in the same row the 3 fields came from ( thats the problem ). An example of why to do this would be, say, a book database. The original query ( 3 fields ) list the author, book title, and brief description, and the book title would act as a link, which when clicked would display ( perhaps go to another page? ) all 7 of the fields of that books row.
Say the table is set up as this...
id, author, book_title, brief_desc, description, submitted_by, date
Any suggestions?
|

10-08-03, 09:44 AM
|
|
Newbie Coder
|
|
Join Date: Sep 2003
Location: Toronto, Ontario
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
The easiest would just make the link go to another page with different results. Unless you wanted DHTML effects or a javascript popup window.
|

10-08-03, 10:32 AM
|
 |
Aspiring Coder
|
|
Join Date: Oct 2003
Posts: 510
Thanks: 1
Thanked 1 Time in 1 Post
|
|
Quote:
|
Originally Posted by Chroder
The easiest would just make the link go to another page with different results. Unless you wanted DHTML effects or a javascript popup window.
|
Make the name/link basically into a another query that would display the entire row? That would work, I'll give it a shot. Don't really want pop-ups if I can help it. Thnx for the idea. I had tried multiple tables in which one was supposed to link to the other, but I couldnt get it set up correctly.
|

10-08-03, 02:08 PM
|
|
Newbie Coder
|
|
Join Date: Sep 2003
Location: Toronto, Ontario
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Make a link to another page and in the query string include the id. Ex:
Then on the next page you can create a mySQL query to get the one specific row. Ex:
|

10-08-03, 03:42 PM
|
 |
Aspiring Coder
|
|
Join Date: Oct 2003
Posts: 510
Thanks: 1
Thanked 1 Time in 1 Post
|
|
Quote:
|
Originally Posted by Chroder
Make a link to another page and in the query string include the id. Ex:
Then on the next page you can create a mySQL query to get the one specific row. Ex:
|
I tried something just like that, but it was with 2 tables, and it wasnt working right. I was thinking of doing it exactly the way your talking about with one table. Let me see if I get this right in this example...
Lets say the first query displays this...
Author
Book Title
Brief Description
echo '<a href="displaydetails.php?id="'.$row['id'].'">See More</a>';
That link goes to a page called displaydetails.php, where it show the entire row.
Don't mean to sound repetitive of what you replied, just wanted to see if I got it right before I try it out. Thnx alot.
|

10-08-03, 04:10 PM
|
|
Newbie Coder
|
|
Join Date: Sep 2003
Location: Toronto, Ontario
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Yep, thats the idea. Of course, your $row['id'] is going to have to exist 
|

10-08-03, 05:01 PM
|
 |
Aspiring Coder
|
|
Join Date: Oct 2003
Posts: 510
Thanks: 1
Thanked 1 Time in 1 Post
|
|
Part of my code...
while ($i < $num):
$id=mysql_result($result,$i,"id"); (the field ID)
echo '<a href="listing.php?id="'.$row['id'].'">See It Here</a>'
Parse error: parse error, expecting `','' or `';''
on the line you gave me.
???
|

10-08-03, 06:21 PM
|
 |
Aspiring Coder
|
|
Join Date: Oct 2003
Posts: 510
Thanks: 1
Thanked 1 Time in 1 Post
|
|
I decided to try this as a song lyric database instead.
This is the pertinent php code to pull up the row id, artist name, and song title.
$query=("SELECT id,artist_name,song_title FROM artist WHERE artist_name LIKE '$searchartist' OR song_title LIKE '$searchtitle' OR category LIKE '$searchcategory'");
$result = mysql_query($query);
$num=mysql_num_rows($result);
$i = 0;
echo "<TABLE width=450 border=0 align=center cellpadding=4 cellspacing=0>
<tr>
<td width=30 align=center bgcolor=white><font face=verdana size=2><b>See It</b></font></td>
<td width=215><font face=verdana size=2><b>Artist</b></font></td>
<td width=215><font face=verdana size=2><b>Song Title</b></font></td></tr><tr>";
while ($i < $num):
$id=mysql_result($result,$i,"id");
$artist_name=mysql_result($result,$i,"artist_name" );
$song_title=mysql_result($result,$i,"song_title");
echo "<td bgcolor=white> '<a href="listing.php?id="'.$row['id'].'">See It Here</a>';</td><td bgcolor=white>$artist_name</td><td bgcolor=white>$song_title</td>";
echo "</tr>";
The link to go to the next page to display the row is where I keep getting a parse error...
Parse error: parse error, expecting `','' or `';''
Am i missing something?
|

10-09-03, 06:18 PM
|
 |
Aspiring Coder
|
|
Join Date: Oct 2003
Posts: 510
Thanks: 1
Thanked 1 Time in 1 Post
|
|
Got it working...thnx for the help
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|