Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $opts = getopt("w:c:h");
- if (isset($opts['h'])) {
- print "-w whereString (Optional)t";
- print "use \" if @ or , characters are used, such as -w email=\"null\"n";
- print "totherwise shows entire tablen";
- print "n";
- print "-c columns seperated by comma and space in double quotesn";
- print "tdefault columns are: "Function, Directory, Filename, HMC_or_LPAR, Description"n";
- exit(1);
- }
- if (isset($opts['w'])) {
- $whereString=$opts['w'];
- } else {
- $whereString="";
- }
- if (isset($opts['c'])) {
- $columns=$opts['c'];
- } else {
- $columns="Function, Directory, Filename, HMC_or_LPAR, Description";
- }
- $dbhost = 'localhost:null';
- $dbuser = 'null';
- $dbpass = 'null';
- $conn = mysql_connect($dbhost, $dbuser, $dbpass);
- if(! $conn )
- {
- die("Could not connect: " . mysql_error() . "n");
- }
- if (empty($whereString)) {
- $sql = "SELECT $columns FROM rastrace";
- } else {
- $sql = "SELECT $columns FROM rastrace WHERE $whereString";
- }
- mysql_select_db('web');
- $retval = mysql_query( $sql, $conn );
- if(! $retval )
- {
- die("Could not get data: " . mysql_error() . "n");
- }
- while($row = mysql_fetch_array($retval, MYSQL_ASSOC))
- {
- if (isset($row['Function'])) { print "Function::{$row['Function']}n"; }
- if (isset($row['Directory'])) { print "Directory::{$row['Directory']}n"; }
- if (isset($row['Filename'])) { print "pmr::{$row['Filename']}n"; }
- if (isset($row['HMC_or_LPAR'])) { print "HMC_or_LPAR::{$row['HMC_or_LPAR']}n"; }
- if (isset($row['Description'])) { print "Description::{$row['Description']}n"; }
- print "--------------------------------n";
- }
- mysql_close($conn);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement