Jump to content

displaying search results EG Country in BOLD


mackevin

Recommended Posts

Hey Everybody, I really hope that someone can help me here, I am stuck

I cannot get the actual search result to display BOLD in particular teh country parameter.

 

Can anybody please help me,

 

thanks in advance

the code is attached below

 

<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td valign="top"><?php
require_once "com/regexp.php";
$pagerows = 15;
$correct = array("key", "time", "type", "level", "sect", "loc", "ee", "p");
$parameters = array();
$cond = "(a.listid = b.listid)";
$parameters["key"] = "notset";
$parameters["time"] = "notset";
$parameters["type"] = "notset";
$parameters["level"] = "notset";
$parameters["sect"] = "notset";
$parameters["loc"] = "notset";
$parameters["ee"] = "notset";
$parameters["p"] = 1;
$keywords = array();
$errors = false;
$totalresults = 0;

reset($_GET);
while(list($k, $v) = each($_GET))
{
  if (in_array($k, $correct))
  {
    if ($k == "key")
    {
      $parameters[$k] = strip_tags($v);
    }
    else
    {
      $parameters[$k] = $v;
    }
  }
}
if ($parameters["key"] != "")
{
  $parameters["key"] = str_replace(",", " ", $parameters["key"]);
  $keywords = explode(" ", $parameters["key"]);
  $addFirst = true;
  $addOR = false;
  foreach($keywords as $k)
  {
    $k = trim($k);
    if (strlen($k) > 0)
    {
      if ($addFirst)
      {
        $cond .= " AND (";
        $addFirst = false;
      }
      if ($addOR)
        $cond .= " OR";
      else
        $addOR = true;
      $cond .= " listtitle like '%".$k."%' OR listempdesc like '%".$k."%' OR listskillstr like '%".$k."%'";
    }
  }
  if (!$addFirst)
    $cond .= ")";
}

if ($parameters["ee"] == 2)
  $cond .= " AND (listaa = 1)";
if ($parameters["ee"] == 3)
  $cond .= " AND (listaa = 0)";

if ($parameters["type"] != 0)
  $cond .= " AND (listtype = ".$parameters["type"].")";
  
if ($parameters["level"] != 0)
  $cond .= " AND (listlevel = ".$parameters["level"].")";
  
if ($parameters["sect"] != 0)
  $cond .= " AND (listsector = ".$parameters["sect"].")";
  
if ($parameters["loc"] == 2)
  $cond .= " AND (listcountry BETWEEN 4 AND 12)";
elseif ($parameters["loc"] == 3)
  $cond .= " AND (listcountry > 12)";
elseif ($parameters["loc"] > 3)
  $cond .= " AND (listcountry = ".$parameters["loc"].")";
  
$timecut = 0;
switch($parameters["time"])
{
  case "1" :
    $timecut = (time() - (60 * 60 * 24 * 7));
    break;
  case "2" :
    $timecut = (time() - (60 * 60 * 24 * 7 * 4));
    break;
}
$cond .= " AND (listdispdate > '".date("Y-m-d H:i:s", $timecut)."')";
$validstartdate = date("Y-m-d H:i:s", time() - (60*60*24*30));
$validenddate = date("Y-m-d H:i:s");
$cond .= " AND (listdispdate > '".$validstartdate."' AND listdispdate <= '".$validenddate."') AND (listactive = 1)";
?>
<h1>Search results:</h1>
<?php
if (!$g_db)
  db_connect();
if (!$g_db)
  echo "An error occurred while trying to execute your request, please trying again.";
else
{
  $nodisplay = false;
  $countries = array();
  $countries[] = "";$countries[] = "";$countries[] = "";
  $skilllevels = array();
  $jobtypes = array();
  $currencies = array();
  $sectors = array();
  $companies = array();
  $result = select_query(array("tblskilllevels"), array("skillleveltext"));
  if ($result == false || $result == -1)
  {
    echo mysql_error();
    $nodisplay = true;
  }
  else
  {
    while($row = mysql_fetch_assoc($result))
    {
      $skilllevels[] = $row["skillleveltext"];
    }
  }
  $result = select_query(array("tblcountry"), array("countryname"));
  if ($result == false || $result == -1)
  {
    echo mysql_error();
    $nodisplay = true;
  }
  else
  {
    while($row = mysql_fetch_assoc($result))
      $countries[] = $row["countryname"];
  }
  $result = select_query(array("tblcurrency"), array("curshort"));
  if ($result == false || $result == -1)
  {
    echo mysql_error();
    $nodisplay = true;
  }
  else
  {
    while($row = mysql_fetch_assoc($result))
      $currencies[] = $row["curshort"];
  }
  $result = select_query(array("tblworkxtype"), array("worxtypetext"));
  if ($result == false || $result == -1)
  {
    echo mysql_error();
    $nodisplay = true;
  }
  else
  {
    while($row = mysql_fetch_assoc($result))
      $jobtypes[] = $row["worxtypetext"];
  }
  $result = select_query(array("tblsector"), array("sectortext"));
  if ($result == false || $result == -1)
  {
    echo mysql_error();
    $nodisplay = true;
  }
  else
  {
    while($row = mysql_fetch_assoc($result))
      $sectors[] = $row["sectortext"];
  }
  $result = select_query(array("tblrecruiterdetails"), array("recid", "reccompany"));
  if ($result == false || $result == -1)
  {
    echo mysql_error();
    $nodisplay = true;
  }
  else
  {
    while($row = mysql_fetch_assoc($result))
      $companies["\"".$row["recid"]."\""] = $row["reccompany"];
  }
  $result = select_query(array("tbllistings as a", "tbllistingssum as b"), array("count(a.listid) as TOTAL"), $cond);
    if ($result == false || $result == -1)
  {
    echo mysql_error();
    $nodisplay = true;
  }
  else
  {
    $row = mysql_fetch_assoc($result);
    $totalresults = $row["TOTAL"];
  }
  $currentpage = (($parameters["p"] - 1) * $pagerows);
  $lastresult = (($currentpage + $pagerows) > $totalresults) ? $totalresults : $currentpage + $pagerows;
  if ($totalresults > 0)
    echo "Displaying ".($currentpage + 1)." - ".$lastresult." of ".$totalresults."<br>";
  $link = "main.php?usr=sek&lev=job&con=search&key=".$parameters["key"]."&time=".$parameters["time"];
  $link .= "&type=".$parameters["type"]."&level=".$parameters["level"]."&ampsect=".$parameters["sect"];
  $link .= "&loc=".$parameters["loc"]."&ee=".$parameters["ee"];
  if ($parameters["p"] > 1)
  {
    echo "<a href=\"".$link."\">&laquo</a> | ";
    echo "<a href=\"".$link."&p=".($parameters["p"]-1)."\">&lt</a> | ";
  }
  if ($lastresult < $totalresults)
  {
    echo "<a href=\"".$link."&p=".($parameters["p"]+1)."\">&gt</a> | ";
    $lastpage = (($totalresults % $pagerows) == 0) ? floor($totalresults / $pagerows)
                          : (floor($totalresults / $pagerows) + 1);
    echo "<a href=\"".$link."&p=".$lastpage."\">&raquo</a>";
  }
  $cond .= " LIMIT ".$currentpage.", ".$pagerows;
  $result = select_query(array("tbllistings as a", "tbllistingssum as b"), array("*"), $cond);
  if ($result == false || $result == -1)
  {
    echo mysql_error();
    $nodisplay = true;
  }
  echo "<br>";
  if ($nodisplay)
    echo "No result found matching your criteria";
  else
  {
    echo "<table cellpadding=\"0\" cellspacing=\"0\">";
    $counter = $currentpage + 1;
    while($row = mysql_fetch_assoc($result))
    {
      $row["listtype"] = $jobtypes[$row["listtype"]-1];
      $row["listlevel"] = $skilllevels[$row["listlevel"]-1];
      $row["listcurrency"] = $currencies[$row["listcurrency"]-1];
     $row["listcountry"] = $countries[$row["listcountry"]-1];
      $row["listsector"] = $sectors[$row["listsector"]-1];
      $row["listdispdate"] = date("Y-m-d", strtotime($row["listdispdate"]));
      $row["recid"] = $companies["\"".$row["recid"]."\""];
      displayListing($row, $counter++);
    }
    echo "</table>";
    echo "<hr>";
  }
}
?></td>
    <td width="185" align="center" valign="top"> </td>
  </tr>
</table>

Link to comment
Share on other sites

There's rather a lot of code there. Any chance of you narrowing down where you think the problem lies?

 

Perhaps it's just me, but i'm not entirely sure what the problem is either - perhaps showing us the current output and expected output would be useful too.

Link to comment
Share on other sites

sorry am new to this  this is the output part of the code, this is where I feel I could add the <B> to the country output

 

 

echo "<br>";

  if ($nodisplay)

    echo "No result found matching your criteria";

  else

  {

    echo "<table cellpadding=\"0\" cellspacing=\"0\">";

    $counter = $currentpage + 1;

    while($row = mysql_fetch_assoc($result))

    {

      $row["listtype"] = $jobtypes[$row["listtype"]-1];

      $row["listlevel"] = $skilllevels[$row["listlevel"]-1];

      $row["listcurrency"] = $currencies[$row["listcurrency"]-1];

    $row["listcountry"] = $countries[$row["listcountry"]-1];

      $row["listsector"] = $sectors[$row["listsector"]-1];

      $row["listdispdate"] = date("Y-m-d", strtotime($row["listdispdate"]));

      $row["recid"] = $companies["\"".$row["recid"]."\""];

      displayListing($row, $counter++);

    }

    echo "</table>";

    echo "<hr>";

 

 

Im not to sure if this will work but attached is the file out put now

Picture 2.png

 

and what I would like isPicture 3.png

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.