close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Dynamic Form Menu

Thread began 8/18/2012 3:55 pm by Loretta439108 | Last modified 8/22/2012 1:39 pm by Loretta439108 | 1405 views | 6 replies

Loretta439108

Dynamic Form Menu

Hi Jason,

This is a bare-bones page to test the code on before I add a cart to my product pages.
I'm also trying to figure out how to add the individual sizes and prices into the repeating section underneath the item description, but it won't allow "nesting".

<?php require_once('Connections/connSpectrum.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

mysql_select_db($database_connSpectrum, $connSpectrum);
$query_rsItems = "SELECT ItemID, ItemCatID, ItemName, ItemDesc, ItemSKU, ItemImage, FROM items ORDER BY ItemID ASC";
$rsItems = mysql_query($query_rsItems, $connSpectrum) or die(mysql_error());
$row_rsItems = mysql_fetch_assoc($rsItems);
$totalRows_rsItems = mysql_num_rows($rsItems);

$varItem_rsSizes = "1";
if (isset($row_rsItems['ItemID'])) {
$varItem_rsSizes = $row_rsItems['ItemID'];
}
mysql_select_db($database_connSpectrum, $connSpectrum);
$query_rsSizes = sprintf("SELECT items.ItemID, options.OptionID, options.Option, options.OptionPrice, options.OptionWeight FROM items LEFT OUTER JOIN itemoptions ON items.ItemID = itemoptions.ItemID INNER JOIN options ON itemoptions.OptionID = options.OptionID WHERE items.ItemID = %s", GetSQLValueString($varItem_rsSizes, "int"));
$rsSizes = mysql_query($query_rsSizes, $connSpectrum) or die(mysql_error());
$row_rsSizes = mysql_fetch_assoc($rsSizes);
$totalRows_rsSizes = mysql_num_rows($rsSizes);
?>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Product Page</title>
<link href="css/global.css" rel="stylesheet" type="text/css" />
</head>

<body background="img/metgrad.jpg">
<div id="container">
<div id="banner">
<p><img src="img/header2.gif" alt="" width="950" height="141" longdesc="http://www.fww.com/" /></p>
</div>



<?php do { ?>
<div class="ul">
<p><?php echo $row_rsItems['ItemName']; ?></p>
<p><?php echo $row_rsItems['ItemDesc']; ?></p>
<p><?php echo $row_rsItems['ItemSKU']; ?></p>
<p><img src="img/small/<?php echo $row_rsItems['ItemImage']; ?>" alt="image" /></p>
<p><?php echo $row_rsSizes['Option']; ?></p>
<form id="form1" name="form1" method="post" action="">
<label for="sizes"></label>
<select name="sizes" id="sizes">
<option value="null">--Please select a size--</option>
<?php
do {
?>
<option value="<?php echo $row_rsSizes['OptionID']?>"><?php echo $row_rsSizes['Option']?></option>
<?php
} while ($row_rsSizes = mysql_fetch_assoc($rsSizes));
$rows = mysql_num_rows($rsSizes);
if($rows > 0) {
mysql_data_seek($rsSizes, 0);
$row_rsSizes = mysql_fetch_assoc($rsSizes);
}
?>
</select>
</form>
<p>&nbsp;</p>
</div>
<?php } while ($row_rsItems = mysql_fetch_assoc($rsItems)); ?>
</div>
</body>
</html>
<?php
mysql_free_result($rsItems);

mysql_free_result($rsSizes);
?>

Thanks so much!

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...