Jump to content

[SOLVED] How to make an array with query results? (Postgresql)


atl_andy

Recommended Posts

My apologies, I've been using PHP for about two weeks and some stuff just doesn't register...like the solution to this problem. 

 

If I use:

<?php
     function db_fetch_array ($result, $row = NULL, $result_type = PGSQL_ASSOC)
     {
         $return = @pg_fetch_array ($result, $row, $result_type);
         return $return;
     }
?>

 

how do I compare db_fetch_array to $validate?

 

Thanks for the help

SOLVED!!!!  After a couple of days of frustration, the technique used:

 

   $validation = $_POST['serialnumber'];

   $db_handle = pg_connect('dbname=test2 user=userpassword=secret');

   $query = "SELECT DISTINCT serialnumber FROM system WHERE serialnumber LIKE '$validation'";
   $result = pg_query($query);

   while ($row = pg_fetch_array($result, NULL, PGSQL_ASSOC))
   {
     $sn = $row['serialnumber'];
     if ($sn == $validation) {
     echo "Duplicate serial number<br />";
     } exit;
   }

   ...continue

 

If there is a more efficient way of executing this validation, I'm all ears (or eyes).  Thanks to those that took the time to help me out on all my posts so far.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.