/    Sign up×
Community /Pin to ProfileBookmark

duplicate results

I have a page that lists events for our stores. These events are kept in a database. If I have 2 events for some of my stores, when displaying them on the page, I get:

“bullet” first event
“bullet” first event again
second event (notice no bullet icon)

What I want isL

“bullet” first event
“bullet” second event

Here is the code for my loop when looping through the events for a particular store number:

[code]
<?php
// now go through and see if there’s anything in $event for this
// store and for each thing we find, spit out a row telling about
// it….
$this_store = intval($key);

for ($i=0; $i< @count($events); $i++) {
// don’t even look at the data if it’s not for the location
// we’re currently displaying
if ($this_store != intval($events[$i][locn]) ) {
continue;
}

$_type = $events[$i][event_type];
switch ($_type) {
case “flu_clinic”:
$_name = “Flu Clinic”;
break;
case “diabetes_clinic”:
$_name = “Diabetes Clinic”;
break;
case “health_beauty_expo”:
$_name = “Baltimore Health & Beauty Expo”;
break;
case “six_flags”:
$_name = “Six Flags Magic Mountain Season Passes”;
break;
}

list ($start_year, $start_month, $start_day) = split (‘[/.-]’, $events[$i][event_start_date]);
$_date=date(‘F j, Y’,mktime(0,0,0,$start_month,$start_day,$start_year));
list ($end_year, $end_month, $end_day) = split (‘[/.-]’, $events[$i][event_end_date]);
$_end_date=date(‘F j, Y’,mktime(0,0,0,$end_month,$end_day,$end_year));

$_start_time = trim($events[$i][event_start_time]);
$_end_time = trim($events[$i][event_end_time]);
$_url = trim($events[$i][event_url]);
$_additional_info = trim($events[$i][additional_info]);

if (($_name == “Flu Clinic”) || ($_name == “Diabetes Clinic”)) {
$event_info = “$_name coming to this store on $_date”;
} elseif ($_name == “Baltimore Health & Beauty Expo”) {
$event_info = “Visit the $_name May 9 & 10 at the Baltimore Convention Center.”;
} elseif ($_name == “Six Flags Magic Mountain Season Passes”) {
$event_info = “Purchase your $_name for a special price of only $54.99 at this Rite Aid location now through May 2nd.”;
}

if (($_start_time > 0) && ($_end_time > 0)) {
if (($_name != “”) && ($_name != “Baltimore Health & Beauty Expo”) && ($_name != “Six Flags Magic Mountain Season Passes”)) {
$event_info .= ” from $_start_time to $_end_time.”;
} else {
$event_info .= “From $_start_time to $_end_time.”;
}
}

if (strlen($_additional_info) > 0 ) {
$_additional_info = str_replace(“<event_start_date>”, $_date, $_additional_info);
$_additional_info = str_replace(“<event_end_date>”, $_end_date, $_additional_info);
$_additional_info = str_replace(“<event_start_time>”, $_start_time, $_additional_info);
$_additional_info = str_replace(“<event_end_time>”, $_end_time, $_additional_info);
$event_info .= ” $_additional_info “;
}

if (strlen($_url) > 0 ) {
if (substr($_url,0,7) == “http://”) {
$event_info .= ” Click <a href=” . log_and_redirect($_url) . ” target=’new’>here</a> for more info. “;
} else {
$event_info .= ” Click <a href=’$_url’>here</a> for more info. “;
}
}

print (”
<tr><td colspan=5 width=100% bgcolor=’#f5f5f5′ valign=’middle’ align=’left’><table width=100% cellpadding=0 cellspacing=0 border=0><tr><td valign=top>
<img src=’/layout/search_icon_general.gif’ width=’19’ height=’19’ border=’0′ align=’left’></td><td valsign=top>
<font color=’#666666′> $event_info </font></td></tr></table>
</td></tr>
“);

}

?>

[/code]

Thanks!!!

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@JonaFeb 23.2005 — [font=trebuchet ms]Try using "<=" instead of "<" in your [/font][font=courier new]for[/font][font=trebuchet ms] loop.[/font]
Copy linkTweet thisAlerts:
@jrthor2authorFeb 24.2005 — nope, didn't change my results. I added a third event for 1 of my stores, and the third event prints out correct:

"bullet" first event

"bullet" first event

second event

"bullet" third event

???
Copy linkTweet thisAlerts:
@jrthor2authorFeb 24.2005 — I fixed it. For some reason, when I commented out my switch statement, it seemed to work.

Thanks
Copy linkTweet thisAlerts:
@JonaFeb 24.2005 — [font=trebuchet ms]Well, that's a lot of code, so I threw in a guess (a common error), but you didn't tell me that any entries followed the second bulleted one. ? Anyway, glad you got it figured out. Remember, that much code usually scares people away immediately, and they never really even read your thread.[/font]
×

Success!

Help @jrthor2 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...