where/filter records using URL string

28 posts by 3 authors in: Forums > CMS Builder
Last Post: August 17, 2010   (RSS)

By s2smedia - August 13, 2010

I have a site set up that is basically 1 pg website shell... then depending what member/user you are..

ex:
http://www.clubambassadors.org/pages/index.php?num=2
http://www.clubambassadors.org/pages/index.php?num=3

it displays different content...

my issue is the way I have it above now limits only CONTENT that is num=3 to display..

somehow need something in the URL to say display records from table_name, num=3 and table_name, CreatedbyUsernum=5

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

By Chris - August 13, 2010

Hi s2smedia,

How about something like this?

$where = '';
if (@$_REQUEST['num']) {
mysql_escapef('num = ?', @$_REQUEST['num']);
}
else {
mysql_escapef('createdByUserNum = ?', @$_REQUEST['createdByUserNum']);
}

list($theRecords, $theMetaData) = getRecords(array(
'tableName' => @$_REQUEST['table_name'],
'where' => $where,
));
$theRecord = @$theRecords[0]; // get first record

// show error message if no matching record is found
if (!$theRecord) {
header("HTTP/1.0 404 Not Found");
print "Record not found!";
exit;
}


Is that how you wanted CreatedbyUsernum=5 to work? To display the first record with CreatedbyUsernum=5? Or did you want the page to turn into a list page if that's supplied?

I hope this helps! Please let me know if you have any questions.
All the best,
Chris

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

By Chris - August 13, 2010

Hi s2smedia,

I think you might be better off with a different page if one use case displays a single record while a different use case lists multiple records. That said it would still be possible to do this. Please post the complete PHP source code for your page and I'll show you how.
All the best,
Chris

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

By s2smedia - August 13, 2010

There's only one not listed as a list. But I can certainly make all setup as a list and do it that way

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

By s2smedia - August 13, 2010

I will post code

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

By s2smedia - August 13, 2010

<?php header('Content-type: text/html; charset=utf-8'); ?>




BELOW IS THE CONTENT I NEED TO SHOW ..ex. num=4

<?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($accountsRecords, $accountsMetaData) = getRecords(array(
'tableName' => 'accounts',
'limit' => '1',
));
$accountsRecord = @$accountsRecords[0]; // get first record

?>

BELOW IS CONTENT I NEED TO BE DISPLAYED in created byNUM

<?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($eventsRecords, $eventsMetaData) = getRecords(array(
'tableName' => 'events',
));

?>
<?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($newsRecords, $newsMetaData) = getRecords(array(
'tableName' => 'news',
'perPage' => '4',
));

?>

BELOW CONTENT I NEED TO DISAY ALL NO MATTER WHO NUM OR CREATEDNUM

<?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($banner_managerRecords, $banner_managerMetaData) = getRecords(array(
'tableName' => 'banner_manager',
'limit' => '2',
'orderBy' => 'RAND()',
));

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title><?php echo $accountsRecord['club_name'] ?> | Club Ambassadors</title>
<link href="css/main.css" rel="stylesheet" type="text/css" />
<link href="SpryAssets/SpryTabbedPanels.css" rel="stylesheet" type="text/css" />
<link href="css/smoothcalendar.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="as/popupwindow.as"></script>
<script src="SpryAssets/SpryTabbedPanels.js" type="text/javascript"></script>
<script type="text/javascript" src="js/mootools-1.2.1-core-nc.js"></script>
<script type="text/javascript" src="js/smoothcalendar.js"></script>
<script src="Scripts/swfobject_modified.js" type="text/javascript"></script>
<script type="text/javascript">

window.addEvent('domready', function(){
var date = new Date("<? print(Date("l F d, Y")); ?>");
var smoothCalendar = new SmoothCalendar("calendar", date);
});

</script>

<style type="text/css">
#calendar {
width:373px;
margin: 0px auto;
}
</style>
<style type="text/css">
.day_content_with_event {
background-color: <?php echo $accountsRecord['color_1'] ?>;
cursor : pointer;

z-index: 500;
display: block;
overflow: hidden;
}
.smoothcalendar_listItem_mouseover {
cursor : pointer;
padding : 5px 5px;
margin-bottom : 2px;
background-color : #333;
color : <?php echo $accountsRecord['color_1'] ?>;
}

.day_content_with_event_mouseover {
background-color: <?php echo $accountsRecord['color_1'] ?>;
border : 2px solid <?php echo $accountsRecord['color_2'] ?>;
cursor : pointer;

}
.smoothcalendar #fullDateText {
text-transform: uppercase;
margin-bottom: 20px;
font-size: 140%;
color : <?php echo $accountsRecord['color_1'] ?>;
}
.current_date {
font-size: 10pt;
font-weight: bold;
line-height: 2.3em;
color : <?php echo $accountsRecord['color_1'] ?>;
}
</style>
<script type="text/javascript">
<!--
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a.indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a;}}
}
//-->
</script>
</head>

<body onload="MM_preloadImages('images/menu_ov_r1_c6.gif')">
<table width="922" border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<td colspan="2" align="right" valign="top" style="padding:5px 0px 5px 0px" id="login">Welcome Back [First Name]! <a href="myaccount.php" style="color:<?php echo $accountsRecord['color_1'] ?>">My Account</a> | <a href="#" style="color:<?php echo $accountsRecord['color_1'] ?>">Log Out</a></td>
</tr>
<tr>
<td colspan="2"><table width="922" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="4"><img src="images/header_r1_c1.gif" width="922" height="18" /></td>
</tr>
<tr>
<td width="2" align="left" valign="top" style="background-image:url(images/header_r2_c1.gif); background-repeat:repeat-y"><img src="images/header_r2_c1.gif" width="2" height="71" /></td>
<td width="203" align="left" valign="middle" style="background-image:url(images/header_r2_c3.gif); background-repeat:repeat-x; background-color:#F7F5F6; padding:0px 10px 0px 20px">
<?php foreach ($accountsRecord['logo'] as $upload): ?>
<a href="index.php?num=<?php echo $accountsRecord['num'] ?>"><a href="index.php?num=<?php echo $accountsRecord['num'] ?>"><img src="http://www.clubambassadors.org/<?php echo $upload['urlPath'] ?>" alt="<?php echo $accountsRecord['club_name'] ?>" width="205" border="0" /></a></a>
<?php endforeach ?>
</td>
<td width="715" align="center" valign="middle" style="background-image:url(images/header_r2_c3.gif); background-repeat:repeat-x; background-color:#F7F5F6"><?php include("includes/menu.php"); ?></td>
<td width="2" align="left" valign="top" style="background-image:url(images/header_r2_c5.gif); background-repeat:repeat-y"><img src="images/header_r2_c5.gif" width="2" height="71" /></td>
</tr>
<tr>
<td colspan="4"><img src="images/header_r3_c1.gif" width="922" height="19" /></td>
</tr>
</table></td>
</tr>

<tr>
<td width="260" align="left" valign="top" style="padding:5px 0px 0px 0px"><a href="<?php echo $accountsRecord['payment_gateway_link'] ?>" target="_blank"><img src="images/makepayment.gif" alt="Make A Payment" width="254" height="92" border="0" /></a></td>
<td width="662" align="right" valign="top" style="padding:5px 0px 0px 0px"><?php foreach ($banner_managerRecords as $record): ?>
<?php foreach ($record['banner_upload'] as $upload): ?>
<?php if ($record['banner_type'] != 'Header Banner (662 x 92)') { continue; } ?>
<a href="<?php echo $record['banner_link'] ?>" target="_blank"><img src="<?php echo $upload['urlPath'] ?>" alt="<?php echo $record['banner_name'] ?>" width="662" height="92" border="0" /></a
><?php endforeach ?>

<?php endforeach ?></td>
</tr>
<tr>
<td width="260" align="left" valign="top" colspan="2" style="padding:5px 0px 0px 0px"><object id="FlashID" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="922" height="28">
<param name="movie" value="newsTicker.swf" />
<param name="quality" value="high" />
<param name="wmode" value="transparent" />
<param name="swfversion" value="9.0.45.0" />
<!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you don’t want users to see the prompt. -->
<param name="expressinstall" value="Scripts/expressInstall.swf" />
<!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. -->
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="newsTicker.swf" width="922" height="28">
<!--<![endif]-->
<param name="quality" value="high" />
<param name="wmode" value="transparent" />
<param name="swfversion" value="9.0.45.0" />
<param name="expressinstall" value="Scripts/expressInstall.swf" />
<!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. -->
<div>
<h4>Content on this page requires a newer version of Adobe Flash Player.</h4>
<p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" width="112" height="33" /></a></p>
</div>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object></td>

</tr>
<tr>
<td colspan="2" align="left" valign="top"><table width="922" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="500" height="500" rowspan="3" align="left" valign="top" style="padding:5px 8px 8px 0px"><div id="TabbedPanels1" class="TabbedPanels">
<ul class="TabbedPanelsTabGroup">
<li class="TabbedPanelsTab1" tabindex="0"><img src="images/blank.gif" width="116" height="33" /></li>
<li class="TabbedPanelsTab2" tabindex="0"><img src="images/blank.gif" width="75" height="33" /></li>
<li class="TabbedPanelsTab3" tabindex="0"><img src="images/blank.gif" width="85" height="33" /></li>
<li class="TabbedPanelsTab4" tabindex="0"><img src="images/blank.gif" width="121" height="33" /></li>
<li class="TabbedPanelsTab5" tabindex="0"><img src="images/blank.gif" width="122" height="33" /></li>
</ul>
<div class="TabbedPanelsContentGroup">
<div class="TabbedPanelsContent">
<div id="filterbar">Filter by Teams:
<label>
<select name="select" id="select">
<option value="Select One" selected="selected">Select One</option>
<option value="U12 Boys">U12 Boys</option>
<option value="U12 Girls">U12 Girls</option>
<option value="U13 Boys">U13 Boys</option>
<option value="U13 Girls">U13 Girls</option>
<option value="U14 Boys">U14 Boys</option>
<option value="U14 Girls">U14 Girls</option>
<option value="U15 Boys">U15 Boys</option>
<option value="U15 Girls">U15 Girls</option>
<option value="U16 Boys">U16 Boys</option>
<option value="U16 Girls">U16 Girls</option>
<option value="U17 Boys">U17 Boys</option>
<option value="U17 Girls">U17 Girls</option>
<option value="U18 Boys">U18 Boys</option>
<option value="U18 Girls">U18 Girls</option>
</select>
</label>
</div>
<?php foreach ($newsRecords as $record): ?>
<div id="feedbox"><b style="font-size:16px; color:<?php echo $accountsRecord['color_2'] ?>; font-style:italic">8.20.10</b>
<div style="color:<?php echo $accountsRecord['color_1'] ?>; font-size:20px; font-weight:bold; padding:0px 0px 5px 0px">HEADLINE</div>
<div style="line-height:17px; height:110px; padding:0px 0px 10px 0px"><?php foreach ($record['file_upload'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" alt="" height="110" align="left" style="border:2px; border-color:#<?php echo $accountsRecord['color_1'] ?>" />

<?php elseif ($upload['isImage']): ?>
<img src="<?php echo $upload['urlPath'] ?>" height="110" alt="" align="left" />

<?php else: ?>
<img src="images/doc.jpg" width="65" height="60" align="left" /><a href="<?php echo $upload['urlPath'] ?>"><b style="font-size:12px; color:<?php echo $accountsRecord['color_2'] ?>; font-style:italic">View File</b> <?php echo $upload['filename'] ?></a><br/>

<?php endif ?>
<?php endforeach ?>
<?php echo $record['content'] ?>
<a href="<?php echo $record['_link'] ?>" style="color:<?php echo $accountsRecord['color_1'] ?>; font-size:10px">Click Here</a></div>
<div id="tagfooter">Tagged: <?php echo join(', ', getListLabels('news', 'tag', $record['tag'])); ?></div>
</div>
<?php endforeach ?>

<?php if ($newsMetaData['invalidPageNum']): ?>
Results page '<?php echo $newsMetaData['page']?>' not found, <a href="<?php echo $newsMetaData['firstPageLink'] ?>">start over &gt;&gt;</a>.<br/><br/>
<?php elseif (!$newsRecords): ?>
No records were found!<br/><br/>
<?php endif ?>

</div>


<div class="TabbedPanelsContent"><div id="filterbar">Filter by Teams:
<label>
<select name="select" id="select">
<option value="Select One" selected="selected">Select One</option>
<option value="U12 Boys">U12 Boys</option>
<option value="U12 Girls">U12 Girls</option>
<option value="U13 Boys">U13 Boys</option>
<option value="U13 Girls">U13 Girls</option>
<option value="U14 Boys">U14 Boys</option>
<option value="U14 Girls">U14 Girls</option>
<option value="U15 Boys">U15 Boys</option>
<option value="U15 Girls">U15 Girls</option>
<option value="U16 Boys">U16 Boys</option>
<option value="U16 Girls">U16 Girls</option>
<option value="U17 Boys">U17 Boys</option>
<option value="U17 Girls">U17 Girls</option>
<option value="U18 Boys">U18 Boys</option>
<option value="U18 Girls">U18 Girls</option>
</select>
</label>
</div>
<?php foreach ($newsRecords as $record): ?>
<div id="feedbox"><b style="font-size:16px; color:<?php echo $accountsRecord['color_2'] ?>; font-style:italic">8.20.10</b>
<div style="color:<?php echo $accountsRecord['color_1'] ?>; font-size:20px; font-weight:bold; padding:0px 0px 5px 0px">HEADLINE</div>
<div style="line-height:17px; height:110px; padding:0px 0px 10px 0px"><?php foreach ($record['file_upload'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" alt="" height="110" align="left" style="border:medium; border-color:#<?php echo $accountsRecord['color_1'] ?>" />

<?php elseif ($upload['isImage']): ?>
<img src="<?php echo $upload['urlPath'] ?>" height="110" alt="" align="left" />

<?php else: ?>
<a href="<?php echo $upload['urlPath'] ?>"><b style="font-size:16px; color:<?php echo $accountsRecord['color_2'] ?>; font-style:italic">View File</b><?php echo $upload['filename'] ?></a><br/>

<?php endif ?>
<?php endforeach ?>
<?php echo $record['content'] ?>
<a href="<?php echo $record['_link'] ?>" style="color:<?php echo $accountsRecord['color_1'] ?>; font-size:10px">Click Here</a></div>
<div id="tagfooter">Tagged: <?php echo join(', ', getListLabels('news', 'tag', $record['tag'])); ?></div>
</div>
<?php endforeach ?>

<?php if ($newsMetaData['invalidPageNum']): ?>
Results page '<?php echo $newsMetaData['page']?>' not found, <a href="<?php echo $newsMetaData['firstPageLink'] ?>">start over &gt;&gt;</a>.<br/><br/>
<?php elseif (!$newsRecords): ?>
No records were found!<br/><br/>
<?php endif ?>
</div>
<div class="TabbedPanelsContent"><div id="filterbar">Filter by Teams:
<label>
<select name="select" id="select">
<option value="Select One" selected="selected">Select One</option>
<option value="U12 Boys">U12 Boys</option>
<option value="U12 Girls">U12 Girls</option>
<option value="U13 Boys">U13 Boys</option>
<option value="U13 Girls">U13 Girls</option>
<option value="U14 Boys">U14 Boys</option>
<option value="U14 Girls">U14 Girls</option>
<option value="U15 Boys">U15 Boys</option>
<option value="U15 Girls">U15 Girls</option>
<option value="U16 Boys">U16 Boys</option>
<option value="U16 Girls">U16 Girls</option>
<option value="U17 Boys">U17 Boys</option>
<option value="U17 Girls">U17 Girls</option>
<option value="U18 Boys">U18 Boys</option>
<option value="U18 Girls">U18 Girls</option>
</select>
</label>
</div>
<?php foreach ($newsRecords as $record): ?>
<div id="feedbox"><b style="font-size:16px; color:<?php echo $accountsRecord['color_2'] ?>; font-style:italic">8.20.10</b>
<div style="color:<?php echo $accountsRecord['color_1'] ?>; font-size:20px; font-weight:bold; padding:0px 0px 5px 0px">HEADLINE</div>
<div style="line-height:17px; height:110px; padding:0px 0px 10px 0px"><?php foreach ($record['file_upload'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" alt="" height="110" align="left" style="border:medium; border-color:#<?php echo $accountsRecord['color_1'] ?>" />

<?php elseif ($upload['isImage']): ?>
<img src="<?php echo $upload['urlPath'] ?>" height="110" alt="" align="left" />

<?php else: ?>
<a href="<?php echo $upload['urlPath'] ?>"><b style="font-size:16px; color:<?php echo $accountsRecord['color_2'] ?>; font-style:italic">View File</b><?php echo $upload['filename'] ?></a><br/>

<?php endif ?>
<?php endforeach ?>
<?php echo $record['content'] ?>
<a href="<?php echo $record['_link'] ?>" style="color:<?php echo $accountsRecord['color_1'] ?>; font-size:10px">Click Here</a></div>
<div id="tagfooter">Tagged: <?php echo join(', ', getListLabels('news', 'tag', $record['tag'])); ?></div>
</div>
<?php endforeach ?>

<?php if ($newsMetaData['invalidPageNum']): ?>
Results page '<?php echo $newsMetaData['page']?>' not found, <a href="<?php echo $newsMetaData['firstPageLink'] ?>">start over &gt;&gt;</a>.<br/><br/>
<?php elseif (!$newsRecords): ?>
No records were found!<br/><br/>
<?php endif ?></div>
<div class="TabbedPanelsContent"><div id="filterbar">Filter by Teams:
<label>
<select name="select" id="select">
<option value="Select One" selected="selected">Select One</option>
<option value="U12 Boys">U12 Boys</option>
<option value="U12 Girls">U12 Girls</option>
<option value="U13 Boys">U13 Boys</option>
<option value="U13 Girls">U13 Girls</option>
<option value="U14 Boys">U14 Boys</option>
<option value="U14 Girls">U14 Girls</option>
<option value="U15 Boys">U15 Boys</option>
<option value="U15 Girls">U15 Girls</option>
<option value="U16 Boys">U16 Boys</option>
<option value="U16 Girls">U16 Girls</option>
<option value="U17 Boys">U17 Boys</option>
<option value="U17 Girls">U17 Girls</option>
<option value="U18 Boys">U18 Boys</option>
<option value="U18 Girls">U18 Girls</option>
</select>
</label>
</div>
<?php foreach ($newsRecords as $record): ?>
<div id="feedbox"><b style="font-size:16px; color:<?php echo $accountsRecord['color_2'] ?>; font-style:italic">8.20.10</b>
<div style="color:<?php echo $accountsRecord['color_1'] ?>; font-size:20px; font-weight:bold; padding:0px 0px 5px 0px">HEADLINE</div>
<div style="line-height:17px; height:110px; padding:0px 0px 10px 0px"><?php foreach ($record['file_upload'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" alt="" height="110" align="left" style="border:medium; border-color:#<?php echo $accountsRecord['color_1'] ?>" />

<?php elseif ($upload['isImage']): ?>
<img src="<?php echo $upload['urlPath'] ?>" height="110" alt="" align="left" />

<?php else: ?>
<a href="<?php echo $upload['urlPath'] ?>"><b style="font-size:16px; color:<?php echo $accountsRecord['color_2'] ?>; font-style:italic">View File</b><?php echo $upload['filename'] ?></a><br/>

<?php endif ?>
<?php endforeach ?>
<?php echo $record['content'] ?>
<a href="<?php echo $record['_link'] ?>" style="color:<?php echo $accountsRecord['color_1'] ?>; font-size:10px">Click Here</a></div>
<div id="tagfooter">Tagged: <?php echo join(', ', getListLabels('news', 'tag', $record['tag'])); ?></div>
</div>
<?php endforeach ?>

<?php if ($newsMetaData['invalidPageNum']): ?>
Results page '<?php echo $newsMetaData['page']?>' not found, <a href="<?php echo $newsMetaData['firstPageLink'] ?>">start over &gt;&gt;</a>.<br/><br/>
<?php elseif (!$newsRecords): ?>
No records were found!<br/><br/>
<?php endif ?></div>
</div>
</div></td>
<td width="394" height="393" align="left" valign="top" style="padding:5px 0px 3px 0px"><table width="393" border="0" cellpadding="0" cellspacing="0" >
<tr>
<td align="left" valign="top"><img src="images/calendar_header.gif" width="393" height="35" /></td>
</tr>
<tr>
<td height="350" align="left" valign="top" id="calendar2">
<div id="calendar">
<?php foreach ($eventsRecords as $record): ?>
<div class="<?php echo date("D, M j, Y g:i:s", strtotime($record['date'])) ?>" title="<?php echo $record['title'] ?>">
<?php echo $record['content'] ?><br /><br />
<?php echo join(' | ', getListLabels('events', 'tag', $record['tag'])); ?>
</div>
<?php endforeach ?>

</div>
<?php foreach ($eventsRecords as $record): ?>
<div style="margin:10px">
<div style="font-size:16px; color:<?php echo $accountsRecord['color_1'] ?>; font-style:italic"><?php echo date("n.j.y", strtotime($record['date'])) ?></div>
<div style="font-size:13px; color:#4C4446"><a href="<?php echo $record['_link'] ?>" style="color:<?php echo $accountsRecord['color_1'] ?>; text-decoration:underline"><?php echo $record['title'] ?></a></div>
</div>
<?php break; ?>
<?php endforeach ?>


</td>
</tr>
</table></td>
</tr>
<tr>
<td align="left" valign="top"><a href="http://www.facebook.com/pages/Club-Ambassadors/287517719903?ref=search" target="_blank"><img src="images/img_r1_c1.jpg" alt="Become a Fan on Facebook!" width="198" height="100" border="0" /></a><a href="http://twitter.com/ClubAmbassadors" target="_blank"><img src="images/img_r1_c2.jpg" alt="Follow Us On Twitter!" width="196" height="100" border="0" /></a></td>
</tr>
<tr>
<td align="left" valign="top" style="padding:3px 0px 8px 0px">
<?php foreach ($banner_managerRecords as $record): ?>
<?php if ($record['banner_type'] != 'Side Banner (394 x 201)') { continue; } ?>
<?php foreach ($record['banner_upload'] as $upload): ?>
<a href="<?php echo $record['banner_link'] ?>" target="_blank"><img src="<?php echo $upload['urlPath'] ?>" alt="<?php echo $record['banner_name'] ?>" width="394" height="201" border="0" /></a
><?php endforeach ?>

<?php endforeach ?>
</td>
</tr>
</table></td>
</tr>
<?php include("includes/footer.php"); ?>
</table>
<script type="text/javascript">
<!--
var TabbedPanels1 = new Spry.Widget.TabbedPanels("TabbedPanels1");
swfobject.registerObject("FlashID");
//-->
</script>
</body>
</html>

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

By s2smedia - August 13, 2010

I just noticed if I type:

http://clubambassadors.org/pages/index.php?club_name=CASL


it displays everything correctly except now just needs to on display records (news, events...etc) created by num

the above club_name=CASL is record 3

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

By Chris - August 16, 2010 - edited: August 16, 2010

Hi s2smedia,

Oh! I misunderstood you earlier.

How about this:

<?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($accountsRecords, $accountsMetaData) = getRecords(array(
'tableName' => 'accounts',
'where' => mysql_escapef('num = ?', @$_REQUEST['owner']),
'limit' => '1',
));
$accountsRecord = @$accountsRecords[0]; // get first record

// load records
list($eventsRecords, $eventsMetaData) = getRecords(array(
'tableName' => 'events',
'where' => mysql_escapef('createdByUserNum = ?', @$_REQUEST['owner']),
));

// load records
list($newsRecords, $newsMetaData) = getRecords(array(
'tableName' => 'news',
'perPage' => '4',
'where' => mysql_escapef('createdByUserNum = ?', @$_REQUEST['owner']),
));

// load records
list($banner_managerRecords, $banner_managerMetaData) = getRecords(array(
'tableName' => 'banner_manager',
'limit' => '2',
'orderBy' => 'RAND()',
));

?>


Then you can create URLs like this: index.php?owner=3

Does this help? Please let me know if you have any questions.
All the best,
Chris

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

By s2smedia - August 16, 2010

makes sense.. but im getting this error:

MySQL Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?) ORDER BY dragSortOrder' at line 3