atl_andy Posted November 28, 2007 Share Posted November 28, 2007 Need help making an array with query results: $value = $_POST['text']; $pg = pg_connect('dbname=test user=user password=secret'); $query = "SELECT column FROM information"; $result = pg_query($query); *** how to create array with $results *** Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted November 28, 2007 Share Posted November 28, 2007 Try pg_fetch_array() http://us3.php.net/manual/en/function.pg-fetch-array.php Quote Link to comment Share on other sites More sharing options...
atl_andy Posted November 28, 2007 Author Share Posted November 28, 2007 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 Quote Link to comment Share on other sites More sharing options...
atl_andy Posted November 28, 2007 Author Share Posted November 28, 2007 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.