| | |
| Stránka: 1 z 1
| [ Príspevkov: 3 ] | |
Autor | Správa |
---|
Registrovaný: 22.01.11 Prihlásený: 03.11.11 Príspevky: 83 Témy: 8 |
čaute .. mám taký problem mam :
mam vytvorenu v databaze tabulku categories kde neviem z akeho dovodu mi nechce to zmenit :
Edit form.:
Kód: <html> <?php
include('includes/functions.php');
$cat = getCat($_GET['id']);
?> <head> <title>Untitled Document</title> </head> <body> <form action="doEditC.php" method="post"> <table> <tr> <td><label for="CatName">Name</label></td><td><input type="text" name="CatName" value="<?php echo $cat['Title']; ?>"/></td> </tr> <tr> <td><label for="CatDesc">Description</label></td><td><input type="text" name="CatDesc" value="<?php echo $cat['Description']; ?>" /></td> </tr> <tr><td colspan="2"><input type="submit" name="submit" /></td><td><input type="hidden" name="id" value="<?php echo $_GET['id']; ?>" /></tr> </table> </form> </body> </html>
doeditc.php Kód: <?php include('includes/functions.php');
if(isset($_POST['submit'])) { if(isset($_POST['CatName'])){ editCat($_POST['CatName'],$_POST['CatDesc'], $_POST['$id']); header("Location: cats.php"); } else { echo "please set a category name!"; include('addCat.php'); } } else { header("Location: addCat.php"); }
?> functions.php¨¨ Kód: function getCats() { $query = mysql_query("SELECT * FROM categories") or die(mysql_error()); if(mysql_num_rows($query) == 0) { echo "<tr><td colspan=\"3\">No Categories Were Found!</td></tr>"; } else { while($cat = mysql_fetch_assoc($query)){ echo "<tr><td>" . $cat['Title'] . "</td><td>" . $cat['Description'] . "</td><td><a href=\"deleteCat.php?id=" . $cat['ID'] . "\">Delete</a><br /><a href=\"editCat.php?id=" . $cat['ID'] . "\">Edit</a></td></tr>"; } } }
function getCat($id) { $id = (int) $id; $query = mysql_query("SELECT * FROM categories WHERE ID = '$id'") or die(mysql_error()); return mysql_fetch_assoc($query); }
function addCat($cName, $cDesc) { $query = mysql_query("INSERT INTO categories VALUES (null,'$cName','$cDesc')") or die(mysql_error());
}
function editCat($cName, $cDesc, $id) { $id = (int) $id; $query = mysql_query("UPDATE categories SET Title = '$cName', Description = '$cDesc' WHERE ID = '$id'") or die(mysql_error()); header("Location: cats.php");
}
za vasu pomoc vopred dakujem [/quote]
|
|
Registrovaný: 27.07.07 Príspevky: 3948 Témy: 51 Bydlisko: Bratislava |
chyba je zrejme tu: $_POST['$id'] - dolar pred id tam nema byt
_________________ NTB: Acer Aspire 4820TG 14" | CPU: Intel Core i5 2,53 GHz | VGA: ATI Mobility Radeon HD5650 1GB | RAM: 8GB DDR3 1066 MHz | HDD: 1TB SSD WD BLUE |
|
Registrovaný: 22.01.11 Prihlásený: 03.11.11 Príspevky: 83 Témy: 8 |
stenley píše: chyba je zrejme tu: $_POST['$id'] - dolar pred id tam nema byt
Diky funguje !
|
|
| Stránka: 1 z 1
| [ Príspevkov: 3 ] | |
| Nemôžete zakladať nové témy v tomto fóre Nemôžete odpovedať na témy v tomto fóre Nemôžete upravovať svoje príspevky v tomto fóre Nemôžete mazať svoje príspevky v tomto fóre
|
|