where/filter records using URL string
28 posts by 3 authors in: Forums > CMS Builder
Last Post: August 17, 2010 (RSS)
By Chris - August 16, 2010
Sorry about that. The code in red above should read "mysql_escapef(..." not "mysql_escape(...". I've edited my above post to be correct.
Chris
Re: [chris] where/filter records using URL string
By s2smedia - August 16, 2010
here what im trying to accomplish...
I would create an account (club) when I do i enter a club name for each one...
then I give that club admin there acount login... now they will be loging in to CMS and just being able to add new records "Author"
so when going to the URL.. i need it to desigante 2 things:
1. index.php?club_name=CLUB
&
2. index.php?createdbyUser=3
canit look something like this?
index.php?createdbyUser=3&club_name=CLUB
this way it will only show the account info (club logo, contact info) for club_name "CLUB"
then it would also deisplay all news, event records etc.. that were created by that club_name user "3"
By Chris - August 16, 2010
I'm confused. Aren't you specifying the exact same information with club_name=CLUB and createdbyUser=3 ? Why do you need to specify both?
Chris
Re: [chris] where/filter records using URL string
By s2smedia - August 17, 2010
the reaso I need to specify the club_name=CLUB seprately than the created by num is because
I will creating the clubs... so all clubs will be created by my NUM
after I create the club.. another person will be logging in using the club login I created.. and then they will be creating news, events etc... so those createdbynum will be fine to use... its just using another way to designate what clud (Account Data) to display
By Jason - August 17, 2010
Are certain records being pulled out based on club_name and others based on createdByUserNum? Which tables are using which?
Thanks.
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] where/filter records using URL string
By s2smedia - August 17, 2010
club_name
Table Name: accounts
createdByUserNum
Table Names: news, events, fundraising, photos, videos, announcements
By Jason - August 17, 2010
If your URL looks like this: index.php?club_name=CLUB NAME&createdByUserNum=NUM
Then you can select your records like this:
// load records
list($accountsRecords, $accountsMetaData) = getRecords(array(
'tableName' => 'accounts',
'where' => mysql_escapef('club_name = ?', @$_REQUEST['club_name']),
'allowSearch' => false,
'limit' => '1',
));
$accountsRecord = @$accountsRecords[0]; // get first record
// load records
list($eventsRecords, $eventsMetaData) = getRecords(array(
'tableName' => 'events',
));
// load records
list($eventsRecords, $eventsMetaData) = getRecords(array(
'tableName' => 'fundraising',
));
// load records
list($eventsRecords, $eventsMetaData) = getRecords(array(
'tableName' => 'photos',
));
// load records
list($eventsRecords, $eventsMetaData) = getRecords(array(
'tableName' => 'video',
));
// load records
list($eventsRecords, $eventsMetaData) = getRecords(array(
'tableName' => 'announcements',
));
// load records
list($newsRecords, $newsMetaData) = getRecords(array(
'tableName' => 'news',
'perPage' => '4',
));
// load records
list($banner_managerRecords, $banner_managerMetaData) = getRecords(array(
'tableName' => 'banner_manager',
'allowSearch' => false,
'limit' => '2',
'orderBy' => 'RAND()',
));
CMS Builder will automatically use the createdByUserNum variable to only select records from news,events,fundraising,photos,videos, and announcements that were created by the user number in the URL. As long as all these tables don't have a field called club_name, this should work fine. You may have to change some of the names to match what you have in your database.
Hope this helps.
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] where/filter records using URL string
By s2smedia - August 17, 2010
thanks sooo much
By s2smedia - August 17, 2010
right now its just this:
<?php echo '<?xml version="1.0" encoding="utf-8"?>'; ?>
<?php
// load viewer library
$libraryPath = 'login/lib/viewer_functions.php';
$dirsToCheck = array('XXX);
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }
// load records
list($announcementsRecords, $announcementsMetaData) = getRecords(array(
'tableName' => 'announcements',
));
?>
<newsTicker>
<main>
<maxCharCount>300</maxCharCount>
<newsTimer>10</newsTimer>
<textColor>0x333333</textColor>
<overColor>0x999999</overColor>
</main>
<items>
<?php foreach ($announcementsRecords as $record): ?>
<item>
<text><?php echo $record['headline'] ?></text>
<date>NEWS</date>
<time>ALERT</time>
<link><?php echo $record['_link'] ?></link>
<window>_parent</window>
</item>
<?php endforeach ?>
</items>
</newsTicker>
By Jason - August 17, 2010
How are you getting that information onto your index.php page?
Having createdByUserNum in your url string should affect how records are being pulled from the announcements table.
Let me know.
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/