Advertisement
Guest User

Untitled

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