Note that there are some explanatory texts on larger screens.

plurals
  1. PODisplaying Option Values From Concantenation In PHP Echo
    primarykey
    data
    text
    <p>hit a wall on what should be a non-issue. Have a PHP echo with two concantenations in them to populate option values for a pull-down menu in a form, with the data for the option values being pulled from a MySQL database query. Works great, except that for some reason the option value will ONLY display the first word, and when it encounters a space in the value it drops it out of the option value field and populates the second, third words prior to the option value. </p> <p>Here's the code: </p> <pre><code> &lt;td width="160"&gt;&lt;p&gt; Job Location:&lt;/p&gt;&lt;select class="listmedium" id="JobLocation" name="JobLocation"&gt;&lt;option value='' selected="selected"&gt;&lt;/option&gt; &lt;?php $con = mysql_connect("Values Deleted"); if (!$con) {die('Could not connect: ' . mysql_error());} mysql_select_db ("database1", $con); $result = mysql_query("SELECT CustomerLoc FROM customerloc ORDER BY CustomerLoc ASC"); while($row = mysql_fetch_array($result)) {echo "&lt;option value=" . $row['CustomerLoc'] . "&gt;" . $row['CustomerLoc'] ."&lt;/option&gt;";} mysql_close($con); ?&gt; &lt;/select&gt; </code></pre> <p>Which outputs as: </p> <pre><code> &lt;td width="160"&gt; &lt;p&gt; Job Location:&lt;/p&gt; &lt;select id="JobLocation" class="listmedium" name="JobLocation"&gt; &lt;option selected="selected" value=""&gt;&lt;/option&gt; &lt;option springs="" value="Carrizo"&gt;Carrizo Springs&lt;/option&gt; &lt;option wells="" value="Artesia"&gt;Artesia Wells&lt;/option&gt; &lt;/select&gt; </code></pre> <p>Notice the "springs" and "wells" place themselves BEFORE the option value quotes where the concantenation is intended to place the entire value, which should read "Carrizo Springs" and "Artesia Wells" for the option values. </p> <p>Now, if I insert a &amp;nbsp manually between the values, the entire value shows up as "Carrizo&amp;nbspSprings" and works (but I don't want to insert &amp;nbsp in each if I don't have to) and also if I manually code the HTML values to read "Carrizo Springs" it then works fine as an option value, thus it seems to be something happening with the PHP data call. </p> <p>I know it is not ideal to use text in place of integers in option values, but there is a reason behind it, and I would appreciate any help from ya'll if someone knows why the PHP would display the output in that manner. Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload