Jump to content

PHP Search Help


PRodgers4284

Recommended Posts

I have got a basic search working with two dropdown boxes and i have the results outputting in a table. The table outputs job vacancies in the table stating a "Company Name", "Job title", "Job Category". I have a field called "View Job" where i have a link to a more detailed view of the job, when i select the view link  to display a more detailed view of the job the form appears empty, i cant same to get the record details to show in the view form, the username and ID are being passed into the view form, just cant get them to show in the form. Can anyone help me with this?

 

My code for the searchjob is:

 

<!--Search Job form  -->                    
<form method="POST" action="">
<fieldset>    
<span class="navyboldtxt">    
<label for="jobcatergory">Job Catergory:  </label></span>
<select name="jobcatergory">
<option value="Please Select">Please Select</option> 
<?php 
  $jobcatergory_opts = array( 
    "Accountancy and Finance", 
    "Banking and Insurance", 
    "Construction", 
    "Customer Service", 
    "Engineering", 
    "Management",
    "Hotel and Catering", 
    "Information Technology",
    "Legal",
    "Marketing", 
    "Medical",
    "Retail",
    "Sales",
    "Secretarial",
    "Transport and Distribution",
    "Working from home",        
  ); 
  foreach($jobcatergory_opts as $opt){
    $selected = $_POST['jobcatergory'] == $opt ? " selected=true":"";
    print "<option value=\"{$opt}\"{$selected}>{$opt}</option>";
  }
?>
</select><p></p>   
<p><label for="joblocation"><span class="navyboldtxt">Job Location:</label></span>    
<select name="joblocation">
<option value="Please Select">Please Select</option>
<?php
  $joblocation_opts = array(
    "Co.Antrim",
    "Co.Armagh",
    "Co.Down",
    "Co.Fermanagh",
    "Co.Londonderry",
    "Co.Tyrone",
  );
  foreach($joblocation_opts as $opt){
    $selected = $_POST['joblocation'] == $opt ? " selected=true":"";
    print "<option value=\"{$opt}\"{$selected}>{$opt}</option>";
  }
?>
</select><span class="redboldtxt">       </span>
</p>
<p><span class="redboldtxt"> <?php echo "$joblocation_message";?><?php echo $error['joblocation']; ?></span><input type="submit" value="Find a Job" /></p>
<p> </p>
</fieldset>  
</form>

<?php 

$sql = "SELECT * FROM job"; 
$jobcat = mysql_real_escape_string(trim($_POST['jobcatergory'])); 
$jobloc = mysql_real_escape_string(trim($_POST['joblocation']));

if ($jobcat != '' && $jobloc != '') { 
$sql .= " WHERE jobcatergory LIKE '$jobcat%' AND joblocation LIKE '%$jobloc%'";
} 
else if ($jobcat != '' && $jobloc == '') { 
  $sql .= " WHERE jobcatergory LIKE '%$jobcat%'"; 
} 
else if ($jobloc != '' && $jobcat == '') { 
  $sql .= " WHERE joblocation LIKE '%$jobloc%'"; 
} 

$query = mysql_query($sql) or die(mysql_error()); 

if(mysql_num_rows($query) > 0) 
{ 
while ($job = mysql_fetch_array($query)) 
{ 
    $username=$job["username"]; 
    $id=$job["id"]; 
    $jobtitle=$job["jobtitle"];  
    $jobcatergory=$job["jobcatergory"];  
   ?> 

   
<table border="1" width="100%" id="table1" bgcolor="#FFFFFF"> 
    <tr> 
        <td width="30%"><font face="Verdana" size="2">Company Name</font></td> 
        <td width="30%"><font face="Verdana" size="2">Job Title</font></td> 
        <td width="30%"><font face="Verdana" size="2">Job Catergory</font></td> 
        <td width="30%"><font face="Verdana" size="2">View Job</font></td>  
        <td width="30%"><font face="Verdana" size="2"></font></td>
    </tr> 
    <tr> 
        <td width="30%"><font face="Verdana" size="2"><?php echo $job["username"]; ?></font></td>
        <td width="30%"><font face="Verdana" size="2"><?php echo $job["jobtitle"]; ?></font></td> 
        <td width="30%"><font face="Verdana" size="2"><?php echo $job["jobcatergory"]; ?></font></td> 
	<td width="30%"><font face="Verdana" size="2"><?php echo "<a href='searchjobview.php?username=$username&id=$id'>View Job</a>"?></p></td>
    </tr> 
</table> 
   
<?php 
  }  
  } 
  else 
  { 
  echo '<p>There are no search results with the search criteria you entered.</p>'; 
  }
?>

 

 

 

View job form is:

 

<?php  
$username = $_GET['username'];
$id = $_GET['id'];


$job = mysql_fetch_array(mysql_query("SELECT * FROM job WHERE username='$username' AND id='$id'")); 


?>  




<form method="post" class="addform" action=""> 
<fieldset>   
<p align="right"> <a href="test.php" onclick="NewWindow(this.href,'name','200','200','yes');return false"><font face="Verdana" size="2">Help/Assistance</a></p>
</font>
</fieldset> 
<fieldset>  
<label for="view">View Job</label><fieldset> 
<p align="right"> </p>
</fieldset><label for="username">Company name:</label><input readonly name="username" type="text" id="username" value="<?php echo $job["username"]; ?>" /><br />  
</fieldset>  

<hr class="hr_blue"/>

<fieldset> 
<label for="jobtitle">Job Title:</label><input name="jobtitle" type="text" id="jobtitle" value="<?php echo $job['jobtitle']; ?>"/> 
</fieldset>

<fieldset>  
<label for="jobcatergory">Job Category:</label><input name="jobcatergory" type="text" id="jobcatergory" value="<?php echo $job['jobcatergory']; ?>"/> 
</fieldset> 


<fieldset>  
<label for="joblocation">Job Location:</label><input name="joblocation" type="text" id="joblocation" value="<?php echo $job['joblocation']; ?>"/> 
</fieldset> 


<fieldset>  
<label for="employmenttype">Employment Type:</label><input name="employmenttype" type="text" id="employmenttype" value="<?php echo $job['employmenttype']; ?>"/> 
</fieldset> 

<fieldset> 
<label for="salary">Salary:</label><input name="salary" type="text" id="salary" value="<?php echo $job['salary']; ?>"/></fieldset>

<fieldset> 
<label for="date">Closing Date:</label><input name="date" type="text" id="date" value="<?php echo $job['date']; ?>"/> 
</fieldset> 


<fieldset>  
<label for="educationallevel">Educational Level Required:</label><input name="educationallevel" type="text" id="educationallevel" value="<?php echo $job['educationallevel']; ?>"/> 
</fieldset> 

<hr class="hr_blue"/>

<fieldset> 
<textarea rows="2" name="description" cols="20"><?php echo $job["description"]; ?></textarea><p></p> 
</fieldset> 
</form> 
<?php 
?>                

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.