close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Sql queries

Thread began 12/05/2011 6:44 am by Pardall1955 | Last modified 12/09/2011 2:57 pm by Pardall1955 | 1939 views | 7 replies |

Pardall1955

Sql queries

How do you pass parameters in a SQL query to receive the data in a display page.

Here is my scenario:

SELECT *
FROM table1 LEFT JOIN table2 ON table1.iID=table2.pID
WHERE iID = pID

============================================

It joins all the records from table1 to table2 but it only displays the first record. I can´t seem to get the parameter correct to display the proper record when is passed.

I´ve seen other scenarios like:

WHERE (iID = ?) or WHERE iID = 'pID's

But they don't work, what am I missing here.

thanks.

Sign in to reply to this post

Ian S

Using the dreamweaver recordset you should be able to pull that information back very easily.

Create a new recordset. Click Advanced

Then enter your query and enter the parameter as something like colname (the dreamweaver standard)

SELECT *
FROM table1 LEFT JOIN table2 ON table1.iID=table2.pID
WHERE pID = colname

Then create a new parameter by clicking the plus icon.

Give it a name. The name needs to match the parameter in the query so call it colname. Select the type of data. i.e Date, Text, Integer. Set a default value of -1 and then set a run time value. This can be a session variable or value from a previous recordset on the page.

And thats it!

Cheers
Ian

Sign in to reply to this post

Pardall1955

Using the dreamweaver recordset you should be able to pull that information back very easily.

Create a new recordset. Click Advanced

Then enter your query and enter the parameter as something like colname (the dreamweaver standard)

SELECT *
FROM table1 LEFT JOIN table2 ON table1.iID=table2.pID
WHERE pID = colname

Then create a new parameter by clicking the plus icon.

Give it a name. The name needs to match the parameter in the query so call it colname. Select the type of data. i.e Date, Text, Integer. Set a default value of -1 and then set a run time value. This can be a session variable or value from a previous recordset on the page.

============

Now, that worked, BUT... it only brought the first 3 records on the table.

I HAVE ALSO CREATED A LEFT JOIN ON THE LIST OF RECORDS PAGE with THE ipID WHICH IS THE FOREING KEY FOR THE TABLE2 (pID), AND THEY ALL SHOW UP ON THE LIST OR RECORDS PAGE ...(IS THAT WRONG???)

NOW WHEN I HAVE PASSED THE INITIAL rawURL enconde, I HAVE USED THE iID FROM THE TABLE1. IF I CHANGE THE rawURL enconde id to ipID NOTHING PASSES TO THE SECOND TABLE.

NOW I´M A BIT CONFUSED. HAVE I MADE MYSELF SOMEWHAT CLEAR... OR I AM CONFUSING YOU MORE???

MANY THANKS IN ADVANCE.

Sign in to reply to this post

Ian S

What three records did it bring back? Did they equate to the query criteria?

OR... are they the only three records that have values in the linked table - in which case your join might be incorrect.

Maybe an Inner Join might work better for you?

Its difficult to say exactly without seeing / knowing your database structure.

Cheers
Ian

Sign in to reply to this post

Pardall1955

THE FIRST 3 RECORD ON THE TABLE, BUT I THINK WHAT HAPPENS HERE IS THAT THERE ARE ONLY 3 RECORDS IN TABLE 2 AND IT ONLY LIKED THEM WITH TABLE1 WHICH HAS 20 RECORDS.

THAT´S VERY POSSIBLE.

MY REAL SCENARIO IS THIS.

I HAVE ON TABLE1 SEVERAL RECORDS(CHURCHES), IT MAY GO TO HUNDREDS PERHAPS AND THEN ONLY A FEW ON TABLE2, WITH ARE(PASTORS) AND WHEN I JOIN THEM i WANT TO BE ABLE TO SHOW CHURCHES WITH IT´S PASTORS NAME AND PHOTO ALONG WITH THE CHURCHES INFORMATION, THEN IF THE CLIENT WANTS TO SEE MORE OF PASTOR INFORMATION, I WANT TO LINK IT TO PASTOR´S PROFILE AND SHOW ALL OF IT´S INFORMATION, BY PASSING PARAMETES FROM ONE PAGE TO ANOTHER.

THANKS AGAIN.

Sign in to reply to this post

Jason ByrnesWebAssist

you may need to change the join type you are using. Maybe use a right join, or an inner join


to create links to the pastors profile, create the link to pass the pastors ID using a querystring variable, for example:

pastorProfile.php?id=23

then on the pastorProfile page, filter the recordset using the id querystring variable.

Sign in to reply to this post

Pardall1955

I ACTUALLY HAD TO PASS THE PARAMETER THROUGH 3 PAGES, THIS IS REALLY HOW IT WORKED FOR ME, SPENT MORE THAN 3 HRS TRYING TO FIGURE IT OUT. BUT WALLA...BUT ANYWAY THANKS FOR YOU HELP. BY THE WAY, WEBASSIST IS AWSOME, WITHOUT IT WOULD MAKE MY LIFE SO MUCH HARDER

===========================================
SELECT igrejas_adventistas.iID, igrejas_adventistas.iNome, igrejas_adventistas.iEndereco, igrejas_adventistas.iBairro, igrejas_adventistas.iCidade, igrejas_adventistas.iTipo, igrejas_adventistas.ipID, igrejas_adventistas.iSite, igrejas_adventistas.iFoto, pastores.pNome, pastores.pEndereco, pastores.pBairro, pastores.pCidade, pastores.pEstado, pastores.pCEP, pastores.pEmail, pastores.pTelefone, pastores.pCelular, pastores.ig1Nome, pastores.ig2Nome, pastores.ig3Nome, pastores.ig4Nome, pastores.ig5Nome, pastores.ig6Nome, pastores.ig7Nome, pastores.ig8Nome, pastores.ig9Nome, pastores.ig10Nome, pastores.pDescr, pastores.pFoto
FROM igrejas_adventistas, pastores
WHERE igrejas_adventistas.ipID = pastores.pID AND iID = colname

Sign in to reply to this post

Pardall1955

here is the link to the site page: asur=igrejas.php then click on the pastor image from the 2nd page.

Sign in to reply to this post

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...