0

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 />";
}
?>

Edited by Reverend Jim: Fixed formatting

3
Contributors
3
Replies
7
Views
7 Years
Discussion Span
Last Post by Awon02
0

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

Edited by BzzBee: n/a

0

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 />";
}


}

?>

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.