whats wrong with my 2 functions?
Posted: Mon Oct 05, 2009 9:37 am
i am desigining a search engine which uses PHP and XML. i have come up with a long code and after a long day of testing i am beginning to realise that the problem might be with my two functions below. however i cant seem to figure out what exactly is wrong. if you can pick up some errors on my 2 functions below i will appreciate hearing from you. thank you and if u need more info please let me know.
function 1
function 2
function 1
Code: Select all
function startElement($parser, $name, $attrs)
{
global $to;
global $from;
global $show;
global $results;
if (empty($_GET['start'])) {
$start=1;
} else {
$start=$_GET['start'];
}
global $maxNum;
global $tag;
$tag = $name;
if ($name == "RECORD") {
global $hit;
$hit = array("index" => "$attrs");
}
if ($name == "SEARCHRESULTS") {
global $hits;
$hits = $attrs["HITS"];
echo '<tr><td colspan="5" height="10px"> </td></tr>';
echo '<tr><td></td><td colspan="3">';
if ($hits != 0) {
if (($start+$maxNum-1) > $hits) {
$end=$hits;
} else {
$end=$start+$maxNum-1;
}
print("<p>$show $start $to $end $from $hits $results.</p>");
} else {
global $nothing_found;
echo $nothing_found;
}
echo '</td><td></td></tr>';
echo '<tr><td colspan="5" height="10px"> </td></tr>';
echo '<tr><td></td><td height="1" class="line" colspan="3"></td><td></td></tr>';
echo '<tr><td colspan="5"> </td></tr>';
}
}Code: Select all
function endElement($parser, $name)
{
global $imageArray;
global $hit;
if ($name == "RECORD") {
$score = number_format(($hit["SCORE"] * 100), 1, '.', " ");
print '<tr>
<td> </td>
<td align="left" valign="top">'
.'['.$score.'%] </td>'
. '<td>'
//------ . '<a href="' . $hit["VISIBLEPATH"] . '">';
if (empty($hit["TITLE"])) {
$path=$hit["VISIBLEPATH"];
ereg ("/(.*)/(.*)", $path, $regs);
print $regs[2];
} else {
print $hit["TITLE"];
}
print '</a> (' . $hit["LASTCHANGED"] . ')</td>';
$contentType=strtoupper($hit["CONTENTTYPE"]);
if (isset($imageArray[$contentType])) {
//-----$content = '<img src="'.$imageArray[$contentType].'" alt="'.$contentType.'" />';
} else {
$content = " ";
}
print '<td>'. $content.'</td><td></td></tr>'
. '<tr>
<td></td>
<td colspan="3">'
.$hit["SUMMARY"]
. '</td><td></td></tr>';
print '<td></td><td colspan="3">'.substr($hit["VISIBLEPATH"], 0, 100) .'</td><td></td></tr>'
. '<tr><td colspan="5"> </td></tr>'
. '<tr><td></td><td height="1" class="line" colspan="3"></td><td></td></tr>'
. '<tr><td colspan="5"> </td></tr>';
}
}