Re: [INTERFACES] Newbie needs help

Поиск
Список
Период
Сортировка
От Constantin Teodorescu
Тема Re: [INTERFACES] Newbie needs help
Дата
Msg-id 356E59F3.321D38F2@flex.ro
обсуждение исходный текст
Ответ на Newbie needs help  ("Matthew T. O'Connor" <matt@ctlno.com>)
Список 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> <th>Data<th>Subiect<th> </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

В списке pgsql-interfaces по дате отправления:

Предыдущее
От: "Matthew T. O'Connor"
Дата:
Сообщение: Newbie needs help
Следующее
От: Tim Bosinius
Дата:
Сообщение: psqlodbc v243 + VB + RDO