mysql_connect ("localhost", "zja24_anonse", "anonse") or
die ("Nie można połączyć z MySQL");
mysql_select_db ("zja24_anonse") or
die ("Nie można połączyć z bazą");
if (isSet($_POST['co']) && $_POST['co'] == 'dodaj') {
if (isSet($_POST['username']) && isSet($_POST['category']) && isSet($_POST['city']) && isSet($_POST['content']) &&
isSet($_POST['age']) && isSet($_POST['email']) && isSet ($_POST['gg_number']) && isSet ($_POST['phone_number']) ) {
$query = "INSERT INTO ancms (username, category, ";
$query .= "city, content, age, email, gg_number, phone_number) valueS ('".$_POST['username']."', '".$_POST['category']."',
'".$_POST['city']."', '".$_POST['content']."', '".$_POST['age']."', '".$_POST['email']."', '".$_POST['gg_number']."',
'".$_POST['phone_number']."');";
$wynik = mysql_query ($query);
}
} elseif (isSet($_POST['co']) && $_POST['co'] == 'popraw') {
if ($_POST['username'] && $_POST['category'] && $_POST['city'] && $_POST['content'] && $_POST['age'] && $_POST['email'] &&
$_POST['gg_number'] && $_POST['phone_number']) {
$query = "UPDATE ancms SET username='".$_POST
['username']."',category=";
$query .= "'".$_POST['category']."', '".$_POST['city']."', content='".$_POST
['content']."', age='".$_POST['age']."', email='".$_POST['email']."', gg_number='".$_POST['gg_number']."',
phone_number='".$_POST['phone_number']."' WHERE id='".$_POST['id']."';";
$wynik = mysql_query ($query);
}
} elseif (isSet($_GET['co']) && $_GET['co'] == 'edytuj') {
$query = "SELECT id, username, category, city, content, age, email, gg_number, phone_number FROM ancms WHERE id='".$_GET
['id']."';";
$wynik = mysql_query ($query);
$rekord = mysql_fetch_assoc($wynik);
$id = $rekord['id']; $username = $rekord['username']; $category = $rekord['category']; $city = $rekord['city']; $content =
$rekord['content']; $age = $rekord['age']; $email = $rekord['email']; $gg_number = $rekord['gg_number']; $phone_number =
$rekord['phone_number'];
print '
';
} elseif (isSet($_GET['co']) && isSet($_GET['id']) &&
$_GET['co'] == 'skasuj') {
$wynik = mysql_query ("DELETE FROM ancms WHERE id = '".$_GET['id']."';");
}
$wynik = mysql_query ("SELECT id, username, category, city, content, age, email, gg_number, phone_number FROM ancms;") or
die ("błąd w pytaniu");
print "
";
print "Login: | Kategoria: | ";
print "Miasto: | ";
print "Treść: | ";
print "Wiek: | ";
print "E-mail: | ";
print "Numer GG: | ";
print "Telefon: | ";
print " |
\n";
while ($rekord = mysql_fetch_assoc ($wynik)) {
$id = $rekord['id'];
$username = $rekord['username'];
$category = $rekord['category'];
$city = $rekord['city'];
$content = $rekord['content'];
$age = $rekord['age'];
$email = $rekord['email'];
$gg_number = $rekord['gg_number'];
$phone_number = $rekord['phone_number'];
print "$username | $category | ";
print "$city | ";
print "$content | ";
print "$age | ";
print "$email | ";
print "$gg_number | ";
print "$phone_number | "; print "skasuj |
\n";
}
print "
";
print '
';
Wyszukiwarka
Podobne podstrony:
PHP i MySQL Dla kazdegoPHP i MySQL Wprowadzenie Wydanie IIPHP i MySQL Witryna WWW oparta na bazie danych Wydanie IVPHP i MySQL Dla kazdego Wydanie II phmdk2PHP i MySQL Tworzenie aplikacji WWW phmsaphelion php i mysql tworzenie sklepów internetowychPHP 5 i MySQL Zastosowania e commerceLinux Web Solution php mySql ApachePHP i MySQL Dynamiczne strony WWW Szybki start Wydanie IIDynamic Site with PHP MySQLwięcej podobnych podstron