close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

displaying records from other table.

Thread began 9/18/2014 3:56 pm by Kumel | Last modified 9/21/2014 12:17 pm by Kumel | 2360 views | 13 replies |

Kumel

displaying records from other table.

I have two tables created.
Screenshots of tables are attached.

Now i have a artwork detail page where artwork tables field are shown. this page is created from dataaasist.

Now while viewing the artwork_details page it displays all data properly.
Im trying to show artist name linked with artist id in artwork table.
For this i m using Inner Join. i m not much familiar with this but somehow managed to get it done thru this: http://www.w3schools.com/sql/sql_join.asp

Now results are showing up on recordset while testing it. but all records are shwon.
Now i want to only show 1 record while filtering artist id of the open page.

Sign in to reply to this post

Kumel

This post is similar to that of this post : http://www.webassist.com/forums/posts.php?id=34735

As per this : http://www.w3schools.com/sql/sql_join.asp
all results are shown. How to show only one result? main page file attached.

This is the recordset
SELECT artworks.id, artists.name
FROM artworks INNER JOIN artists ON artworks.artist_id=artists.id

Now by this all record shown. I want only one to be shown which is open.

ie name from artists table linked from artist_id from artwork table.

Regards

Attached Files
artworks_Detail.php
Sign in to reply to this post

CraigRBeta Tester

If your recordset is working ok, but you want to limit the number of rows returned, you need to add the LIMIT keyword to the SELECT statement

SELECT artworks.id, artists.name
FROM artworks INNER JOIN artists ON artworks.artist_id=artists.id
LIMIT 1

Sign in to reply to this post

Kumel

Its not working yet.
I want to display artist name of artwork detail page thru artist it in artwork table
There are two tables 1: "artwork" wic has id, artist_id, art_name,description n etc. Artist id is stored from another table called "artist".
artist table has id,name,bio & img.

Now in artwork detail page i wanna showcase artistname thru artist_id wic is linked here.


Regards

Sign in to reply to this post

CraigRBeta Tester

I took a look at your attached php page, noticed you have 3 recordsets on there, not sure why.

if you upload a copy or an image of your artists and artwork tables i will take a look, (I cannot see the screenshot of the tables you say are in post #1)

Sign in to reply to this post

Kumel

I have attached screenshots of database on on #1 post!

There are 3 recordset yes.
1st RS is WADAartworks which came from dataassist. which displays columns from artwork table.
2nd RS is artistname which was just for testing. which i have removed now.
3rd RS is lol which is still present & it is to link to artist_id of artwork table.

I have attached files again.

Attached Files
artworks_Detail.php
Sign in to reply to this post

CraigRBeta Tester

Ok, I can now see the images of the table structure you posted. Thanks

I see this is the detail page, and you will have passed a get parameter to it, but I also notice the recordset called WADAartworks has 3 filter parameters, two of which are using the same value, and also a session value

Please explain what you are expecting to see in the results.

eg are you clicking on the name of a piece of art on a list and wanting to display its details on this page ?

if this is the case, then this is what i would do...

drop the lol recordset, you don't need it

change the WADAartworks recordset to accept a single parameter and add the inner join here, (to display the artist name)

change the select statement to

$query_WADAartworks = sprintf("SELECT artworks.id, artists.name, artworks.artname, artworks.img, artworks.description, artworks.medium, artworks.art_size, artworks.art_style, artworks.year, artworks.price, artworks.category FROM artworks INNER JOIN artists ON artworks.artist_id=artists.id WHERE artworks.id = %s", GetSQLValueString($Paramid_WADAartworks, "int"));



change the displayed value in the table for the artist to reflect that this informaton is now coming from the WADAartworks recordset

Sign in to reply to this post

Kumel

Woo! That was awesome & easy.
Thanks a lot.

I have a another small doubt hope it can be solved here. :)

Well in everything is working fine now. Now in artwork_detail page al the data are shown perfectly, i have a nagivation panel which is like this:

<!-- portfolio nav -->
<ul class="portfolio-nav">
<li>
<a class="portfolio-prev" href="portfolio-item2.html">
<i class="fa fa-angle-left"></i>
<span>Prev</span>
</a>
</li>
<li>
<a class="portfolio-close" href="#">
<i class="fa fa-times"></i>
<span>Close</span>
</a>
</li>
<li>
<a class="portfolio-next" href="portfolio-item2.html">
<i class="fa fa-angle-right"></i>
<span>Next</span>
</a>
</li>
</ul>
<!--/ portfolio nav -->




So lets say a person is view a artwork_detail.php?id=1, if he click next it must take him to next id which is available & if he click prev then prev id! (ie in this case last id available like 32 in my case.)


Regards

Sign in to reply to this post

CraigRBeta Tester

I think there are 2 pieces of logic you need to apply to your navigation,

1. knowing the current id, you need to increment the id+ 1 when clicking on next, -1 when clicking on prev

so, for example, the link would use the current $_GET parameter and add / subtract from that

2. if you are wanting to loop from the last record to the first, without coming to the end, you will also need to compare the number of rows in the recordset, ($totalRows_WADAartworks). if this value = $_GET parameter, then your link should point to id number one.

(same logic, in reverse if you want to go from first record to the last, ie if $_GET parameter -1 = 0 then your link should point to id number $totalRows_WADAartworks.

This code should be flexible enough so that adding new images will not break it

Sign in to reply to this post

Kumel

Oh!
Well i got what you said. But please can you guide me on how this is done on given above codes.

I have attached the page as well.

Attached Files
artwork-details.php
Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...