Advertisement
Guest User

Untitled

a guest
Jul 5th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. <?php
  2. $opts = getopt("w:c:h");
  3.  
  4. if (isset($opts['h'])) {
  5. print "-w whereString (Optional)t";
  6. print "use \" if @ or , characters are used, such as -w email=\"null\"n";
  7. print "totherwise shows entire tablen";
  8. print "n";
  9. print "-c columns seperated by comma and space in double quotesn";
  10. print "tdefault columns are: "Function, Directory, Filename, HMC_or_LPAR, Description"n";
  11. exit(1);
  12. }
  13.  
  14.  
  15. if (isset($opts['w'])) {
  16. $whereString=$opts['w'];
  17. } else {
  18. $whereString="";
  19. }
  20.  
  21.  
  22.  
  23. if (isset($opts['c'])) {
  24. $columns=$opts['c'];
  25. } else {
  26. $columns="Function, Directory, Filename, HMC_or_LPAR, Description";
  27. }
  28.  
  29.  
  30. $dbhost = 'localhost:null';
  31. $dbuser = 'null';
  32. $dbpass = 'null';
  33. $conn = mysql_connect($dbhost, $dbuser, $dbpass);
  34. if(! $conn )
  35. {
  36. die("Could not connect: " . mysql_error() . "n");
  37. }
  38.  
  39. if (empty($whereString)) {
  40. $sql = "SELECT $columns FROM rastrace";
  41. } else {
  42. $sql = "SELECT $columns FROM rastrace WHERE $whereString";
  43. }
  44.  
  45.  
  46. mysql_select_db('web');
  47. $retval = mysql_query( $sql, $conn );
  48. if(! $retval )
  49. {
  50. die("Could not get data: " . mysql_error() . "n");
  51. }
  52. while($row = mysql_fetch_array($retval, MYSQL_ASSOC))
  53. {
  54. if (isset($row['Function'])) { print "Function::{$row['Function']}n"; }
  55. if (isset($row['Directory'])) { print "Directory::{$row['Directory']}n"; }
  56. if (isset($row['Filename'])) { print "pmr::{$row['Filename']}n"; }
  57. if (isset($row['HMC_or_LPAR'])) { print "HMC_or_LPAR::{$row['HMC_or_LPAR']}n"; }
  58. if (isset($row['Description'])) { print "Description::{$row['Description']}n"; }
  59. print "--------------------------------n";
  60. }
  61. mysql_close($conn);
  62. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement