Skip site navigation (1) Skip section navigation (2)

Search an addresbook

From: "Cyprian Makhafola [ MTN - Innovation Centre ]" <Makhaf_C(at)mtn(dot)co(dot)za>
To: <pgsql-php(at)postgresql(dot)org>
Subject: Search an addresbook
Date: 2006-10-09 13:01:14
Message-ID: 6E5C002EEBF89049AC4DFF84765A7D9603F255AC@MTNMAIL.mtn.co.za (view raw or flat)
Thread:
Lists: pgsql-php
Hi All
 
I am a newby in the php and postgres. I have a the following script that
suppose to search an addrssbook but the scripts does not return anything
even an error. I got this scripts from the internet but in the mysql
form so i changed it to postgres.
 
The field s for my table is customer_id, name. address, msisdn,
telephone and msisdn. I use want to use name or msisdn to search.
<?php
$dbname     = "phonebook";
$host       = "localhost";
$port       = "5432";
$user      = "postgres";
 
if (!IsSet($start) ) :
   $start = 0;
endif;
?>
 
<?
#if ($searchstring)
if(isset($searchstring) && strcmp("Search",$searchstring) == 0)
{
        $query = "SELECT * FROM clientdata WHERE $searchtype LIKE
'%$searchstrin
g%' ORDER BY name ASC";
        $connection = pg_connect("host=$host port=$port dbname=$dbname
user=$use
r");
        $pg_select_db("$dbname",$query);
        $Customer_id =  pg_escape_string($_POST['customer_id']);
 
        $Name = pg_escape_string($_POST['name']);
        $Msisdn = pg_escape_string($_POST['msisdn']);
        $result = pg_query($query);
        $resultsnumber = pg_numrows($result);
 
        echo "<TABLE BORDER=0>";
        echo "number of results: $resultsnumber";
 
        $alternate = "2";
                while ($myrow = pg_fetch_array($result))
                {
                   $Name = $myrow["name"];
                   $customer_id = $myrow["id"];
                   $msisdn = $myrow["msisdn"];
                   if ($alternate == "1")
                   {
                     $color = "#ffffff";
                     $alternate = "2";
                   }
                   else
                   {
                      $color = "#efefef";
                      $alternate = "1";
                   }
        echo "<TR bgcolor=$color><TD>$name, $msisdn</TD>";
        echo "Could not find records";
                }
}
?>

I can add and delete but i cannot search, please assist.


NOTE: This e-mail message is subject to the MTN Group disclaimer see http://www.mtn.co.za/default.aspx?pid=34411

pgsql-php by date

Next:From: mark.dingeeDate: 2006-10-09 13:18:09
Subject: Re: Search an addresbook
Previous:From: ChrisDate: 2006-10-09 05:51:46
Subject: Re: Tutorial/Example of Insert/Select PDF Postgres DB ?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group