shireen_shabbir
asked on
Search Engine in PHP?
I am trying to create a search engine on my site (Recruitment) where candidates can look for jobs.
I am getting the results. But I want to limit the number of jobs that can be viewed per page. I have decided on four jobs per page.
I am therefore able to get the number of pages that need to be generated. But What do I do after that?
I want to create it something like the search in Altavista.com
Looks something like this:
[<< Prev] 1 2 3 4 5 etc.. [Next >>]
Awaiting your reply..
Shireen:)
I am getting the results. But I want to limit the number of jobs that can be viewed per page. I have decided on four jobs per page.
I am therefore able to get the number of pages that need to be generated. But What do I do after that?
I want to create it something like the search in Altavista.com
Looks something like this:
[<< Prev] 1 2 3 4 5 etc.. [Next >>]
Awaiting your reply..
Shireen:)
Which database do you use ?
ASKER
MySQL
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I am in a little trouble here. I dont know how to explain so I am putting a bit of the code:
<table width=100% cellspacing=0 cellpadding=0>
<tr>
<td width="15%"></td>
<td bgcolor="#67A0BA" width="70%">
<?
$mysql_link=mysql_connect( "localhost ", "root", "");
mysql_select_db("Recruit", $mysql_link);
if ($Title == "0" & $Skill == '0' & $Location == "0" & $JobPreference == "0")
{
$query="select * from tblJob";
}
if ($Title == "0" & $Skill != '0' & $Location == "0" & $JobPreference == "0")
{
$query="select * from tblJob, tblJobSkill where ";
$query2="select SkillID from tblSkill where SkillName='".$Skill."'";
$mysql_res=mysql_query($qu ery2, $mysql_link);
$num=mysql_fetch_row($mysq l_res);
$query .= "tblJob.JobID=tblJobSkill. JobID and tblJobSkill.SkillID='$num[ 0]' and tblJob.Title like '%%' and tblJob.Location like '%%' and tblJob.JobPreference like '%%'";
}
else
{
$query="select * from tblJob where ";
if ($Title == "0")
{
$query .= "tblJob.Title like '%%' and ";
}
else
{
$query .= "tblJob.Title='".$Title."' and ";
}
if ($Location == "0")
{
$query .= "tblJob.Location like '%%' and ";
}
else
{
$query .= "tblJob.Location='".$Locat ion."' and ";
}
if ($JobPreference == "0")
{
$query .= "tblJob.JobPreference like '%%'";
}
else
{
$query .= "tblJob.JobPreference='".$ JobPrefere nce."'";
}
}
$mysql_result=mysql_query( $query, $mysql_link);
$numrow=mysql_num_rows($my sql_result );
print("\n<form id=jobresult method=post action=\" \">\n");
print("<BR>");
print("<table width=75% cellspacing=0 cellpadding=0><tr><td class=td><b>Check if desired</b></td><td class=td align=center><b>Job Details</b></td></tr></tab le>");
$numview=4;
$i=$lowernum;
while (($row=mysql_fetch_row($my sql_result )) & ($i < $highernum))
{
print("\n<BR>\n");
print("\n<table class=tableborder width=100% border=3><tr><td>");
print("\n<table border=0 cellspacing=0 cellpadding=0 width=100%>\n");
print("\n<tr><td align=center> <input type=checkbox size=15 value=$row[0]> </td>\ n");
print("\n<td class=boldsmallfont>Job Title: </td>\n");
print("\n<td class=td colspan=2>$row[1]</td><td> </td></tr> \n");
print("\n<tr><td></td><td class=boldsmallfont>Positi on: </td>\n");
print("\n<td class=td colspan=2>$row[2]</td><td> </td></tr> \n");
print("\n<tr><td></td><td class=boldsmallfont>Job Preference: </td>\n");
print("\n<td class=td colspan=2>$row[3]</td><td> </td></tr> \n");
print("\n<tr><td></td><td class=boldsmallfont>Locati on: </td>\n");
print("\n<td class=td colspan=2>$row[4]</td><td> </td></tr> \n");
print("\n<tr><td colspan=4> </td></tr> \n");
print("\n<tr><td></td><td class=boldsmallfont>Last Date for Applications: </td>\n");
$query2="select date_format('$row[13]','d/ m/y')" ;
$mysql_result2=mysql_query ($query2, $mysql_link);
$rec=mysql_fetch_row($mysq l_result2) ;
print("\n<td class=td>$rec[0]</td>");
print("<td align=center>");
print("<table border=3><tr><td align=center class=td bordercolor=#aaaaaa bgcolor=#aaaaaa>");
print("<a href=# onClick=\"window.open('des cription.p hp3?JobID= $row[0]', 'Description', 'scrollbars,width=700 height=500');\">");
print("Show Details</a></td></tr></tab le></td></ tr>");
print("\n<tr><td colspan=4> </td></tr> \n");
print("\n</table>\n");
print("\n</td></tr>\n</tab le>\n");
$i += 1;
}
if ($numrow > 4)
{
print("<table align=center cellspacing=0 cellpadding=5><tr>");
print("<td class=td>Pages</td>");
$numpage=$numrow/$numview;
$numex=$numrow%$numview;
if ($numex > 0)
{
$numpage += 1;
}
for ($j=1; $j <= $numpage; $j++)
{
print("<td><A href='jobresult.php3?lower num=$lower num&higher num=$highe rnum&Title =$Title&Lo cation=$Lo cation&Ski ll=$Skill& JobPrefere nce=$JobPr eference'> $j</A></td >");
}
print("</tr></table>");
}
?>
</form>
</td>
<td width=15%></td>
</tr>
</table>
************************** **********
When I add "Limit" to the Select statement, it does not give me the total number of results. In this case, it just gives me four records.
So I have tried to do that by adding it to the while statement. Yet it doesnt work..
Please help me out..
Awaiting ur reply
&
Thanks in adv.
<table width=100% cellspacing=0 cellpadding=0>
<tr>
<td width="15%"></td>
<td bgcolor="#67A0BA" width="70%">
<?
$mysql_link=mysql_connect(
mysql_select_db("Recruit",
if ($Title == "0" & $Skill == '0' & $Location == "0" & $JobPreference == "0")
{
$query="select * from tblJob";
}
if ($Title == "0" & $Skill != '0' & $Location == "0" & $JobPreference == "0")
{
$query="select * from tblJob, tblJobSkill where ";
$query2="select SkillID from tblSkill where SkillName='".$Skill."'";
$mysql_res=mysql_query($qu
$num=mysql_fetch_row($mysq
$query .= "tblJob.JobID=tblJobSkill.
}
else
{
$query="select * from tblJob where ";
if ($Title == "0")
{
$query .= "tblJob.Title like '%%' and ";
}
else
{
$query .= "tblJob.Title='".$Title."'
}
if ($Location == "0")
{
$query .= "tblJob.Location like '%%' and ";
}
else
{
$query .= "tblJob.Location='".$Locat
}
if ($JobPreference == "0")
{
$query .= "tblJob.JobPreference like '%%'";
}
else
{
$query .= "tblJob.JobPreference='".$
}
}
$mysql_result=mysql_query(
$numrow=mysql_num_rows($my
print("\n<form id=jobresult method=post action=\" \">\n");
print("<BR>");
print("<table width=75% cellspacing=0 cellpadding=0><tr><td class=td><b>Check if desired</b></td><td class=td align=center><b>Job Details</b></td></tr></tab
$numview=4;
$i=$lowernum;
while (($row=mysql_fetch_row($my
{
print("\n<BR>\n");
print("\n<table class=tableborder width=100% border=3><tr><td>");
print("\n<table border=0 cellspacing=0 cellpadding=0 width=100%>\n");
print("\n<tr><td align=center> <input type=checkbox size=15 value=$row[0]> </td>\
print("\n<td class=boldsmallfont>Job Title: </td>\n");
print("\n<td class=td colspan=2>$row[1]</td><td>
print("\n<tr><td></td><td class=boldsmallfont>Positi
print("\n<td class=td colspan=2>$row[2]</td><td>
print("\n<tr><td></td><td class=boldsmallfont>Job Preference: </td>\n");
print("\n<td class=td colspan=2>$row[3]</td><td>
print("\n<tr><td></td><td class=boldsmallfont>Locati
print("\n<td class=td colspan=2>$row[4]</td><td>
print("\n<tr><td colspan=4> </td></tr>
print("\n<tr><td></td><td class=boldsmallfont>Last Date for Applications: </td>\n");
$query2="select date_format('$row[13]','d/
$mysql_result2=mysql_query
$rec=mysql_fetch_row($mysq
print("\n<td class=td>$rec[0]</td>");
print("<td align=center>");
print("<table border=3><tr><td align=center class=td bordercolor=#aaaaaa bgcolor=#aaaaaa>");
print("<a href=# onClick=\"window.open('des
print("Show Details</a></td></tr></tab
print("\n<tr><td colspan=4> </td></tr>
print("\n</table>\n");
print("\n</td></tr>\n</tab
$i += 1;
}
if ($numrow > 4)
{
print("<table align=center cellspacing=0 cellpadding=5><tr>");
print("<td class=td>Pages</td>");
$numpage=$numrow/$numview;
$numex=$numrow%$numview;
if ($numex > 0)
{
$numpage += 1;
}
for ($j=1; $j <= $numpage; $j++)
{
print("<td><A href='jobresult.php3?lower
}
print("</tr></table>");
}
?>
</form>
</td>
<td width=15%></td>
</tr>
</table>
**************************
When I add "Limit" to the Select statement, it does not give me the total number of results. In this case, it just gives me four records.
So I have tried to do that by adding it to the while statement. Yet it doesnt work..
Please help me out..
Awaiting ur reply
&
Thanks in adv.
Yes with the limit command you can't get the total number of rows
What you can do is to create 2 query.
<?
$query = "select * from table";
$mysql_result=mysql_query( $query, $mysql_link);
$numrow=mysql_num_rows($my sql_result );
......
and then the query with limit
In term of performance, I don't think it will slow your system :)
What you can do is to create 2 query.
<?
$query = "select * from table";
$mysql_result=mysql_query(
$numrow=mysql_num_rows($my
......
and then the query with limit
In term of performance, I don't think it will slow your system :)