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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.