Database fields are disappearing from the screen???
Posted: Fri Nov 03, 2006 4:32 pm
feyd | Please use
This code is for checking to see if the user has leave any field blank, etc:
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
When I test the following codes most of the database fields disappear.
Before I click on the order button it starts off at [url=http://www.blueguminteractive.biz/example1.htm]this page[/url]. Then when I click on the order button and when the combo boxes aren't selected it goes to [url=http://www.blueguminteractive.biz/example2.htm]this screenshot[/url]. Can someone please tell me why and how I can fix it? Thanks in advance.
This code is for displaying the form:Code: Select all
echo "<div class=leftbox><h1>".$row['productname']."</h1>";
echo "<img src=/simplystuck/images/".$row['mainphoto']."></div>";
// display the description
echo "<div class=rightbox>".$row['description'];
// display the bullets
echo "<ul><li>".$row['bullet1']."</li>";
echo "<li>".$row['bullet2']."</li>";
if (!empty($row['bullet3'])) {
echo "<li>".$row['bullet3']."</li>";
if (!empty($row['bullet4'])) {
echo "<li>".$row['bullet4']."</li>";
}
if (!empty($row['bullet5'])) {
echo "<li>".$row['bullet5']."</li>";
}
if (!empty($row['bullet6'])) {
echo "<li>".$row['bullet6']."</li>";
}
echo "</ul>";
}
if (!empty($row['extrainfo1'])) {
echo $row['extrainfo1'];
}
echo "<br /><b>Product Information</b><br/ >";
echo "<b>Pack Sizes</b>: ".$row['packsize1']." / ";
if (!empty($row['packsize2'])) {
echo $row['packsize2']." / ";
}
if (!empty($row['packsize3'])) {
echo $row['packsize3'];
}
echo " labels<br />";
if (!empty($row['colour1'])) {
echo "<b>Pack Colours</b>: ";
echo $row['colour1'].", ";
}
if (!empty($row['colour2'])) {
echo $row['colour2'].", ";
}
if (!empty($row['colour3'])) {
echo $row['colour3'].", ";
}
if (!empty($row['colour4'])) {
echo $row['colour4'].", ";
}
if (!empty($row['colour5'])) {
echo $row['colour5']."<br />";
}
if (!empty($row['icon1'])) {
echo "<b>Icons</b>: ".$row['icon1'].", ";
}
if (!empty($row['icon2'])) {
echo $row['icon2'].", ";
}
if (!empty($row['icon2'])) {
echo $row['icon3'].", ";
}
if (!empty($row['icon2'])) {
echo $row['icon4'];
}
?>
<br><br>Please choose from the options:<br>
<br><b>Pack size</b>:
<select name="selectpacksize" id="selectpacksize">
<option value="none" selected>Please select</option>
<?php
print "<option value=".$row['packsize1'].">".$row['packsize1']." labels... + AU".$row['price1']."</option>";
if (!empty($row['packsize2'])) {
print "<option value=".$row['packsize2'].">".$row['packsize2']." labels... + AU".$row['price2']."</option>";
}
if (!empty($row['packsize3'])) {
print "<option value=".$row['packsize3'].">".$row['packsize3']." labels... + AU".$row['price3']."</option>";
}
?>
</select>
<?php
if (!empty($row['colour1'])) {
echo "<br /><b>Colour</b>: ";
print "<select name=\"selectcolour\" id=\"selectcolour\">";
print "<option value=\"none\" selected>Please select</option>";
//while($row = mysql_fetch_array($sql)){
print "<option value=".$row['colour1'].">".$row['colour1']."</option>";
if (!empty($row['colour2'])) {
print "<option value=".$row['colour2'].">".$row['colour2']."</option>";
}
if (!empty($row['colour3'])) {
print "<option value=".$row['colour3'].">".$row['colour3']."</option>";
}
if (!empty($row['colour4'])) {
print "<option value=".$row['colour4'].">".$row['colour4']."</option>";
}
if (!empty($row['colour5'])) {
print "<option value=".$row['colour5'].">".$row['colour5']."</option>";
}
//}
print "</select>";
}
if (!empty($row['icon1'])) {
echo "<br /><b>Icon</b>: ";
//$sql = mysql_query("SELECT * FROM `tbl_product` WHERE pd_id = $pd_id") or die ("Could not query because: " . mysql_error());
print "<select name=\"selecticon\" id=\"selecticon\">";
print "<option value=\"none\" selected>Please select</option>";
//while($row = mysql_fetch_array($sql)){
print "<option value=".$row['icon1'].">".$row['icon1']."</option>";
if (!empty($row['icon2'])) {
print "<option value=".$row['icon2'].">".$row['icon2']."</option>";
}
if (!empty($row['icon3'])) {
print "<option value=".$row['icon3'].">".$row['icon3']."</option>";
}
if (!empty($row['icon4'])) {
print "<option value=".$row['icon4'].">".$row['icon4']."</option>";
}
//}
print "</select>";
}
echo "<br /><br />".$row['icon1']." <img src=/simplystuck/images/".$row['imagefile1'].">".$row['icon2']."<img src=/simplystuck/images/".$row['imagefile2'].">".$row['icon3']."<img src=/simplystuck/images/".$row['imagefile3'].">".$row['icon4']."<img src=/simplystuck/images/".$row['imagefile4'].">";
//if (!empty($row['']))) {
//echo "<br /><br /><b>Name to be printed (max 20 characters)</b>: ";
//echo "";
//}
// display the order button
echo "<br /><br /><input type=submit name=order value=ORDER></div>";
?>
</form>
<?php
mysql_close();Code: Select all
if (isset($_POST['order'])) {
if ($selectpacksize == 'none') {
$arrErrors['selectpacksize'] = 'Please select a pack size.';
}
//if (!empty($row['colour'])) {
if ($selectcolour == 'none') {
$arrErrors['selectcolour'] = 'Please select a colour.';
}
//}
//if (!empty($row['icon'])) {
if ($selecticon == 'none') {
$arrErrors['selecticon'] = 'Please select an icon.';
}
//}
if (count($arrErrors) == 0) {
// check to see if the product exists in the cart table
$sql = mysql_query("SELECT * FROM `tbl_cart` WHERE `username` = '$username' AND `pd_id` = '$pd_id'") or die ("Could not query because: ".mysql_error());
$check = mysql_num_rows($sql);
if ($check >= 1) {
// if the product is in the database then increase the quantity
$insertqty = "UPDATE `tbl_cart` SET `ct_qty` = `ct_qty + 1` WHERE `username` = '$username' AND `pd_id` = '$pd_id'" or die("Could not update because: ".mysql_error());
}
// today's date
$date = time();
//$query2 = "SELECT * FROM `tbl_product` WHERE `pd_id` = '$pd_id'";
//$r2= mysql_query($query2) or die('Query error: ' .mysql_error());
//$row2= mysql_fetch_assoc($r2);
//$pd_id = $row2['pd_id'];
//$pd_id = $_GET['pd_id'];
$insertproduct = "INSERT INTO `tbl_cart` (`ct_id`, `ct_qty`, `ct_date`, `username`, `pd_id`, `packsize`, `colour`, `icon`, `name`, `address1`, `address2`, `address3`, `address4`, `address5`) VALUES (0, 'ct_qty + 1', '$date', '$username', '$pd_id', '$selectpacksize', '$selectcolour', '$selecticon', '$nameprint', '$address1', '$address2', '$address3', '$address4', '$address5')";
if (mysql_query ($insertproduct)) {
header ('Location: viewcart.php?username='.$row['username']);
} else {
print "<p>Could not add the entry because: <b>" . mysql_error() . "</b>. The query was $insert.</p>";
}
} else {
// The error array had something in it. There was an error.
// Start adding error text to an error string.
$strError = '<div class="formerror"><p>Please check the following and try again:</p><ul>';
// Get each error and add it to the error string
// as a list item.
foreach ($arrErrors as $error) {
$strError .= "<li>$error</li>";
}
$strError .= '</ul></div>';
}
}feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]