Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function connection(){
- $mysqli = new mysqli("localhost", "user", "password", "tablename");
- if(mysqli_connect_errno()) {
- echo "Connection Failed: " . mysqli_connect_errno();
- exit();
- }
- return $mysqli;
- }
- function makedropdown($table, $column, $form) {
- connection();
- if($stmt = $mysqli->prepare("SELECT * FROM ? ORDER BY ? ASC")){
- $stmt -> bind_param("ss", $table, $column);
- $stmt -> execute();
- $stmt -> bind_result($result);
- echo "<select name='$form'>";
- While ($row = $stmt->fetch($result)){
- echo "<option>" . $row[1] . "</option>";
- }
- echo "</select>";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement