Hi guys am very new to PHP and have bundled along for weeks using tutorials, sorting many ‘issues’ along the way, but am stuck, and would appreciate your help!
Here’s the page link in the comment for a visual in case I don’t make sense:
https://flighteducation.co.uk/Careers.php.
I have a search area (top right) that searches a mysql database for a ‘career’, and echos out the rest of the information in the database, below in the HTML using the PHP code:
<?php
session_start();
$output=NULL;
//Connect to the database
$mysqli = new mysqli("localhost", "", "", "");
//Query the database
if((isset($_POST['submit'])) && (isset($_POST['search']) && ($_POST['search'] != NULL))) {
$search = $mysqli->real_escape_string($_POST['search']);
$result = $mysqli->query("SELECT * FROM careers WHERE jobTitle regexp '$search'");
if($result->num_rows > 0)
{
while($rows=$result->fetch_assoc())
{
$jobTitle=$rows['jobTitle'];
$jobDesription=$rows['jobDescription'];
$salaryLow=$rows['salaryLow'];
$salaryHigh=$rows['salaryHigh'];
$typicalHours=$rows['typicalHours'];
$timeDay=$rows['timeDay'];
$howBe=$rows['howBe'];
$universityInfo=$rows[' universityInfo'];
$universityRequirements=$rows['universityRequirements'];
$collegeInfo=$rows['collegeInfo'];
$collegeRequirements=$rows['collegeRequirements'];
$otherRoutes=$rows['otherRoutes'];
$directApplication=$rows[' directApplication'];
$volunteeringExperience=$rows['volunteeringExperience'];
$moreInformation=$rows['moreInformation'];
$skillsKnowledge=$rows['skillsKnowledge'];
$dayTasks=$rows['dayTasks'];
$workingEnvironment=$rows[' workingEnvironment'];
$careersProgression=$rows['careersProgression'];
$output .="<b>Job Title:</b><br /> $jobTitle<br /><br />
<b>Job Description:</b><br /> $jobDesription<br /><br />
<b>Salary Low:</b><br /> $salaryLow<br /><br />
<b>Salary High:</b><br /> $salaryHigh<br /><br />
<b>Typical Hours:</b><br /> $typicalHours<br /><br />
<b>Typical Hours:</b><br /> $timeDay<br /><br />
<b>How to become a:</b><br /> $howBe<br /><br />
<b>University:</b><br /> $universityInfo<br /><br />
<b>University requirements:</b><br /> $universityRequirements<br /><br />
<b>College:</b><br /> $collegeInfo<br /><br />
<b>College requirements:</b><br /> $collegeRequirements<br /><br />
<b>Other routes:</b><br /> $otherRoutes<br /><br />
<b>Direct application:</b><br /> $directApplication<br /><br />
<b>Volunteering and Experience:</b><br /> $volunteeringExperience<br /><br />
<b>More Information:</b><br /> $moreInformation<br /><br />
<b>Skills & Knowledge:</b><br /> $skillsKnowledge<br /><br />
<b>Day to Day tasks:</b><br /> $dayTasks<br /><br />
<b>Working Environment:</b><br /> $workingEnvironment<br /><br />
<b>Careers Progression:</b><br /> $careersProgression<br /><br />
<br /><br /><br />";
}
}
else{
$output="We can't seem to find any related Careers!<br />Try simplifying your search?";
}
}
?>
with the ‘output’ code after the search button section being:
<!--PHP OUTPUT-->
<?php echo $output; ?>
My problem is that I also have a drop-down menu on the left which is ‘populated’ by a column in the database using the code:
<!--DROPDOWN SEARCH-->
<?PHP
$dropdown=$mysqli->query("SELECT jobTitle FROM careers");
?>
<!--Top Container -->
<section class="careers-results">
<header class="showcase-career">
<label for="Careers">Choose a Career:</label>
<img src="img/Careers-Logo.png" alt="LOGO"> <be>
<select class="careers-dropdown" name="Careers" id="Careers">
<?PHP
while ($rows=$dropdown->fetch_assoc())
{
$jobTitle=$rows['jobTitle'];
echo "<option value='jobTitle'>$jobTitle</option>";
}
?>
**I am struggling to get the ‘selection’ in the dropdown menu to trigger the same MySQL database, and echo the other information, as it does in the ‘search option’
I am supposing I need to input a $_GET somewhere? And is it possible to use the same <?php echo $output; ?> as used in the ‘search results’?
apologies in advance for my immaturity in knowledge and use of language (and length of this)
very much appreciated
Steven**