Location: PHPKode > projects > Music and Discography Database > music_db/common_pg_funcs.php
<?
// SQL functions ===============================================
include_once('config.php.inc');

function connectSQL() {
  global $ID,$csign,$db_name,$db_user,$db_pass,$db_host;
  if ($csign==1) return;
  $ID=pg_connect("host=$db_host user=$db_user password=($db_pass) dbname=$db_name");
  $csign=1;
}
  
function closeSQL() {
  global $ID,$csign;
  if ($csign==1) pg_close($ID);
  $csign=0;
}
 
function query($qstr) {
  global $ID,$res,$nur;
  //print "$qstr<BR>";
  $res = pg_query($ID,$qstr);
  $nur = pg_num_rows($res);
//  print "$nur<BR> ";
}

function sqlcmd($qstr) {
  global $ID,$res,$nur;
  //print "$qstr<BR>";
   $res = pg_query($ID,$qstr);
   $nur = pg_affected_rows($res);
}

function next_row() {
  global $ID,$res;
  $row = pg_fetch_assoc($res);
  return $row;
}

function select_menu($table,$field) {   # Select menh� k�dezi le adatb�isb� a sorokat.
    #global $ID, $res, $nur, $$field;
    global $ID, $res, $nur;
    query("SELECT $field FROM $table GROUP BY $field ORDER BY $field");
    $ff = array("*");
    for($i=0;$i<$nur;$i++) {
        $row = pg_fetch_row($res);
        if($row[0] != '') {
            array_push($ff,"$row[0]");
        }
    }
    return $ff;
}

function ifset($variable) {     # teszteli egy v�toz�l�ez��, � ha nem l�ezik, l�rehozza res �t�kel.
    global $$variable;
    if (!isset($$variable)) $$variable = '';
}

function chomp(&$elem) {
  $elem = trim($elem);
  $elem = ltrim($elem);
}

// �tal�os HTML fggv�yek ================================================

// select menut nyomtat el�e defini�t tartalommal
function make_select($content,$name) {
  global $$content;
  $row = $$content;
  print "<SELECT NAME='$name'>";
  for ($i=0;$i<count($row);$i++) {
    print "<OPTION>$row[$i]</OPTION>";
  }
  print "</SELECT>";
}
?>
Return current item: Music and Discography Database