June 9, 200818 yr Hope this is any easy one: When I select a 2 word value from the make_catagory_pulldown() it only sends the first word to the database table. Is there an easy fix for this? Ideally I'd like to pulldown to be made from a column in a database ... can anyone show me the script for this? Thanks very much for any help ... This is the script I am using: function make_catagory_pulldown() { $catagory = array (1 => '', 'Hairdressers', 'Media', 'Music Shops', 'Performance Artists', 'Promotions', 'Recording Studios', 'Rehersal Space'); echo '<select name="catagory">'; foreach ($catagory as $key => $value) { echo '<OPTION value='.$value.'> '.$value.''; // this causes the genera to be included rather than the key position } echo '</select>'; } // Check for catagory: if (empty($_POST['catagory'])) { $errors[] = 'You forgot to enter the catagory.'; } else { $ca = mysqli_real_escape_string($dbc, trim($_POST['catagory'])); } <p>Company Name: <input type="text" name="company" size="40" maxlength="100" value="<?php if (isset($_POST['company'])) echo $_POST['company']; ?>" /></p>
June 9, 200818 yr The problem is that you are not puting quotes around the value attribute when you are generating your options list. Here is an example of the HTML you are outputting: <option value=test thing>test thing</option> The browser will interpret this as an `option` element with attribute `value`='test' and an unset attribute `thing`. value = htmlentities($value); echo '<option value="'.$value.'"> '.$value.'</option>'; That oughta fix it.
Create an account or sign in to comment