<script type="text/javascript">
<!--
$(document).ready(function() {
$('#markItUp').markItUp(mySettings);
});
-->
</script>
<?php
require('../connect.php');
$request_id = $_REQUEST['id'];
if($_POST['cmd'] == "save") {
$title = $_POST['title'];
$date = $_POST['date'];
$price = $_POST['price'];
$summary = $_POST['summary'];
$description = $_POST['description'];
$default_str = $_POST['default'];
$id_str = $_POST['id'];
for ($i = 0; $i < count($default_str); $i++) {
$default = $_POST['default'][$i];
$id = $_POST['id'][$i];
$query = "UPDATE uploads SET `default`='$default' WHERE id='$id'";
mysql_query($query) or die(mysql_error());
}
mysql_query("UPDATE listings SET title='$title' WHERE id='$request_id'") or die(mysql_error());
mysql_query("UPDATE listings SET date='$date' WHERE id='$request_id'") or die(mysql_error());
mysql_query("UPDATE listings SET price='$price' WHERE id='$request_id'") or die(mysql_error());
mysql_query("UPDATE listings SET summary='$summary' WHERE id='$request_id'") or die(mysql_error());
mysql_query("UPDATE listings SET description='$description' WHERE id='$request_id'") or die(mysql_error());
echo '
<script type="text/javascript" language="javascript">
$(function() {
feedBackMessage("formMessage", "positive", "Listing has been updated");
});
</script>';
}
$result = mysql_query("SELECT * FROM listings WHERE id='$request_id'");
while($listing = mysql_fetch_array($result)) {
?>
<div id="form" class="component red">
<h2>Edit a Listing</h2>
<div class="component lightBorder">
<p id="formMessage"></p>
<form id="editListing" name="editListing" action="<?=$_SERVER['php_self']?>" onsubmit="return validateForm(this);" method="post">
<input type="hidden" name="cmd" value="save" style="border: 0px; background: transparent;"/>
<p style="float: right;"><span style="color: red;">*</span> Indicates required fields</p>
<p style="clear: right;">
<label><span style="color: red;">*</span> Title:</label>
<span style="display: block; margin-left: 110px;">
<input type="text" name="title" value="<?=$listing['title']?>" maxlength="250" class="required" style="width: 97%;" />
</span>
</p>
<p>
<label><span style="color: red;">*</span> Date:</label>
<span style="display: block; margin-left: 110px;">
<input type="text" name="date" value="<?=$listing['date']?>" maxlength="10" class="required" style="width: 97%;" />
</span>
</p>
<p>
<label><span style="color: red;">*</span> Price:</label>
<span style="display: block; margin-left: 110px;">
<input type="text" name="price" value="<?=$listing['price']?>" maxlength="250" class="required" style="width: 97%;" />
</span>
</p>
<p>
<label>Summary:</label>
<span style="display: block; margin-left: 110px;">
<textarea name="summary" id="summary" rows="5" cols="40" style="width: 97%;"><?=$listing['summary']?></textarea>
</span>
</p>
<p>
<label>Description:</label>
<textarea id="markItUp" class="markItUpEditor" name="description" rows="5" cols="40"><?=$listing['description']?></textarea>
</p>
<p>
<label>Images:</label>
<span class="listingImages" style="display: block; margin-left: 110px;">
<?
$request_lid = $listing['lid'];
$result1 = mysql_query("SELECT * FROM uploads WHERE listing='$request_lid'") or die (mysql_error());
$i=0;
while ($images = mysql_fetch_array($result1)) {
$i++;
echo "<span class='item'>";
echo "<a href='{$images['upload_dir']}{$images['filename']}' title='{$images['filename']}' class='thickbox' rel='listingImages' style='text-decoration: none;'><img src='{$images['upload_dir']}{$images['filename']}' width='100' border='0' alt='{$images['filename']}' style='margin-bottom: 5px;' /></a><br />";
echo "<input type='hidden' name='id[]' value='".$images['id']."'/><br />";
echo "<input type='text' size='1' id='default' name='default[]' value='{$images['default']}'/>";
echo "</span>";
}
?>
<br style="clear: left;" />
</span>
</p>
<input class="submit" type="submit" name="submit" value="Submit" />
</form>
</div>
</div>
<? } mysql_close($connection); ?>
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE