MySQL Advanced Query
2 posts by 2 authors in: Forums > CMS Builder
Last Post: May 27, 2010 (RSS)
By (Deleted User) - May 27, 2010
Just a quick question... I am building a site where users log in and upload various listings in a table called 'listings_editor'. For each listing record, I require them to enter a unique listing id number for the listing. What I would like to do is create another table for users to submit additional data about any of their listings, and I want them to be able to select from a list which one of their listings they are submitting additional info for. I am using the MySQL query feature for this, and so far, I have:
SELECT listing_number
FROM `<?php echo $TABLE_PREFIX ?>listings_editor`
This gives me a list of all listing numbers in the 'listings_editor' table. What I want to do is add a filter so that only the listing numbers for the current user are displayed. My thought is to do the following:
SELECT mls_number
FROM `<?php echo $TABLE_PREFIX ?>ad_copy_editor`
WHERE createdByUserNum = $userNum
The problem is, I don't know how the user number is stored and accessed across the CMS system for reference. Any help would be appreciated!
Thanks!
PS. All the users uploading listings are given "Author" access to 'listings_editor'
SELECT listing_number
FROM `<?php echo $TABLE_PREFIX ?>listings_editor`
This gives me a list of all listing numbers in the 'listings_editor' table. What I want to do is add a filter so that only the listing numbers for the current user are displayed. My thought is to do the following:
SELECT mls_number
FROM `<?php echo $TABLE_PREFIX ?>ad_copy_editor`
WHERE createdByUserNum = $userNum
The problem is, I don't know how the user number is stored and accessed across the CMS system for reference. Any help would be appreciated!
Thanks!
PS. All the users uploading listings are given "Author" access to 'listings_editor'
Re: [cjnovak] MySQL Advanced Query
By Dave - May 27, 2010
Hi cjnovak,
This took me a little while to look up! Try this:
SELECT mls_number
FROM `<?php echo $TABLE_PREFIX ?>ad_copy_editor`
WHERE createdByUserNum = <?php echo $CURRENT_USER['num'] ?>
Note that when you refer to undocumented program internals there's always a chance it may break or change when you upgrade to future versions (although it's pretty unlikey the global will).
Hope that helps!
This took me a little while to look up! Try this:
SELECT mls_number
FROM `<?php echo $TABLE_PREFIX ?>ad_copy_editor`
WHERE createdByUserNum = <?php echo $CURRENT_USER['num'] ?>
Note that when you refer to undocumented program internals there's always a chance it may break or change when you upgrade to future versions (although it's pretty unlikey the global will).
Hope that helps!
Dave Edis - Senior Developer
interactivetools.com
interactivetools.com