Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.59 KB | None | 0 0
  1. <html>
  2. <body style="color: #888888;font-size: 75%;">
  3. <?php
  4. $myServer = "localhost"; //sql server normally localhost
  5. $myUser = "radiodb"; //sql db user
  6. $myPass = "P0hv8jL2"; //sql db pass
  7. $myDB = "radiodbase"; //sql db name
  8.  
  9. #
  10.     $con = @mysql_connect($myServer, $myUser, $myPass) or die('mysql_connect: ' . mysql_error());
  11. #
  12.            @mysql_select_db($myDB) or die('mysql_select_db: ' . mysql_error());
  13. #
  14.    
  15. #
  16.     $result = array();
  17. #
  18. if ($CURUSER["can_dj"] == "yes") {
  19.     if (isset($_GET['id'], $_GET['action'])) {
  20.          mysql_query("DELETE FROM song WHERE id = " . intval($_GET['id']));
  21.          show_error_msg("Deleted", "Request Deleted", 1);
  22.     }
  23.  }  
  24.  if ($CURUSER["can_dj"] == "no") {
  25.   show_error_msg("Error", "You dont have permission to delete requests.", 1);
  26.  }
  27.      
  28. #
  29.     $res = mysql_query("SELECT * FROM song Limit 10"); //$res = mysql_query("SELECT * FROM song ORDER BY id DESC LIMIT 10");
  30. #
  31.     while ($row = mysql_fetch_array($res))
  32. #
  33.         $result[] = $row;
  34. #
  35.        
  36. #
  37.     array_reverse($result);
  38. #
  39.     //print_r($result);
  40. #
  41.     foreach ($result as $request) {
  42. #
  43.         echo htmlspecialchars($request['song_name']) . ' <a href="requests.php?action=delete&id='.$request['id'].'">delete</a><br />';
  44.          #
  45.     }
  46. #
  47.  
  48. #
  49.     mysql_close();
  50. /*
  51. $con = mysql_connect("$myServer","$myUser","$myPass"); //connect to the db
  52. if (!$con) //if you cant connect then do this function
  53.   {
  54.     die('Could not connect: ' . mysql_error()); //say you cant connect and why
  55.   }
  56.  
  57. $db_selected = mysql_select_db($myDB, $con); //select the database you will be working with
  58. if (!$db_selected) { //if you cant select a db
  59.         die ('Can\'t use '+ $myDB + ':' . mysql_error()); //say you cant select it and why
  60.     }
  61.  
  62. $query="SELECT * FROM song ORDER by id DESC"; //assign the query that you want to be done from the table and fields and sorting
  63. $result=mysql_query($query); //do the query you assigned
  64.  
  65. $num=mysql_numrows($result); //calculate how many rows there are in the results you queried
  66.  
  67. //echo "<b>10 Latest Requests</b><br />"; //output the words 10 Latest Requests
  68.  
  69. $i=0; //assign 0 to variable i
  70. while ($i < $num) { //while i is less than the total number of rows run the function in the brackets
  71. $songname=mysql_result($result,$i,"song_name"); //assign songname to a variable named $songname from the results
  72. if ($i < 10) //if i is less than 10 since we only want the first 10 and the id starts at 0
  73.     {
  74.         $b = $i+1;
  75.         echo "$b. $songname<br />"; //output the song name
  76.     }    
  77.     $i++; //add 1 to i
  78. }
  79. */
  80. ?>
  81. </body>
  82. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement