Step one: choose the type of 'Special'
Step two: choose a product for the special
Step three: add the content of the special and save it to the DB
I am using DreamWeaver here so there will be some DW specific coding as well as my own.
I will only post the relavent bits of code. The first bit is the container page that calls various includes to accomplich the steps above.
Code: Select all
<?php
if (!$_POSTї'type']) {
include($_SERVERї'DOCUMENT_ROOT']."/assets/includes/chooseType.php");
} elseif ($_POSTї'type'] == "product") {
print "The type of special is: " . $_POSTї'type'] . "<br>";
include($_SERVERї'DOCUMENT_ROOT']."/assets/includes/chooseProduct.php");
} elseif (($_POSTї'type'] == "product") && ($_POSTї'select'])) {
print "The product id is: " . $_POSTї'select'] . "<br>";
print "Product Selected - Load addProductSpecials.php";
include($_SERVERї'DOCUMENT_ROOT']."/assets/includes/addProductSpecial.php");
} elseif ($_POSTї'type'] == "general") {
include($_SERVERї'DOCUMENT_ROOT']."/assets/includes/addGeneralSpecial.php");
}
?>This include simply presents the user a choice of a 'Prioduct Special' or a 'General Special':
Code: Select all
<form ACTION="<?php $_SERVERї'PHP_SELF'] ?>" METHOD="post" NAME="chooseType" ID="chooseType">
<table WIDTH="50%" BORDER="0" CELLSPACING="1" CELLPADDING="3">
<tr><td CLASS="darkTBLHdr">Choose the type of special you wish to create:</td>
<td><p><label><input TYPE="radio" NAME="type" VALUE="product">Product</label><br>
<label><input TYPE="radio" NAME="type" VALUE="general">General</label>
<br></p></td></tr><tr><td align="left"><a HREF="/vsadmin/adminSpecials.php">Back To Main</a></td><td><input TYPE="submit" NAME="Submit" VALUE="Next"></td></tr></table></form>Code: Select all
<?php require_once($_SERVERї'DOCUMENT_ROOT'] . '/Connections/rr.php'); ?>
<?php
mysql_select_db($database_rr, $rr);
$query_rsSpecials = "SELECT products.pID, products.pName, products.pImage, products.pPrice, specials.id, specials.type, specials.specialPrice, specials.idname, specials.head, specials.info_one, specials.info_two, specials.buttons, specials.s_date, specials.e_date FROM products, specials";
$rsSpecials = mysql_query($query_rsSpecials, $rr) or die(mysql_error());
$row_rsSpecials = mysql_fetch_assoc($rsSpecials);
$totalRows_rsSpecials = mysql_num_rows($rsSpecials);
?>
<?php echo $_SERVERї'PHP_SELF']; ?>
<form ACTION=<?php echo $_SERVERї'PHP_SELF']; ?>?pID=<?php echo $_POSTї'select']; ?> METHOD="post" NAME="chooseProduct">
<table WIDTH="50%" BORDER="0" CELLSPACING="1" CELLPADDING="3">
<tr><td HEIGHT="31" CLASS="darkTBLHdr">Choose the product you wish to use for the special:</td>
<td>
<select NAME="select" ID="select">
<?php
do {
?>
<option value="<?php echo $row_rsSpecialsї'pID']?>"<?php if (!(strcmp($row_rsSpecialsї'pID'], $row_rsSpecialsї'pName']))) {echo "SELECTED";} ?>><?php echo $row_rsSpecialsї'pName']?></option>
<?php
} while ($row_rsSpecials = mysql_fetch_assoc($rsSpecials));
$rows = mysql_num_rows($rsSpecials);
if($rows > 0) {
mysql_data_seek($rsSpecials, 0);
$row_rsSpecials = mysql_fetch_assoc($rsSpecials);
}
?>
</select>
</td></tr><tr><td><input TYPE="submit" NAME="Submit" VALUE="Next">
<input NAME="type" TYPE="hidden" ID="type" VALUE="<?php echo $_POSTї'type'] ?>">
<input NAME="pID" TYPE="hidden" ID="pID" VALUE="<?php echo $_POSTї'pID'] ?>"></td>
<td><?php echo $_POSTї'type']; ?> <br> <?php echo $_POSTї'select']; ?></td>
</tr></table>
</form>
<?php
mysql_free_result($rsSpecials);
?>I am sure by this time my scripts are full of error as I have been trying to solve this for a bit now. I don't think at this point I could see the errors if I fell on them. Might just have to start from scratch.
Anyway, I would appreciate it if someone sees the error of my ways ... that they would let me know and sorry for the long ass post
Dave