// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Fetch all rows from the table
$sql = "SELECT ID, source, name, tier, obj_desc FROM sellOBJs";
$result = $conn->query($sql);
// Close the database connection
$conn->close();
?>
<!DOCTYPE html>
<html>
<head>
<title>Dropdown from Database</title>
</head>
<body>
<form>
<label for="sellObj">Select an option:</label>
<select name="sellObj" id="sellObj">
<?php
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
$optionText = "{$row["ID"]} - {$row["source"]} - {$row["name"]} - {$row["tier"]} - {$row["obj_desc"]}";
echo "<option value='{$row["ID"]}'>$optionText</option>";
}
} else {
echo '<option value="-1">No options available</option>';
}
?>
</select>
</form>
</body>
</html>
{source}
<?php
include JPATH_SITE . '/PHP/extraPHP.php';
include JPATH_SITE . '/PHP/formPHP.php';
?>
{/source}
<form action="submit.php" method="post">
<label for="league"> League:</label>
<select id="league" name="league">
<option value="LSCT">{source php="/PHP/extraPHP.php"}<?php echo $leagueName; ?>{/source} SCT</option>
<option value="LHCT">{source php="/PHP/extraPHP.php"}<?php echo $leagueName; ?>{/source} HCT</option>
<option value="Standard">Standard</option>
</select><br><br>
<label for="sellObj">Select an option:</label>
<select name="sellObj" id="sellObj">
{source php="/PHP/formPHP.php"}<?php
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
$optionText = "{$row["ID"]} - {$row["source"]} - {$row["name"]} - {$row["tier"]} - {$row["obj_desc"]}";
echo "<option value='{$row["ID"]}'>$optionText</option>";
}
} else {
echo '<option value="-1">No options available</option>';
}
?>
{/source}
</select>
<label for="price">Price:</label>
<input type="number" id="price" name="price" required><br><br>
<label for="quantity">Quantity:</label>
<input type="number" id="quantity" name="quantity" required><br><br>
<label for="sellIGN">IGN:</label>
<input type="text" id="sellIGN" name="sellIGN" required><br><br>
<input type="submit" value="Submit">
</form>