hargz09 Posted August 25, 2009 Share Posted August 25, 2009 Hi, I need to create a form but I'm unsure what to create it with. It needs to firstly display values for each item: For example Red + £3, Blue -£2 It will then need to show a total at the bottom. It then also needs to only show only items that value to the Model Chosen. For Example if Model A is selected: Blue Green and Red display If Model B is selected Blue, Yellow and purple display in the colour choice. It then needs to be saved into a database and the values need to be easily changed. Any suggestions? Link to comment https://forums.phpfreaks.com/topic/171829-calculating-form/ Share on other sites More sharing options...
Goldeneye Posted August 25, 2009 Share Posted August 25, 2009 It sounds like you should use PHP to create this 'form' if there's a Database involved. Otherwise, what are you going to do if the user has Javascript disabled? Link to comment https://forums.phpfreaks.com/topic/171829-calculating-form/#findComment-906159 Share on other sites More sharing options...
hargz09 Posted August 25, 2009 Author Share Posted August 25, 2009 I know how to create a normal php form but how would i go about adding values? Link to comment https://forums.phpfreaks.com/topic/171829-calculating-form/#findComment-906211 Share on other sites More sharing options...
Goldeneye Posted August 26, 2009 Share Posted August 26, 2009 Well, got Text-Fields and Text-Areas, you do this: <?php /* * * THIS IS A VERY BASIC EXAMPLE * */ $query = mysql_query("SELECT `field` FROM `table` WHERE `fieldid`=1"); $row = mysql_fetch_assoc($query); if(isset($_POST['submitform'])) $value = $_POST['field'] else $value = $row['field']; //Start the HTML Form echo '<form action="foobar.php" method="post">'; echo '<input type="text" name="field" value="" />'; echo '<input type="submit" name="submitform" value="Submit Form" />'; echo '</form>'; ?> Of course, that's just for Text-based input. This isn't the way you'd do it for Checkboxes, Radio-Buttons, and Select-Menus. (I hope this is what you were looking for) Link to comment https://forums.phpfreaks.com/topic/171829-calculating-form/#findComment-906349 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.