Re: [INTERFACES] Newbie needs help

From: Constantin Teodorescu <teo(at)flex(dot)ro>
To: "Matthew T(dot) O'Connor" <matt(at)ctlno(dot)com>
Cc: "'pgsql-interfaces(at)hub(dot)org'" <pgsql-interfaces(at)hub(dot)org>
Subject: Re: [INTERFACES] Newbie needs help
Date: 1998-05-29 06:47:15
Message-ID: 356E59F3.321D38F2@flex.ro
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

Matthew T. O'Connor wrote:
>
> Any help? I have been reading about the pgsql module for Apache, but I
> can't find it. and I have been reading about PHP3 but I'm not sure how
> to use it.

<html>

<body bgcolor=white>

<?
Function Listeaza () {
global $res;
$nrecs=pg_NumRows($res);
$i=0;
echo "Clic <img src='/img/balls/bullet5.gif'> afiseaza si
modifica notita<br>";
echo "Clic <img src='/img/balls/bullet6.gif'> sterge <font
color=red><b>iremediabil</b></font> notita<br><br>";
echo "<table width=100%><tr
bgcolor=cyan><th>&nbsp;<th>Data<th>Subiect<th>&nbsp;</tr>";
while($i<$nrecs) {
echo "<tr><td align=center><a
href='blocnotes.php3?show+ovar=", pg_Result($res,$i,"oid"), "'>";
echo "<img src='/img/balls/bullet5.gif' border=0></a>";
echo
"<td>",substr(pg_Result($res,$i,"data"),0,16),"<td>",pg_Result($res,$i,"subiect");
echo "<td align=center><a
href='blocnotes.php3?delete+oid=",pg_Result($res,$i,"oid"),"'>";
echo "<img src='/img/balls/bullet6.gif'
border=0></a></tr>";
$i++;
}
echo "</table><br><br>";
}
?>

<? if ($argc==0): ?>


<? elseif ($argv[0]=="add"): ?>

<center>
<form name="nou" method=POST action="blocnotes.php3?store">
<table border=0><tr>
<td>Titlu: <input type="text" name="subiect" size=50></td></tr>
<tr><td><textarea name="continut" wrap="hard" rows=9
cols=60></textarea></td></tr>
<tr><td align="CENTER"><input type="submit" name="okbtn"
value="Adauga"></td></tr>
</table></form></center>

<? elseif ($argv[0]=="store"):

$acum=date("d-m-Y H:i:s");
echo "<font color=navy><b>Titlu</b></font> : $subiect<br><br>";
echo "<font color=maroon><b>Continut</b></font> :
$continut<br><br>";
$dbc=pg_Connect("localhost","5432","","","consiliu");
$res=pg_Exec($dbc,"insert into blocnotes
values('$REMOTE_USER','$acum','$subiect','$continut')");
pg_FreeResult($res);
pg_Close($dbc);
echo "A fost introdus in blocnotes!";

elseif ($argv[0]=="list"):

$dbc=pg_Connect("localhost","5432","","","consiliu");
$res=pg_Exec($dbc,"select oid,* from blocnotes where
iuzar='$REMOTE_USER' order by data desc");
Listeaza();
pg_FreeResult($res);
pg_Close($dbc);

elseif ($argv[0]=="show"):

$dbc=pg_Connect("localhost","5432","","","consiliu");
$res=pg_Exec($dbc,"select * from blocnotes where oid=$ovar");
echo "<font color=navy><b>Subiect :
</b></font>",pg_Result($res,0,"subiect"),"<br><br>";
echo "<font color=navy><b>Continut
:</b></font><br><pre>",pg_Result($res,0,"continut"),"</pre>";
echo "<br><br><br>";
echo "<a
href='blocnotes.php3?showandchange+ovar=$ovar'>Modifica</a><br>";
pg_FreeResult($res);
pg_close($dbc);

elseif ($argv[0]=="showandchange"):

$dbc=pg_Connect("localhost","5432","","","consiliu");
$res=pg_Exec($dbc,"select * from blocnotes where oid=$ovar");
?>
<center>
<form name="nou" method=POST
action="blocnotes.php3?modify+ovar=<? echo $ovar;?>">
<table border=0>
<tr><td>Titlu: <input type="text" name="subiect" size=50
value="<? echo pg_Result($res,0,"subiect"); ?>"></td></tr>
<tr><td><textarea name="continut" wrap="hard" rows=9 cols=60><?
echo pg_Result($res,0,"continut"); ?></textarea></td></tr>
<tr><td align="CENTER"><input type="submit" name="okbtn"
value="Modifica">
<input type="button" value="Abandon"
onClick="history.back()"></td></tr>
</table>
</form></center>
<?
pg_FreeResult($res);
pg_close($dbc);

elseif ($argv[0]=="modify"):

$dbc=pg_Connect("localhost","5432","","","consiliu");
$res=pg_Exec($dbc,"update blocnotes set
subiect='$subiect',continut='$continut' where oid=$ovar");
pg_FreeResult($res);
pg_Close($dbc);
echo "Am modificat, noile informatii sint :<br><br>";
echo "<font color=navy>Subiect :
</font><b>$subiect</b><br><br>";
echo "<font color=navy>Continut : </font><pre>$continut</pre>";

elseif ($argv[0]=="delete"):

$dbc=pg_Connect("localhost","5432","","","consiliu");
$res=pg_Exec($dbc,"delete from blocnotes where oid=$oid");
pg_FreeResult($res);
$res=pg_Exec($dbc,"select oid,* from blocnotes where
iuzar='$REMOTE_USER' order by data");
Listeaza();
pg_FreeResult($res);
pg_Close($dbc);

elseif ($argv[0]=="search"): ?>

<center>
<form name="caut" method=POST action="blocnotes.php3?find">
<table border=0>
<tr><td>Cuvint <input type="text" name="wort"></td></tr>
<tr><td align="CENTER"><input type="submit" name="okbtn"
value="Cauta"></td></tr>
</table></form></center>

<? elseif ($argv[0]=="find"):
if ($wort !="") {
$dbc=pg_Connect("localhost","5432","","","consiliu");
$res=pg_Exec($dbc,"select oid,* from blocnotes where
subiect ~* '$wort' or continut ~* '$wort'");
$nrecs=pg_NumRows($res);
if($nrecs==0) {
echo "Nu am gasit nimic!<br><br>";
} else {
Listeaza();
}
pg_FreeResult($res);
pg_Close($dbc);
}
else {
echo "<center><h1>Introduceti macar o litera
!</h1></center>";
}

endif;
?>

</body>
</html>

--
Constantin Teodorescu
FLEX Consulting Braila, ROMANIA

In response to

Browse pgsql-interfaces by date

  From Date Subject
Next Message Mark Pulver 1998-05-30 04:10:06 Pg.pm and friends
Previous Message Matthew T. O'Connor 1998-05-29 06:19:23 Newbie needs help