Hello, I'm new to php, I'm working on a website for employment. I want user to be able to pull data from mysql by using selection from drop down menu. I have a table call jobs, inside this table there are 5 columns: JobType, Place, Wage, Phone, Date. I created the drop down menu and the php filter code (not sure if i'm coding it right).
But went I run it on IE, the page just refresh. It didn't echo anything on the page. Here is my code...... Please Help!!!

// THIS IS IN THE SELECTION PAGE
<form action="selectform.php" method="POST">
<select name="jobselect">
<option value="" selected="selected">All Jobs</option>
<option value="Cook1">1st Cook</option> 
<option value="Cook2">2nd Cook</option> 
<option value="Helper">Kitchen Helper</option> 
<option value="Bagger">Bagger</option> 
<option value="DishWasher">Dish Washer</option> 
<option value="Hostress">Hostress</option> 
<option value="Waiter">Waiter</option> 
<option value="Waitress">Waitress</option> 
<option value="BusBoy">Bus Boy</option> 
<option value="Fryer">Deep Fryer</option> 
<option value="Cashier">Cashier</option> 
<option value="Driver">Driver</option> 
</select> 
<input type="Submit" value="Submit" name="Submit">
</form>




// THIS IS IN THE FILTERED PAGE
<?php
mysql_connect ("localhost","root") or die (mysql_error());            mysql_select_db ("nindu") or die (mysql_error());

?>
<?php

    $Job = isset($_POST["jobselect"]);
    $Query = "SELECT * FROM jobs WHERE JobType='$Job'";

//RUN THE QUERY
    $result = mysql_query($Query) or die (mysql_error());
while ($row = mysql_fetch_array($result)) {
    echo "<br />";
    echo $row['JobType'] . "-" . $row['Place'] . "-" .
                         $row['Wage'] . "-" . $row['Phone'] . "-" . 
                         $row['Date'];
    echo "<br />";
}
?>

try following changes

use $Job = isset($_REQUEST["jobselect"]); insted of $Job = isset($_POST["jobselect"]);

echo your query and run it in mysql editor. see are you fetching recoding correctly

I still need help with my website. I want user to be able to search all jobs if they submit search with All Jobs selected. code below


// THIS IS IN THE SELECTION PAGE
<form action="selectform.php" method="post">
<select name="jobselect">
<option value="All" selected="selected">All Jobs</option>
<option value="Cook1">Cook1</option>
<option value="Cook2">Cook2</option>
<option value="Helper">Helper</option>
<option value="Bagger">Bagger</option>
<option value="DishWasher">DishWasher</option>
<option value="Hostress">Hostress</option>
<option value="Waiter">Waiter</option>
<option value="Waitress">Waitress</option>
<option value="BusBoy">BusBoy</option>
<option value="Fryer">Fryer</option>
<option value="Cashier">Cashier</option>
<option value="Driver">Driver</option>
</select>
<input type="Submit" value="Submit" name="Submit">
</form>


// THIS IS IN THE FILTERED PAGE
<?php
mysql_connect ("localhost","root") or die (mysql_error());
mysql_select_db ("nindu") or die (mysql_error());

?>
<?php

if (isset($_POST["jobselect"])) {
$Job = mysql_real_escape_string ($_POST["jobselect"]);
$Query = "SELECT * FROM jobs WHERE JobType='$Job'";

//RUN THE QUERY
$result = mysql_query($Query) or die (mysql_error());
while ($row = mysql_fetch_array($result)) {
echo "<br />";
echo $row . " - " . $row . " - " . $row . " - " .
$row . " - " . $row;
echo "<br />";
}
}

?>

// Everything above this part works ok


<?php
//but I also want php to pull all jobs from the table if user submit with All Jobs selected.
//Please correct code if wrong
$Query2 = "SELECT * FROM jobs" ;
if ($Job == "All Jobs") {
echo $Query2 ;

$result = mysql_query($Query2) or die (mysql_error());
while ($row = mysql_fetch_array($result)) {
echo "<br />";
echo $row . " - " . $row . " - " . $row . " - " .
$row . " - " . $row;
echo "<br />";
}


}

?>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.