Page 1 of 1

PHP Problem involving Drop Down Menus and Updating SQL

Posted: Sun Mar 25, 2007 4:25 pm
by GOkninski
Hello,

Have been stuck on a PHP problem for the past couple of days and would greatly appreciate some help to overcome a major problem. I'm creating a Stock Administration system that will allow the user to add, edit and delete stock items from an SQL database.

At the moment, if the user adds a new stock item then it is correctly saved to the database. This part works perfectly.

However the problem is when editing an existing stock item. If you select the item and modify it then it picks up the information from the database correctly, but if you dont change anything and straight away save the stock item, then have a look in the database and you will see that all the values that are entered through the use of drop-down boxes has been put to '0' rather then retaining the value originally entered.

Firstly the SQL Code to create the Product Table:

Code: Select all

create table product
(
product_ref						int (6),
product_title					varchar (50),
purchase_cost					float (6,2),
purchase_qty					int (4),
selling_price					float (6,2),
selling_qty						int (4),
product_description				text,
number_in_stock					int (6),
image_ref						varchar (100),
postage_ref						int (6),
manufacturer_ref				int (6),
genre_ref						int (6),
host_system_ref					int (6),
product_type_ref				int (6),
minimum_stock_requirement		int (4),
special_offer					enum ('Yes', 'No'),
appear_on_website				enum ('Yes', 'No'),
Primary Key						(product_ref),
Foreign key						(manufacturer_ref) references manufacturer(manufacturer_ref),
Foreign Key						(genre_ref) references genre (genre_ref),
Foreign Key						(host_system_ref) references host_system (host_system_ref),
Foreign Key						(product_type_ref) references product_type (prodct_type_ref),
Foreign Key						(postage_ref) references postage_cost(postage_ref)
)
The following SQL statement is to create the Host System table. The data within the 'Host System' table is then used to populate one of the drop down lists when adding new stock items.

Code: Select all

create table host_system
(
host_system_ref			int (6) auto_increment,
host_system_name		varChar (100),
Primary Key				(host_system_ref)
)
This next bit of code populates the Host System Table.

Code: Select all

INSERT INTO `host_system` (`host_system_name`) VALUES ('N/A');
INSERT INTO `host_system` (`host_system_name`) VALUES ('32X');
INSERT INTO `host_system` (`host_system_name`) VALUES ('3DO');
INSERT INTO `host_system` (`host_system_name`) VALUES ('Atari 2600 Junior');
INSERT INTO `host_system` (`host_system_name`) VALUES ('Atari 2600');
INSERT INTO `host_system` (`host_system_name`) VALUES ('Atari 5200');
INSERT INTO `host_system` (`host_system_name`) VALUES ('Atari 7800');
INSERT INTO `host_system` (`host_system_name`) VALUES ('CD 32');
INSERT INTO `host_system` (`host_system_name`) VALUES ('Coleco Vision');
INSERT INTO `host_system` (`host_system_name`) VALUES ('Commodore 64');
INSERT INTO `host_system` (`host_system_name`) VALUES ('Dreamcast');
INSERT INTO `host_system` (`host_system_name`) VALUES ('Game Cube');
INSERT INTO `host_system` (`host_system_name`) VALUES ('Game Gear');
INSERT INTO `host_system` (`host_system_name`) VALUES ('GameCom');
INSERT INTO `host_system` (`host_system_name`) VALUES ('GameBoy Advance');
INSERT INTO `host_system` (`host_system_name`) VALUES ('Gameboy Colour');
INSERT INTO `host_system` (`host_system_name`) VALUES ('Gameboy/Gameboy Pocket');
INSERT INTO `host_system` (`host_system_name`) VALUES ('GX4000');
INSERT INTO `host_system` (`host_system_name`) VALUES ('Intellivision');
INSERT INTO `host_system` (`host_system_name`) VALUES ('Jaguar');
INSERT INTO `host_system` (`host_system_name`) VALUES ('Lynx');
INSERT INTO `host_system` (`host_system_name`) VALUES ('Master System');
INSERT INTO `host_system` (`host_system_name`) VALUES ('MegaCD/Sega CD');
INSERT INTO `host_system` (`host_system_name`) VALUES ('MegaDrive');
INSERT INTO `host_system` (`host_system_name`) VALUES ('NeoGeo');
INSERT INTO `host_system` (`host_system_name`) VALUES ('NeoGeo CD');
INSERT INTO `host_system` (`host_system_name`) VALUES ('NeoGeo Pocket');
INSERT INTO `host_system` (`host_system_name`) VALUES ('NeoGeo Pocket Colour');
INSERT INTO `host_system` (`host_system_name`) VALUES ('NES Famicom');
INSERT INTO `host_system` (`host_system_name`) VALUES ('Nintendo 64');
INSERT INTO `host_system` (`host_system_name`) VALUES ('Nomad');
INSERT INTO `host_system` (`host_system_name`) VALUES ('Odyssey2');
INSERT INTO `host_system` (`host_system_name`) VALUES ('PCFX');
INSERT INTO `host_system` (`host_system_name`) VALUES ('Playstation/PSOne');
INSERT INTO `host_system` (`host_system_name`) VALUES ('Playstation 2');
INSERT INTO `host_system` (`host_system_name`) VALUES ('Playstation 3');
INSERT INTO `host_system` (`host_system_name`) VALUES ('Saturn');
INSERT INTO `host_system` (`host_system_name`) VALUES ('SNES/Super Famicom');
INSERT INTO `host_system` (`host_system_name`) VALUES ('SX 32');
INSERT INTO `host_system` (`host_system_name`) VALUES ('Turbo Duo/PC Engine Duo');
INSERT INTO `host_system` (`host_system_name`) VALUES ('Turbo Express');
INSERT INTO `host_system` (`host_system_name`) VALUES ('TurboGrafx 16/PC Engine');
INSERT INTO `host_system` (`host_system_name`) VALUES ('Vectrex');
INSERT INTO `host_system` (`host_system_name`) VALUES ('Videopac G7000');
INSERT INTO `host_system` (`host_system_name`) VALUES ('Virtual Boy');
INSERT INTO `host_system` (`host_system_name`) VALUES ('Wonderswan');
INSERT INTO `host_system` (`host_system_name`) VALUES ('Wii');
INSERT INTO `host_system` (`host_system_name`) VALUES ('Xbox');
INSERT INTO `host_system` (`host_system_name`) VALUES ('Xbox 360');
INSERT INTO `host_system` (`host_system_name`) VALUES ('ZX Spectrum Plus');
INSERT INTO `host_system` (`host_system_name`) VALUES ('ZX Spectrum Plus 2');
INSERT INTO `host_system` (`host_system_name`) VALUES ('ZX Spectrum Plus 3');
INSERT INTO `host_system` (`host_system_name`) VALUES ('ZX Spectrum 128k');
INSERT INTO `host_system` (`host_system_name`) VALUES ('ZX Spectrum 48k');
Next is the code for the AddNewStockItem.php file.

Code: Select all

<?php
include 'DBConnect.php';
?>

<HTML>

<Head>

<link rel="stylesheet" type="text/css" href="css/CreateNewProduct_CSS/BreakingLineOne.css"/>
<link rel="stylesheet" type="text/css" href="css/CreateNewProduct_CSS/BreakingLineTwo.css"/>
<link rel="stylesheet" type="text/css" href="css/CreateNewProduct_CSS/BreakingLineThree.css"/>
<link rel="stylesheet" type="text/css" href="css/CreateNewProduct_CSS/AddNewItemFormatting.css"/>
<link rel="stylesheet" type="text/css" href="css/Buttons/AddNewItemSaveButton.css"/>
<link rel="stylesheet" type="text/css" href="css/Buttons/BrowseFileButtonAddStockItem.css"/>
<link rel="stylesheet" type="text/css" href="css/Buttons/CancelButton.css"/>

<Title>

Create new Stock Listing Item

</Title>

</Head>

<body bgcolor=#B0C4DE>

<a href="StockMaintenance.php" target="MainFrame" title="Return to Stock Listing"
class="CancelButton">Cancel
</A>

<form method="post" action="SubmitStockItem.php">

<table id="BreakingLineOne">
<tr>
<td><hr color="white" noshade width="100" size="2" align="left"></td>
<td>Product Information</td>
<td><hr color="white" noshade width="650" size="2" align="right"></td>
</tr>
</table>

<?php

$sql = 		"SELECT max(product_ref) 
			FROM product";
			
			$result = mysql_query($sql);
						$row = (mysql_result($result, "product_ref"));	

?>

<?php
$ref = ($row)+1;
?>

<div id="FirstLine" div class="Product_Ref">
<label>Product Ref: </label>
<input readonly="readonly" type="text" name="product_ref" value="<?php echo $ref ?>" size="15">
</div>

<div id="SecondLine" div class="Product_Title">
<label>Product Title : </label>
<input type="text"name="product_title" size="30">
</div>

<div id="ThirdLine" div class="Host_System">
<label>Host System : </label>
<select name="Host_System">
<option value="0">Please Select an Option</option>
<?php
$HostSystemList = "SELECT * FROM `host_system`";
							
					$result = mysql_query($HostSystemList); 
											
					while ($row = mysql_fetch_array($result)) 
					{ 
echo "<option value=".$row['host_system_ref']."name='".$row['host_system_ref']."'>".$row['host_system_name']."</option>\n";
					}
?>	
</select>
</div>

<div id="FifthLine" div class="Manufacturer">
<label>Manufacturer : </label>
<select name="Manufacturer">
<option value="0">Please Select an Option</option>
<?php
$ManufacturerList = "SELECT * FROM `manufacturer`";
							
					$result = mysql_query($ManufacturerList); 
											
					while ($row = mysql_fetch_array($result)) 
					{ 
echo "<option value=".$row['manufacturer_ref']."name='".$row['manufacturer_ref']."'>".$row['manufacturer_name']."</option>\n";
					}
?>	
</select>
</div>

<div id="Type" div class="Product_Type">
<label>Product Type : </label>
<select name="Prod_type">
<option value="0">Please Select an Option</option>
<?php
$Prodtest = "SELECT * FROM `product_type`";
							
					$result = mysql_query($Prodtest); 
											
					while ($row = mysql_fetch_array($result)) 
					{ 
echo "<option value=".$row['product_type_ref']."name='".$row['product_type_ref']."'>".$row['product_type_name']."</option>\n";
					}
?>	
</select>
</div>

<div id="SixthLine" div class="Genre">
<label>Genre : </label>
<select name="Genre">
<option value="0">Please Select an Option</option>
<?php
$GenreList = "SELECT * FROM `genre`";
							
					$result = mysql_query($GenreList); 
											
					while ($row = mysql_fetch_array($result)) 
					{ 
echo "<option value=".$row['genre_ref']." name='".$row['genre_ref']."'>".$row['genre_name']."</option>\n";
					}
?>	
</select>
</div>

<div id="Postage" div class="postage_cost">
<label>Postage Cost : </label>
<select name="Cost_of_Postage">
<option value="0">Please Select an Option</option>
<?php
$Postagetest = "SELECT * FROM `postage_cost`";
							
					$result = mysql_query($Postagetest); 
											
					while ($row = mysql_fetch_array($result)) 
					{ 
echo "<option value=".$row['postage_ref']."name='".$row['postage_ref']."'>".$row['postage_cost']."</option>\n";
					}
?>	
</select>
</div>


<div id="SeventhLine" div class="ImageLocation">
<label>Image Location : </label>
</div>
<input type="file" class="BrowseImageButton" name="Image_Location" size="23"> </input>

<div id="ProdDescr" div class="Product_Description_Label">
<label>Product Description:</label>
</div>

<div id="EighthLine" div class="Product_Description">
<textarea cols="100" rows="2" name="product_description" align="top">
</textarea>
</div>

<div id="EighteenthLine" div class="Special_Offer">
<label>Special Offer:</label>
<input type="radio" name="SpecialOffer" value="Yes">Yes
<input type="radio" name="SpecialOffer" checked="yes" value="No">No
</div>

<div id="WebInclude" div class="Website_Include">
<label>Add to Website:</label>
<input type="radio" name="Web_Include" value="Yes">Yes
<input type="radio" name="Web_Include" checked="yes" value="No">No
</div>

<table id="BreakingLineTwo">
<tr>
<td><hr color="white" noshade width="100" size="2" align="left"></td>
<td>Pricing & Quantities</td>
<td><hr color="white" noshade width="650" size="2" align="right"></td>
</tr>
</table>

<div id="NinethLine" div class="Purchase_Price">
<label>Purchase Price : </label>
<input type="text"name="purchase_price" size="8">
</div>

<div id="TenthLine" div class="Purchase_Quantity">
<label>Purchase Quantity: </label>
<input type="text"name="purchase_quantity" size="8">
</div>

<div id="EleventhLine" div class="Selling_Price">
<label>Selling Price : </label>
<input type="text"name="selling_price" size="8">
</div>

<div id="TwelthLine" div class="Selling_Quantity">
<label>Selling Quantity: </label>
<input type="text"name="selling_quantity" size="8">
</div>

<table id="BreakingLineThree">
<tr>
<td><hr color="white" noshade width="100" size="2" align="left"></td>
<td>Product Stock Information</td>
<td><hr color="white" noshade width="590" size="2" align="right"></td>
</tr>
</table>

<div id="ThirteenthLine" div class="Minimum_Stock_Level">
<label> Minimum Stock Level: </label>
<input type="text"name="minimum_stock_level" size="6">
</div>

<div id="FourteenthLine" div class="Current_Stock_Level">
<label>Current Stock Level: </label>
<input type="text"name="current_stock_level" size="6">
</div>

<input class="SaveButton" type="submit" value="Save">

<input class="ClearButton" type="reset" value="Clear Details">

</Body>

</HTML>
And here is the code for the EditStockItem.php file.

Code: Select all

<?php
include 'DBConnect.php';
?>

<HTML>

<Head>

<link rel="stylesheet" type="text/css" href="css/CreateNewProduct_CSS/BreakingLineOne.css"/>
<link rel="stylesheet" type="text/css" href="css/CreateNewProduct_CSS/BreakingLineTwo.css"/>
<link rel="stylesheet" type="text/css" href="css/CreateNewProduct_CSS/BreakingLineThree.css"/>
<link rel="stylesheet" type="text/css" href="css/ModifyStockItemFormatting.css"/>
<link rel="stylesheet" type="text/css" href="css/Buttons/SaveStockItemModificationsButton.css"/>
<link rel="stylesheet" type="text/css" href="css/Buttons/CancelButton.css"/>

<Title>

Edit Stock Item Page

</Title>

</Head>

<Body bgcolor=#B0C4DE>

<?php
$Product = $_REQUEST['action'];

$ProductList = 			"SELECT * FROM `product`, host_system, product_type, manufacturer, genre, postage_cost
						where product_ref = $Product
						and
						product.product_type_ref=product_type.product_type_ref
						and
						product.host_system_ref=host_system.host_system_ref
						and
						product.manufacturer_ref=manufacturer.manufacturer_ref
						and
						product.genre_ref=genre.genre_ref
						and
						product.postage_ref = postage_cost.postage_ref";
												  
						$result = mysql_query($ProductList) 
											or die("Invalid query: " . mysql_query()); 
						$row = mysql_fetch_array($result)
										
?>


<Body bgcolor=#B0C4DE>

<a href="StockItemDetail.php?action=<?php echo $row['product_ref']?>" target="MainFrame" title="Return to Stock Item Details"
class="CancelButton">Cancel
</A>

<form method="post" action="SubmitStockItemModifications.php">

<table id="BreakingLineOne">
<tr>
<td><hr color="white" noshade width="100" size="2" align="left"></td>
<td>Product Information</td>
<td><hr color="white" noshade width="650" size="2" align="right"></td>
</tr>
</table>

<div id="FirstLine" div class="Product_Ref">
<label>Product Ref: </label>
<input readonly="readonly" type="text"name="product_ref" value="<?php echo $row['product_ref']?>" size="6">
</div>

<div id="SecondLine" div class="Product_Title">
<label>Product Title : </label>
<input type="text"name="product_title" value="<?php echo $row['product_title']?>" size="30">
</div>

<div id="ThirdLine" div class="Host_System">
<label>Host System:</label>
<select name="Host_System">
<option value="<?php $row['host_system_ref'];?>" selected> <?php echo $row['host_system_name']?> </option>
option value="0">Please Select an Option</option>
<?php
$HostSystemList = "SELECT * FROM `host_system`";
							
					$result = mysql_query($HostSystemList); 
											
					while ($row = mysql_fetch_array($result)) 
					{ 
echo "<option value=".$row['host_system_ref']."name='".$row['host_system_ref']."'>".$row['host_system_name']."</option>\n";
					}
?>	
</select>
</div>

<div id="FourthLine" div class="Product_Type">
<label>Product Type:</label>
<select name="product_type">
<option value="<?php $row['product_type_ref']?>" selected> <?php echo $row['product_type_name']?> </option>
<option value="1">Game</option>
<option value="2">Retro Game</option>
<option value="3">Console</option>
<option value="4">Retro Console</option>
<option value="5">Accessory</option>
<option value="6">Miscelleneous</option>
</select>
</div>

<div id="FifthLine" div class="Manufacturer">
<label>Manufacturer:</label>
<select name="Manufacturer">
<option value="<?php $row['manufacturer_ref']?>" selected> <?php echo $row['manufacturer_name']?> </option>
<option value="1">Atari</option>
<option value="2">Bandai</option>
<option value="3">Coleco</option>
<option value="4">GCE</option>
<option value="5">Magnavox</option>
<option value="6">Microsoft</option>
<option value="7">NEC</option>
<option value="8">Nintendo</option>
<option value="9">Panasonic</option>
<option value="10">Philips</option>
<option value="11">Sega</option>
<option value="12">Sinclair/Amstrad</option>
<option value="13">Sony</option>
<option value="14">SNK</option>
<option value="15">Tiger</option>
</select>
</div>

<div id="SixthLine" div class="Genre">
<label>Genre:</label>
<select name="Genre">
<option value="<?php $row['genre_ref']?>" selected> <?php echo $row['genre_name']?> </option>
<option value="1">Adventure</option>
<option value="2">Arcade</option>
<option value="3">Driving</option>
<option value="4">Fighting</option>
<option value="5">Flight Sim</option>
<option value="6">Platform</option>
<option value="7">Role Playing</option>
<option value="8">Shoot Em Up</option>
<option value="9">Sport</option>
<option value="10">Strategy</option>
</select>
</Div>

<div id="EighteenthLine" div class="Special_Offer">
<label>Special Offer:</label>
<input type="radio" name="SpecialOffer" value="Yes">Yes
<input type="radio" name="SpecialOffer" value="No">No
</div>

<div id="SeventhLine" div class="ImageLocation">
<label>Image Location : </label>
<input type="file" value="<?php echo $row['image_ref']?>" class="BrowseImageButton" name="Image_Location" size="23"> </input>
</div>

<div id="EighthLine" div class="Product_Description_Title">
<label align="top">Product Description:</label>
</div>

<div id="EighthLine" div class="Product_Description">
<textarea cols="90" rows="2" name="product_description" "/><?php echo $row['product_description']?></textarea>
</div>

<table id="BreakingLineTwo">
<tr>
<td><hr color="white" noshade width="100" size="2" align="left"></td>
<td>Pricing & Quantities</td>
<td><hr color="white" noshade width="650" size="2" align="right"></td>
</tr>
</table>

<div id="NinethLine" div class="Purchase_Price">
<label>Purchase Price : </label>
<input type="text"name="purchase_price" value="<?php echo $row['purchase_cost']?>" size="8">
</div>

<div id="TenthLine" div class="Purchase_Quantity">
<label>Purchase Quantity: </label>
<input type="text"name="purchase_quantity" value="<?php echo $row['purchase_qty']?>" size="8">
</div>

<div id="EleventhLine" div class="Selling_Price">
<label>Selling Price : </label>
<input type="text"name="selling_price" value="<?php echo $row['purchase_qty']?>" size="8">
</div>

<div id="TwelthLine" div class="Selling_Quantity">
<label>Selling Quantity: </label>
<input type="text"name="selling_quantity" value="<?php echo $row['selling_qty']?>" size="8">
</div>

<table id="BreakingLineThree">
<tr>
<td><hr color="white" noshade width="100" size="2" align="left"></td>
<td>Product Stock Information</td>
<td><hr color="white" noshade width="590" size="2" align="right"></td>
</tr>
</table>

<div id="ThirteenthLine" div class="Minimum_Stock_Level">
<label> Minimum Stock Level: </label>
<input type="text"name="minimum_stock_level" value="<?php echo $row['minimum_stock_requirement']?>" size="6">
</div>

<div id="FourteenthLine" div class="Current_Stock_Level">
<label>Current Stock Level: </label>
<input disabled type="text"name="current_stock_level" value="<?php echo $row['number_in_stock']?>" size="6">
</div>

<input class="SaveStockItemModificationsButton" type="submit" value="Save">

<div id="SeventeenthLine" div class="Postage_Cost">
<label>Postage Cost:</label>
<select name="postage_cost">
<option value="<?php $row['postage_ref']?>" selected> <?php echo $row['postage_cost']?> </option>
<option value="1">£0.50</option>
<option value="2">£1.00</option>
<option value="3">£1.50</option>
<option value="4">£2.00</option>
<option value="5">£2.50</option>
<option value="6">£3.00</option>
<option value="7">£3.50</option>
<option value="8">£4.00</option>
<option value="9">£4.50</option>
<option value="10">£5.00</option>
<option value="11">£5.50</option>
<option value="12">£6.00</option>
<option value="13">£6.50</option>
<option value="14">£7.00</option>
<option value="15">£7.50</option>
<option value="16">£8.00</option>
<option value="17">£8.50</option>
<option value="18">£9.00</option>
<option value="19">£9.50</option>
<option value="20">£10.00</option>
<option value="21">£10.50</option>
<option value="22">£11.00</option>
<option value="23">£11.50</option>
<option value="24">£12.00</option>
<option value="25">£12.50</option>
<option value="26">£13.00</option>
<option value="27">£13.50</option>
<option value="28">£14.00</option>
<option value="29">£14.50</option>
<option value="30">£15.00</option>
<option value="31">£15.50</option>
<option value="32">£16.00</option>
<option value="33">£16.50</option>
<option value="34">£17.00</option>
<option value="35">£17.50</option>
<option value="36">£18.00</option>
<option value="37">£18.50</option>
<option value="38">£19.00</option>
<option value="37">£19.50</option>
<option value="38">£20.00</option>
</select>
</div>


<!--
<div id="EighteenthLine" div class="special_offer">
<label>Special Offer</label>
<select name="special_offer">
<option value="0">Please Select an Option</option>
<option value="Yes">Yes</option>
<option value="No">No</option>
</div>
-->

</Body>

</HTML>
This final bit of code is for submitting the modifications that have been made. This file is called SubmitStockItemModifications.php.

Code: Select all

<?php

include 'DBConnect.php';

?>

<Html>

<Head>

<link rel="stylesheet" type="text/css" href="css/ConfirmationMessages.css"/>

<Title>

Submit Stock Item Modification

</Title>

<Body bgcolor=#B0C4DE>

<div class="ModifyDetailsConfirmationMessage">
Item Details Updated
</div>

<?php
$sql =						("UPDATE product set	  
							  product_title = '$_POST[product_title]',
							  purchase_cost = '$_POST[purchase_price]',
							  purchase_qty = '$_POST[purchase_quantity]',
							  selling_price = '$_POST[selling_price]',
							  selling_qty = '$_POST[selling_quantity]',
							  product_description = '$_POST[product_description]',
							  postage_ref = '$_POST[postage_cost]',
							  image_ref = '$_POST[Image_Location]',
							  genre_ref = '$_POST[Genre]',
							  manufacturer_ref = '$_POST[Manufacturer]',
							  host_system_ref = '$_POST[Host_System]',
							  product_type_ref = '$_POST[product_type]',
							  minimum_stock_requirement = '$_POST[minimum_stock_level]'
							  
							  WHERE product_ref = '$_POST[product_ref]'");				

$Update_result = mysql_query($sql) 
				or die("Invalid query: " . mysql_error()); 											
?>			

<META HTTP-EQUIV="Refresh" CONTENT="3; URL=StockMaintenance.php">

</Body>

</Html>
You may notice that the Drop Downs within the EditAStockItem.php file are hardcoded and for AddingNewStockItem.php its being generated from the product table apart from Host System which is still populated from the table. This is because i only just recently changed where the drop downs are getting their information from.

So, as i said before, if i add a new stock item then everything works fine and the information is being written to the table, however, if you edit the stock item however then the fields that have been generated from the drop down lists return to 0.

Apologies for pasting so much code in here, but wanted to give my potential rescuer enough information to go on. If you need any more info then please ask.

I would be exteremyl grateful for someones help!

Cheers,

Greg.

hi

Posted: Mon Mar 26, 2007 12:22 am
by rameshmrgn
have u closed the <form> tag in "AddNewStockItem.php" .... ?

Posted: Mon Mar 26, 2007 6:59 am
by GOkninski
Valid point, matey, but i have tried closing the form on both AddStockItem.php and EditStockItem.php and it hasnt made a difference.

Any additional help would be greatly appreciated as I am desperate to get this sorted.

Greg.

Posted: Mon Mar 26, 2007 8:21 am
by superdezign
You're very open with your code. Most people hide it and only give us the function where the error is.
And, personally, I'd prefer it that way. Less to read.

I didn't read it, but from the sound of your problem, you're not loading the values from the database into the dropdown boxes.

Code: Select all

<option <?=$valueFromDatabase=='blah'?'selected':'';?> value="blah">Blah</option>
Mind you, I didn't read the code so maybe you've already done this.

Posted: Mon Mar 26, 2007 9:21 am
by GOkninski
Thanks for your replies.

I do apologise for pasting so much code in there, but to be truthful i dont know where the error/problem is and am getting desperate. You should see me, i have turned from a normal looking man into a trembling Gollum-like wreck in a matter of days.

I didnt expect anyone to read all the code, but included most of it to do with the function to let any potential rescuers test the code for themselves, as i have struggled with this issue for a couple of days now and its put the entire project at risk.

As for your suggestion, that is already how the drop downs are populated in the edit section. When the user trys to modify or edit a stock item, the values from the product table are still displayed, its when the user saves the modifications to the stock item that Zero values are written to the table against that particular stock item.

Again, any contributions to solving my issue would be very much appreciated.

Greg.