przykladowe php mysql


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 '
Poprawa rekordu:';
print '';
print ' print 'name="username" value="'.$username.'" />';
print '';
print '';
print '';
print '';
print '';
print '
Login:
Kategoria:';
print '
print 'value="'.$category;
print '" />
Miasto: print 'name="city" value="'.$city.'" />
Treść:
Wiek:
E-mail:
Numer GG:
Telefon:
';
} 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 "";
print "";
print "";
print "";
print "";
print "";
print "";
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 "";
print "";
print "";
print "";
print "";
print "";
print "\n";
}
print "
Login:Kategoria:Miasto:Treść:Wiek:E-mail:Numer GG:Telefon:
$username$category$city$content$age$email$gg_number$phone_number";
print "skasuj
";
print '
Nowy rekord:';
print '';
print '';
print '';
print '';
print '';
print '';
print '';
print '';
print '';
print '
Login: print 'name="login" />
Kategoria: print 'type="text" name="category" />
Miasto:
Treść:
Wiek:
E-mail:
Numer GG:
Telefon:
';


Wyszukiwarka

Podobne podstrony:
PHP i MySQL Dla kazdego
PHP i MySQL Wprowadzenie Wydanie II
PHP i MySQL Witryna WWW oparta na bazie danych Wydanie IV
PHP i MySQL Dla kazdego Wydanie II phmdk2
PHP i MySQL Tworzenie aplikacji WWW phmsap
helion php i mysql tworzenie sklepów internetowych
PHP 5 i MySQL Zastosowania e commerce
Linux Web Solution php mySql Apache
PHP i MySQL Dynamiczne strony WWW Szybki start Wydanie II
Dynamic Site with PHP MySQL

więcej podobnych podstron