Jump to content

Update Table Value's via Drop down box.


SiMoZ

Recommended Posts

Hey thanks for reading my thread, 

 

Currently im working on a Status Page for my Game Hacking Website. What i want todo is have a back Panel that i can Select "Game A" from a drop down box, and select the Detection status from another drop down box. Click the submit button, and it changes the values in the Database.

 

I'm new to coding in PHP.

<?PHP 
// Create connection

$con=mysqli_connect("localhost","Username","Password","Database");


// Check connection
if (mysqli_connect_errno($con))
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

$result = mysqli_query($con,"SELECT * FROM haxstatus");

$Hackname="";
$Status="";
$update="";

while($row = mysqli_fetch_array($result)) 

{
	$id=$row["Status"];
  	$name=$row["GameName"];
  	$Hackname.="<OPTION VALUE=\"$id\">".$name.'</option>';
}
  

  
$list = mysqli_query($con,"SELECT * FROM haxstatus");

//dump the sql table in a table
echo "<table border='1'>
<tr>
<th>Game Name:</th>
<th>Detection Status:</th>
</tr>";

while($row = mysqli_fetch_array($list))
  {
  echo "<tr>";
  echo "<td>" . $row['GameName'] . "</td>";
  echo "<td>" . $row['Status'] . "</td>";
  echo "</tr>";
  }
echo "</table>";

?>


    <p> 
    </p>
    <p> </p>
    <p>
      <SELECT NAME=name>
        <OPTION VALUE=0>Game Name
        <? echo $Hackname?>
      </SELECT>
            

      <SELECT Name="Detection">
        <OPTION VALUE=0>Edit Detection Status
        <OPTION VALUE=1>Detected
        <OPTION VALUE=2>Undetected         
      </SELECT>

          
<form action="update.php" method="post">
  <input type="submit">
</form>

  
<?PHP 
$con=mysqli_connect("localhost","Username","Password","Database");

if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
// i attempted to Update the table haxstatus and set Status to the drop down box named detection
$sql="UPDATE haxstatus SET Status=$_POST[Detection] WHERE ('GameName')";

if (!mysqli_query($con,$sql))
  {
  die('Error: ' . mysqli_error());
  }
echo "Updated";


mysqli_close($con);
?>

When i click submit i get this error 

 

Warning: mysqli_error() expects exactly 1 parameter, 0 given in /home/gamead/public_html/update.php on line 15
Error:

 

 

 

 

 

 

Thank you in advanced if you choose to help.

Link to comment
https://forums.phpfreaks.com/topic/276764-update-table-values-via-drop-down-box/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.