I have a option list populated by a mysql query and I am having issues getting my results when i click the submit button.
include_once 'dropfunc.php';
connect ();
if($_SERVER["REQUEST_METHOD"] == "post")
{
// Create connection
$con=mysqli_connect("localhost","root","","maintenance");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
// Do one thing
}
else {
$site_id=$_POST["site_id"];
$result = mysqli_query($con,"select * from record where site_id=$site_id");
mysql_close();
}
}
else
echo "this is not working"
?>
Now my dropdown menu works fine and runs off a function and a connect page. For now im just trying to get my submit to work then i will work and making its function page as well. Now if i add an else"this is not working" out side all of the if statement at the top i can get it to echo so i know the IF is not getting anything done.
<!doctype html>
<html>
<div class="box-content">
<form method="post" action="<?php echo $_SERVER["PHP_SELF"];?>">
<div class="control-group">
<label class="control-label" for="selectError">Select Site</label>
<div class="controls">
<select name ="site_id" id="site_id" data-rel="chosen" >
<?php query() ?>
</select>
<input type="submit" value="Submit">
<?php close() ?>
</form>
</div>
<?php
Now i know this is working because i can run it on its own.
while($row = mysqli_fetch_array($result)) {
$luant = $row['luant'];
$ludish = $row['ludish'];
$lucable = $row['lucable'];
$lubrace = $row['lubrace'];
IF ($luant==1 and $ludish==1 and $lucable==1 and $lubrace==1){
echo "The page is working";
}
else {
echo "Still working but they don't equal 1";
}
}
?>