close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Trying to fudge some code!! :)

Thread began 2/15/2011 12:39 pm by iamdan356160 | Last modified 2/22/2011 10:03 am by Jason Byrnes | 4226 views | 15 replies |

iamdan356160

Trying to fudge some code!! :)

Hi all,
I'm not a PHP expert in any shape or form... mainly find myself guessing my way thru stuff (due to the fact that you can with the help of WebAssist plugins :)...
Anyway... got this line of code in my script...

$query_rs_discountdetails = "SELECT * FROM Discounts WHERE disc_code = $row_WADAUsers['User_DiscCode']";

which is causing a syntax error. Im trying to get the SQL statement to use a binding from another recordset. Any ideas on how to get this to work??
Regards,

Dan

Sign in to reply to this post

Jason ByrnesWebAssist

correct syntax would be:
$query_rs_discountdetails = "SELECT * FROM Discounts WHERE disc_code = ". $row_WADAUsers['User_DiscCode'];


make sure that the rs_discountdetails code is on the page before it is used in this query.

Sign in to reply to this post

iamdan356160

Hi Jason,
Thank you for the quick reply... this sorted the syntax error... But, I've not been able to actually achieve my desired goal... maybe you could help with that?...

I've built a list / results page, using DataAssist... I've added some icons into the list, with a cool tooltip that displays more details. Each record in the list is a record from the "Users" table, and contains a field called 'User_DiscCode'. I also have a table called 'Discounts' that contains a field called 'disc_code'. I basically want to be able to display the Discount info (from the 'discount' table) in the tool tip, if 'disc_code' matches the users 'User_DiscCode'. How could I this and make it work for all records in the list?

Does that make sense?

Sign in to reply to this post

Jason ByrnesWebAssist

Edit the main WADAUsers recordset for the page to use a join query to get the related data from the Discounts table:



SELECT Users.*, Discounts.disc_code
FROM Users
INNER JOIN Discounts
ON Users.User_DiscCode = Discounts.disc_code

This code will go in place of the SELECT ... FROM portion of the recordset, if there is a where clause, or order by clause, leave that in place untouched

this way the related disc_code will be returned for each record.

Sign in to reply to this post

iamdan356160

Hi Jason,
Thanks for the reply... Two things though...

1. I've added your code... but now the list is only showing users that have used a discount code!?

2. Where can I find the bindings that the 'INNER JOIN' would have brought in?

Thanks in advance! :)

Dan

Sign in to reply to this post

Jason ByrnesWebAssist

try using LEFT JOIN then


the binding for the nee column returned from the reocrdset should be on the Bindings panel.

Sign in to reply to this post

iamdan356160

Hi Jason,
The LEFT JOIN has appeared to work (All users appear in the list now).

But I'm not getting the 'Discount' table details in the bindings panel!?

What PHP would I need to type, to get the fields to appear in the list?

Thanks in advance,

Dan

Sign in to reply to this post

Jason ByrnesWebAssist

close Dreamweaver, then open the Windows Explorer or Macintosh Finder. Browse to the location of your Dreamweaver site files, and delete the _mmServerScripts folder.

Sign in to reply to this post

iamdan356160

Hi Jason,
I've tried that, but I'm still getting the same issue. I still can't see the bindings for the discounts table... I've attached a screenshot. Have I got the SQL statement correct? Is there anything else that could be causing this?

Dan

Sign in to reply to this post

Jason ByrnesWebAssist

the bindings will be under the WADAUsers recordset.


Expand that recordset to find the binding for the Discounts.disc_code column.

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