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

Hi s2smedia,

Sorry about that. The code in red above should read "mysql_escapef(..." not "mysql_escape(...". I've edited my above post to be correct.
All the best,
Chris

By Chris - August 16, 2010

Hi s2smedia,

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?
All the best,
Chris

Re: [chris] where/filter records using URL string

By s2smedia - August 17, 2010

Yea its alittle confusing..

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

Hi,

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

Exactly..

club_name
Table Name: accounts


createdByUserNum
Table Names: news, events, fundraising, photos, videos, announcements

By Jason - August 17, 2010

Hi,

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

PERFECT!!!!!!

thanks sooo much

By s2smedia - August 17, 2010

ahh dont kill me.. one last question.. im pulling in data from a xml file for a news ticker.. it seems that it isnt being affected by the URL string.. is there maybe something special i have to place on the xml file php?

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

Hi,

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/