This is a multi-part message in MIME format.
------_=_NextPart_001_01C6EBA3.016A7C50
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: quoted-printable
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 =3D "phonebook";
$host =3D "localhost";
$port =3D "5432";
$user =3D "postgres";
if (!IsSet($start) ) :
$start =3D 0;
endif;
?>
<?
#if ($searchstring)
if(isset($searchstring) && strcmp("Search",$searchstring) =3D=3D 0)
{
$query =3D "SELECT * FROM clientdata WHERE $searchtype LIKE
'%$searchstrin
g%' ORDER BY name ASC";
$connection =3D pg_connect("host=3D$host port=3D$port dbname=3D$dbn=
ame
user=3D$use
r");
$pg_select_db("$dbname",$query);
$Customer_id =3D pg_escape_string($_POST['customer_id']);
$Name =3D pg_escape_string($_POST['name']);
$Msisdn =3D pg_escape_string($_POST['msisdn']);
$result =3D pg_query($query);
$resultsnumber =3D pg_numrows($result);
echo "<TABLE BORDER=3D0>";
echo "number of results: $resultsnumber";
$alternate =3D "2";
while ($myrow =3D pg_fetch_array($result))
{
$Name =3D $myrow["name"];
$customer_id =3D $myrow["id"];
$msisdn =3D $myrow["msisdn"];
if ($alternate =3D=3D "1")
{
$color =3D "#ffffff";
$alternate =3D "2";
}
else
{
$color =3D "#efefef";
$alternate =3D "1";
}
echo "<TR bgcolor=3D$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=3D34411
------_=_NextPart_001_01C6EBA3.016A7C50
Content-Type: text/html; charset="US-ASCII"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; charset=3Dus-ascii">
<META content=3D"MSHTML 6.00.2900.2963" name=3DGENERATOR></HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D537065212-09102006>Hi
All</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN
class=3D537065212-09102006></SPAN></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D537065212-09102006>I am a ne=
wby in the
php and postgres. I have a the following script that suppose to search an=
a
ddrssbook but the scripts does not return anything even an error. I got th=
is
scripts from the internet but in the mysql form so i changed it to
postgres.</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN
class=3D537065212-09102006></SPAN></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D537065212-09102006>The field=
s for my
table is customer_id, name. address, msisdn, telephone and msisdn. I use wa=
nt to
use name or msisdn to search.</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN
class=3D537065212-09102006><?php<BR>$dbname =3D=
"
phonebook";<BR>$host =3D
"localhost";<BR>$port =3D
"5432";<BR>$user =3D "postgres";</SPAN></FONT=
></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D537065212-09102006>if (!IsSe=
t($start) )
:<BR> $start =3D 0;<BR>endif;<BR>?></SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D537065212-09102006><?<BR>=
#if
($searchstring)<BR>if(isset($searchstring) &&
strcmp("Search",$searchstring) =3D=3D
0)<BR>{<BR> $query =3D "SELECT * =
FROM
clientdata WHERE $searchtype LIKE '%$searchstrin<BR>g%' ORDER BY name
ASC";<BR> $connection =3D
pg_connect("host=3D$host port=3D$port dbname=3D$dbname
user=3D$use<BR>r");<BR>
$pg_select_db("$dbname",$query);<BR> &nb=
sp;
$Customer_id =3D
pg_escape_string($_POST['customer_id']);</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><SPAN
class=3D537065212-09102006> $Name=
=3D
pg_escape_string($_POST['name']);<BR> &n=
bsp;
$Msisdn =3D
pg_escape_string($_POST['msisdn']);<BR> =
$result =3D pg_query($query);<BR> =
$
resultsnumber =3D pg_numrows($result);</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><SPAN
class=3D537065212-09102006> echo=
"
<TABLE BORDER=3D0>";<BR> e=
cho
"number of results: $resultsnumber";</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><SPAN
class=3D537065212-09102006> $alte=
rnate =3D
"2";<BR> &=
nbsp;
while ($myrow =3D
pg_fetch_array($result))<BR>  =
;
{<BR> &nbs=
p;
$Name =3D
$myrow["name"];<BR> &n=
bsp;
$customer_id =3D
$myrow["id"];<BR> &nbs=
p;
$msisdn =3D
$myrow["msisdn"];<BR> =
if ($alternate =3D=3D
"1")<BR> &=
nbsp;
{<BR> &nbs=
p;
$color =3D
"#ffffff";<BR> &=
nbsp;
$alternate =3D
"2";<BR> &=
nbsp;
}<BR> &nbs=
p;
else<BR> &=
nbsp;
{<BR> &nbs=
p;
$color =3D
"#efefef";<BR> &=
nbsp;
$alternate =3D
"1";<BR> &=
nbsp;
}<BR> echo "<TR
bgcolor=3D$color><TD>$name,
$msisdn</TD>";<BR> echo "Co=
uld
not find
records";<BR> &n=
bsp;
}<BR>}<BR>?><BR></SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D537065212-09102006>I can add=
and delete
but i cannot search, p</SPAN></FONT><FONT face=3DArial size=3D2><SPAN
class=3D537065212-09102006>lease assist.</SPAN></FONT></DIV><CODE><FONT SIZ=
E=3D3><BR>
<BR>
NOTE: This e-mail message is subject to the MTN Group disclaimer see http:/=
/www.mtn.co.za/default.aspx?pid=3D34411<BR>
</FONT></CODE></BODY></HTML>
------_=_NextPart_001_01C6EBA3.016A7C50--
