- Impact
- 18
I bet its really simple. Anyway the message that pops up is "Something Wrong" which means the mysql query isn't working, but I cannot find anything wrong with anything. 
Please help!
Please help!
PHP:
<?php
// edit.php! :) woo!
include "../../config.php";
if($_POST['url']){
// posted the form...
$id = $_REQUEST['id'];
$name = $_POST['name'];
$url = $_POST['url'];
$category = $_POST['category'];
$description = $_POST['description'];
$keywords = $_POST['keywords'];
$image = $_POST['image'];
$tallbanner = $_POST['tall_banner'];
$longbanner = $_POST['long_banner'];
$sql = "UPDATE pd_shops SET name='$name', description='$description', keywords='$keywords', url='$url', category='$category', image='$image', tall_banner='$tallbanner', wide_banner='$widebanner' WHERE id='$id'";
$result = mysql_query($sql);
if($result){
$message = "Successfully Changed!";
}
else{
$message = "Something Wrong! :-(";
}
}
if(isset($_REQUEST['id']) && !isset($_POST['id'])){
$id = $_REQUEST['id'];
}
$sql = "SELECT * FROM pd_shops WHERE id='$id'";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
$name = $row['name'];
$url = $row['url'];
$category = $row['category'];
$description = $row['description'];
$keywords = $row['keywords'];
$image = $row['image'];
$tallbanner = $row['tall_banner'];
$widebanner = $row['wide_banner'];
if(isset($message)){
$script = "yes";
}
else{
$script = "no";
}
?>
<html>
<head>
<title>Admin Page</title>
<style>
body{
font-family: arial, tahoma, serif;
}
</style>
<?php
if($script == "yes"){
echo "<script>
alert('$message');
</script>";
}
?>
</head>
<body>
<table>
<tr>
<td colspan="2" align="center"><b>Admin Center</b></td>
</tr>
<tr>
<td width="200"><a href="../categories/index.php">Categories</a></td>
<td rowspan="2">
<form method="post" action="edit.php?id=<?php echo $id; ?>">
<table>
<tr>
<td colspan="2" align="center"><b>EDIT "<?php echo $name; ?>"</b></td>
</tr>
<tr>
<td>Name:</td>
<td><input name="name" value="<?php echo $name; ?>" /></td>
</tr>
<tr>
<td>Url:</td>
<td><input name="url" value="<?php echo $url; ?>" /> - <a href="<?php echo $url; ?>" target="_blank">OPEN IN NEW WINDOW</a></td>
</tr>
<tr>
<td>Category:</td>
<td>
<?php
// this is where the clever bit comes in... la la la
echo '<select name="category">';
$sql = "SELECT * FROM pd_categories ORDER BY name ASC";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)){
echo '<option value="';
echo $row['id'];
if($category == $row['id']){
echo '" selected>';
}
else{
echo '">';
}
echo $row['name'];
echo '</option>';
}
echo '</select>';
?>
</td>
</tr>
<tr>
<td>Description:</td>
<td><textarea name="description"><?php echo $description; ?></textarea></td>
</tr>
<tr>
<td>Keywords:</td>
<td><input name="keywords" value="<?php echo $keywords; ?>" /></td>
</tr>
<tr>
<td>Image:</td>
<td><input name="image" value="<?php echo $image; ?>" /></td>
</tr>
<tr>
<td></td>
<td><?php
if(!empty($image)){
echo '<img src="'.$image.'" />';
}
else{
echo '<font color="red">NO IMAGE!</font>';
}
?></td>
</tr>
<tr>
<td>Tall Banner</td>
<td><input name="tall_banner" value="<?php echo $tallbanner; ?>" /></td>
</tr>
<tr>
<td></td>
<td><?php
if(!empty($tallbanner)){
echo '<img src="'.$tallbanner.'" />';
}
else{
echo '<font color="red">NO TALL BANNER!</font>';
}
?></td>
</tr>
<tr>
<td>Wide Banner</td>
<td><input name="long_banner" value="<?php echo $longbanner; ?>" /></td>
</tr>
<tr>
<td></td>
<td><?php
if(!empty($longbanner)){
echo '<img src="'.$longbanner.'" />';
}
else{
echo '<font color="red">NO WIDE BANNER!</font>';
}
?></td>
</tr>
<tr>
<td></td>
<td><input type="hidden" name="id" value="<?php echo $id; ?>" /><input type="submit" value="Submit" /></td>
</tr>
</table>
</form>
</td>
</tr>
<tr>
<td><a href="index.php">Shops</a></td>
</tr>
</table>
</body>
</html>









