So i have a results page that is taking an XML feed, based on search critera (zip code, program, and location)…however i dont know how to add the ability to show results based on DEGREE LEVEL too.
I have the XML feed going into an array and the array imploding. I’m fairly new to php so examples and any tips are greatly appreciated.
Let me know if this is enough information you need to help resolve.
Thank you,
<?php
$response = file_get_contents("http://www.xxxxx.com/page.php?id=1238&code=9dd46170bab569960ff4ae34fdb83f58&zip=$zip&career=$career&school_type=$school_type&program_type=$program_type");
$xml = simplexml_load_string($response);
$html = array(
'Online' => array(),
'Campus' => array(),
'Other' => array(),
);
foreach ($xml->capsule as $capsule) {
// Set $type var with ifs..
if ($type == 'Online') {
$capsule->city = 'Homestudy';
$capsule->state = '(Online Program)';
}
if (empty($capsule->city)) {
$capsule->city = 'Homestudy';
$capsule->state = '(Online Program)';
}
if (empty($capsule->state)) {
$capsule->city = 'Homestudy';
$capsule->state = '(Online Program)';
}
foreach($capsule->program as $key => $program) {
if (!empty($program_type) && $program_type != $program['program_type']) {
unset($capsule->program[$key]);
continue;
}
}
if (isset($capsule->campus['type'])) {
$type = trim($capsule->campus['type']);
}
else {
$type = 'Other';
}
$degree_level = "AS";
$program_list = null;
foreach($capsule->program as $program) {
$program_list .= '<span class="blue">' . '<li>' . $program['program_type_name'] . ''. '</span> -
<span class="green">' . $program . '</li></span>';
}
$html[$type][] = '
<div class="wrapper">
<div class="left_column"><a href="' . urldecode($capsule->link) . '&campaign_id=12616017&code=' . $source .''. '"><img src="' . urldecode($capsule->image) . ''. '" border="0" /></a></div>
<div align="center" class="central-colunm"><h2><b>' . urldecode($capsule->type) . '
<a href="' . urldecode($capsule->link) . '&campaign_id=12616017&code=' . $source .''. '">
' . urldecode($capsule->form_name) . ''. '-' . $capsule->city . ''. ' ' . $capsule->state . ''. '</a></b><br />
</h2></div>
<div class="right_column"><a href="' . urldecode($capsule->link) . '&campaign_id=12616017&code=' . $source .''. '"><a href="' . urldecode($capsule->link) . '&campaign_id=12616017&code=' . $source .''. '"><img src="images/learn_more.gif" border="0"
onmouseover="this.src=\\'images/learn_more_over.gif\\'"
onmouseout="this.src=\\'images/learn_more.gif\\'"></a></div>
<div class="central-colunm"><h4><a href="' . urldecode($capsule->link) . '&campaign_id=12616017&code=' . $source .''. '">DEGREE:(' . urldecode($program['program_type']) . ')</h4>
' . $program_list . '
</h4> <br /></div>
<div class="spacer"></div>
</div>
';
}
$ResultArray = array_slice($html['Online'], 0, 5);
//print_r($ResultArray);
//print_r($html);
print_r($program['program_type']);
if ($school_type == 'O') {
echo implode('<b>Online School</b>', $ResultArray);
echo $html['Online']['As'];
} else if ($school_type == 'C') {
print implode('<b>Campus School</b>' , $html['Campus']);
print implode('<b>Online School</b>' , $html['Online']);
}
?>
What i am looking to do is have a form drop down (degree_level), and basically have the search critera pull only proper results. Right now its currently pulling ALL degree levels. I need to zoom in one more step and result only degrees that was selected.
the part of the XML capsule (capsule = each result as a capsule), $program[‘program_type’] will give you like “AS,BA, BS, MS, PhD” etc.
So i need to have the abiltiy to filter those results, i hope i’ve covered as much as i can in order for you guys to udnerstand.
Also, this loads DEATHLY slow - i’ve tried switching from tables to div results, using array_slice to limit results (so its not pulling 100 results), i’ve tried optomizing the html code on the page - still no avail. Is this just a SLOW xml feed? or is there something wrong with my code, that’s slowing it down?
recap:
Need to have ability to sort by $degree_level ($program[‘program_type’] is what the XML calls it), ALSO the XML uses like BA and BS both meaning Bachelor’s Degree, can i have 1 drop down option mean both BS and BA?
if possible, optmoize to speed up.
Thank you guys in advance,
Joey