Guest User

Untitled

a guest
Nov 22nd, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.24 KB | None | 0 0
  1. <b>Klassement spelers</b>
  2. <?php
  3. //dropdownlist hier, naam selecten en alle results 
  4.     require_once 'functions.php';
  5.    
  6.     $result = q_select("*", "speler", "naam=".$naam);
  7.     $res = dbarray($result);
  8.     echo $res;
  9.     if(dbrows($result) > 0) {
  10.         echo "<table>
  11.                 <tr>
  12.                     <th>Speler</th>
  13.                     <th>Score</th>
  14.                 </tr>";
  15.         foreach($res in $result) {
  16.             echo "<tr>
  17.                     <td>".$res['naam']."</td>
  18.                     <td>".$res['score']."</td>
  19.                 </tr>";
  20.         }
  21.         echo "</table>";
  22.     }
  23. ?>
  24.  
  25. <?php
  26.  
  27. $host = "localhost";
  28. $user = "admin";
  29. $pass = "";
  30.  
  31. $connection = mysql_connect($host,$user,$pass) or die('Could not connect: ' . mysql_error());
  32.  
  33. mysql_select_db('spelers');
  34.  
  35. function q_insert($fields, $values, $table) {
  36.     if($fields != "")
  37.         $fields = "(".implode($fields, ", ").")";
  38.     $values = implode($values, ", ");
  39.     $res = "INSERT INTO $table $fields VALUES ($values)";
  40.     return dbquery($res);
  41. }
  42.  
  43. function q_select($fields, $table, $where) {
  44.     if($fields != "*") $fields = implode($fields, ", ");
  45.     $res = "SELECT $fields FROM $table WHERE $where";
  46.     $res = dbquery($res);
  47.     return $res;
  48. }
  49.  
  50. function dbarray($query) {
  51.     $res = mysql_fetch_assoc($query);
  52.     return $res;
  53. }
  54.  
  55. function dbrows($query) {
  56.     $res = mysql_num_rows($query);
  57.     return $res;
  58. }
  59.  
  60. ?>
Add Comment
Please, Sign In to add comment