473,395 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

MSSQL populated dropbox option value truncated

Hi all, I am currently trying to populate a dropbox with values from a MSSQL DB. The values that are being brought back from the table are two words - peoples full names, eg 'John Smith' (in the one field). My problem is that using the code below, only the person's first name is being posted to the subsequent page and the surname is lost. Does anyone know what is wrong with this code? I'm pretty sure it has somethin to do with the fact there is a space in the field value...
[php]
<?php
$myServer = "...";
$myUser = "...";
$myPass = "...";
$myDB = "...";

$link = mssql_connect( $myServer, $myUser, $myPass );
mssql_select_db( $myDB, $link );
$output = mssql_query("SELECT name FROM staff");
?>
<select name="requestedby" id="requestedby">
<?php while ($row = mssql_fetch_object($output)) { echo "<option value=" . $row->name . ">" . $row->name . "</option>"; } ?>
</select>[/php]

Please enclose any code within the proper code tags. See the Posting Guidelines on how to do that.

moderator
Mar 2 '08 #1
3 1904
ronverdonk
4,258 Expert 4TB
Welcome to The Scripts!

Since the value contains blanks, these will be stripped. Always enclose a value field within quotation marks. For you this means:[php]while ($row = mssql_fetch_object($output)) {
echo "<option value='" . $row->name . "'>" . $row->name . "</option>"; [/php]Ronald
Mar 2 '08 #2
Thankyou very much.. works as intended!
Mar 2 '08 #3
ronverdonk
4,258 Expert 4TB
You are welcome. See you again next time.

Ronald
Mar 2 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: | last post by:
I am hoping a mixed ASP- Javascript programmer could help me with this scenario: I have a list box populated with randomized records (NewID()) from a Broker (Salesperson) sql server table. ...
2
by: Pablo | last post by:
C:\Program Files\Microsoft SQL Server\MSSQL\Data\" contains .mdb and ..ldb files that are huge, some reach 21GB! while backup files don't exceed 8MB. I guess it's a kind of transaction log, but...
0
by: Jamin Guy | last post by:
We are excited to announce the release of Tango DropBox 3.0 with PRO upgrade! Tango DropBox PRO includes secure file transfers using SSL and TLS, and the ability to export pre-configured,...
0
by: hassanali20 | last post by:
I've surfed this forum and found one thread which was talking about the same problem i've, but it didn't help in my situation. http://www.thescripts.com/forum/thread510563.html I could connect to...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.