Witam,
Mam problem z napisaniem skryptu, ktory umozliwialby dodawanie, usuwanie i wyszukiwanie rekordow w bazie PostgreSQL. Skrypty wrzucone na serwer nie pokazuja ze gdzies wystapil blad ale nie dzialaja :/ Czy moze byc to spowodowane brakiem uprawnien? Podobne skrypty na MySQL dzialaly bez zarzutu. Jestem 'swiezakiem' wiec nie pojedzcie mnie za bardzo (IMG:
http://forum.php.pl/style_emoticons/default/winksmiley.jpg) Z gory dzieki za wszelka pomoc.
Dodawanie:
<?php
if (isset($_POST["ID"])) { $link = pg_connect("user= dbname= host= password= port=54321"); $res = pg_query($db, "INSERT INTO filmy (id, tytul, gatunek, rok, dlugosc, format, rozmiar) VALUES ('$_POST[ID]', '$_POST[TYTUL]', $_POST[GATUNEK], $_POST[ROK], $_POST[DLUGOSC], $_POST[FORMAT], $_POST[ROZMIAR])"); if (!$res) { echo "Błąd aktualizacji bazy!"; } }
?>
Usuwanie:
<?php
$link = pg_connect("user= dbname= host= password= port=54321"); $zapytanie = pg_query($link,"SELECT * FROM filmy"); echo'<table border=0 width=796 cellspacing=1 cellpadding=2><tr>'; echo"<td height=21 width=270 align=center bordercolor=#C0C0C0><font face=Verdana size=1>{$wiersz['tytul']}</td>"; echo"<td height=21 width=109 align=center bordercolor=#C0C0C0><font face=Verdana size=1>{$wiersz['gatunek']}</td>"; echo"<td height=21 width=92 align=center bordercolor=#C0C0C0><font face=Verdana size=1>{$wiersz['rok']}</td>"; echo"<td height=21 width=86 align=center bordercolor=#C0C0C0><font face=Verdana size=1>{$wiersz['dlugosc']}</td>"; echo"<td height=21 width=49 align=center bordercolor=#C0C0C0><font face=Verdana size=1>{$wiersz['format']}</td>"; echo"<td height=21 width=84 align=center bordercolor=#C0C0C0><font face=Verdana size=1>{$wiersz['rozmiar']}</td>"; echo"<td height=21 width=8 align=center bordercolor=#C0C0C0><font face=Verdana size=1><a href="usun_film
.php?stan
=del
&iddel
=".$wiersz['id'].""><img border=0 align=center src=del.jpg></a></td>"; if($stan=='del') {
$zapytanie2 = pg_query($link,"DELETE FROM filmy WHERE id=$iddel"); echo "<center><font face=Verdana size=1><br>Rekord został skasowany!<br><a href=usun_film.php>Odswiez</a></font>"; }
else {
}
?>
Wyszukiwanie:
<?php
$link = pg_connect("user= dbname= host= password= port=54321"); if($stan=='szukaj') {
$zapytanie = pg_query($link,"SELECT * FROM filmy where tytul like "%$znajdz%" or gatunek like "%$znajdz%" or rok like "%$znajdz%""); {
echo'<table border=0 width=780 cellspacing=1 cellpadding=2><tr>'; echo"<td height=21 width=301 align=center bordercolor=#C0C0C0><font face=Verdana size=1>{$wiersz['tytul']}</td>"; echo"<td height=21 width=113 align=center bordercolor=#C0C0C0><font face=Verdana size=1>{$wiersz['gatunek']}</td>"; echo"<td height=21 width=81 align=center bordercolor=#C0C0C0><font face=Verdana size=1>{$wiersz['rok']}</td>"; echo"<td height=21 width=86 align=center bordercolor=#C0C0C0><font face=Verdana size=1>{$wiersz['dlugosc']}</td>"; echo"<td height=21 width=57 align=center bordercolor=#C0C0C0><font face=Verdana size=1>{$wiersz['format']}</td>"; echo"<td height=21 width=81 align=center bordercolor=#C0C0C0><font face=Verdana size=1>{$wiersz['rozmiar']}</td>"; }
}
else {
echo "</table><center><br><form method=get action=szukaj.php><input type=text name=znajdz size=20><input type=submit value=szukaj name=stan></form></center>"; }
?>
Ten post edytował Smyk 22.01.2006, 19:41:12