Advertisement
Guest User

scopingissue

a guest
Sep 22nd, 2013
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. function connection(){
  2. $mysqli = new mysqli("localhost", "user", "password", "tablename");
  3. if(mysqli_connect_errno()) {
  4. echo "Connection Failed: " . mysqli_connect_errno();
  5. exit();
  6. }
  7. return $mysqli;
  8. }
  9.  
  10.  
  11. function makedropdown($table, $column, $form) {
  12. connection();
  13. if($stmt = $mysqli->prepare("SELECT * FROM ? ORDER BY ? ASC")){
  14. $stmt -> bind_param("ss", $table, $column);
  15. $stmt -> execute();
  16. $stmt -> bind_result($result);
  17. echo "<select name='$form'>";
  18. While ($row = $stmt->fetch($result)){
  19. echo "<option>" . $row[1] . "</option>";
  20. }
  21. echo "</select>";
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement