Guest User

Untitled

a guest
Feb 15th, 2014
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. <?php
  2. if(session_id() == '') {
  3. session_start();
  4. }
  5. $config = parse_ini_file("config.ini",true);
  6. $logindata = array();
  7. $logindata['gebruiker'] = $config['Database']['username'];
  8. $logindata['server'] = $config['Database']['server'];
  9. if($config['Database']['password']!=null && $config['Database']['password']!=""){
  10. $logindata['wachtwoord'] = $config['Database']['password'];
  11. }else{
  12. $logindata['wachtwoord'] = null;
  13. }
  14. $logindata['database'] = $config['Database']['database'];
  15. $database = mysql_connect($logindata['server'],$logindata['gebruiker'],$logindata['wachtwoord']);
  16. if(!$database){
  17. echo mysql_error();
  18. die('Could not connect to database');
  19. }
  20. if(!mysql_select_db($logindata['database'], $database)){
  21. die(mysql_error().' Database error<br>');
  22. }
  23.  
  24.  
  25. function showALLVOTES(){
  26. global $database,$logindata;
  27. $sql = "SELECT * FROM `ALLVOTES` ORDER BY nummer";
  28. $query = mysql_query($sql,$database);
  29. if($query==false){
  30. echo('Error, something wrong with the query<br>');
  31. echo mysql_error();
  32. }
  33. while($row = mysql_fetch_array($query,MYSQL_ASSOC)){
  34. if($teller==0){
  35. $teller=1;
  36. echo('<table border="1"><tr>');
  37. foreach($row as $key => $value){
  38. echo('<th>'.$key.'</th>');
  39. }
  40. echo('</tr>');
  41. }
  42. echo('<tr>');
  43. foreach($row as $key => $value){
  44. echo('<td>'.$value.'</td>');
  45. }
  46. echo('</tr>');
  47. }
  48. echo('</table>');
  49. }
  50.  
  51. function showMONTHLYVOTES(){
  52. global $database,$logindata;
  53. $sql = "SELECT * FROM `MONTHLYVOTES` ORDER BY nummer";
  54. $query = mysql_query($sql,$database);
  55. if($query==false){
  56. echo('Error, something wrong with the query<br>');
  57. echo mysql_error();
  58. }
  59. while($row = mysql_fetch_array($query,MYSQL_ASSOC)){
  60. if($teller==0){
  61. $teller=1;
  62. echo('<table border="1"><tr>');
  63. foreach($row as $key => $value){
  64. if($key=="ID"){
  65. }else{
  66. echo('<th>'.$key.'</th>');
  67. }
  68. }
  69. echo('</tr>');
  70. }
  71. echo('<tr>');
  72. foreach($row as $key => $value){
  73. if($key=="ID"){
  74. }else{
  75. echo('<td>'.$value.'</td>');
  76. }
  77. }
  78. echo('</tr>');
  79. }
  80. echo('</table>');
  81. }
  82. ?>
Advertisement
Add Comment
Please, Sign In to add comment