\n");
$result = pg_exec($connection, $query);
if($result)
{
$total_rows = pg_numrows($result);
if($linesperpage <= 0) $linesperpage = $total_rows;
$total_pages = (($total_rows - 1) / $linesperpage) + 1;
settype($total_pages, "integer");
switch($bsact)
{
case " < ":
$begin -= $linesperpage;
if($begin < 0) { $begin = 0; $page = 1; }
else $page--;
break;
case " > ":
$begin += $linesperpage;
if($begin > ($total_rows - $linesperpage))
{
$begin = $total_rows - $linesperpage;
$page = $total_pages;
}
else $page++;
break;
case ">>":
$begin = $total_rows - $linesperpage;
$page = $total_pages;
break;
default:
$begin = 0;
$page = 1;
break;
}
$last_row = $begin + $linesperpage;
if($last_row > $total_rows) $last_row = $total_rows;
print("\n");
print("\n");
print("\n");
print("\n");
print("\n");
print("\n");
print("\n");
print("\n");
// $url_arg = "&begin=$begin&page=$page&category=";
// $url_args .= urlencode($category);
// $url_args .= "&wordsearch=$wordsearch&wordoption=$wordoption&contactsearch=$contactsearch&contactoption=$contactoption";
print("
\n");
print(" |
\n");
for($row = $begin, $row_style=0; $row < $last_row; $row++, $row_style++)
{
$row_data = pg_fetch_row($result, $row);
if($row_data[0] != $previous_category)
{
if(isset($previous_category))
print("  |
\n");
$previous_category = $row_data[0];
print("\n");
// print(" |
\n");
$row_style = 0;
}
// else print("
|
\n");
if($row_data[1])
{
if($row_style & 1) print("");
else print("
");
print("");
print($row_data[1]);
print(" | ");
if($row_data[2]) print($row_data[2]);
}
else
{
if($row_style & 1) print(" |
");
else print("
");
print("");
if($row_data[2]) print($row_data[2]);
}
print(" |
\n");
if($row_style & 1) print("");
else print("
");
print("");
if($row_data[3]) print($row_data[3]);
print(" | ");
if($row_data[4]) print("$row_data[4], ");
if($row_data[5]) print("$row_data[5]");
if($row_data[6]) print(" $row_data[6]");
if($row_data[7]) print("-$row_data[7]");
print(" |
\n");
$num_phones = (pg_numfields($result) - 8) / 2;
for($phone = 0, $field = 8; $phone < $num_phones; $phone++, $field += 2)
{
if(($phone % 3) == 0)
{
if($row_style & 1) print("");
else print("
");
}
print("");
if($row_data[$field] && $row_data[$field+1])
print($row_data[$field] . " : " . $row_data[$field+1]);
else print(" ");
print(" | ");
if(($phone % 3) == 2) print("
\n");
}
}
print("
\n");
pg_freeresult($result);
}
else print("Search criteria yield no results.