Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Drop down truncating words when sending to table

Featured Replies

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>

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.