Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This still applies from my previous post:</p> <p>//====== Begin previous post</p> <p>Hopefully, your MYSQL database has a primary key? If it does, set the <code>value</code> of each <code>&lt;option&gt;</code> to the primary key of the item.</p> <p>For example:</p> <p>SQL</p> <pre><code>id desc 1 "dressmaker thing with mannequin" 2 "dressmaker thing no mannequin" </code></pre> <p>Form PHP</p> <pre><code>echo "&lt;option value='".$query['id']."'&gt;".$query['desc']."&lt;/option&gt;"; </code></pre> <p>When the form is submitted, re-query the database for the desired description. You'll be doing this re-query anyway to retrieve prices and such, yes?</p> <p>The reason this is happening is that spaces are discouraged in HTML attributes. You shouldn't have an attribute like <code>value='this attribute is spaced'</code>.</p> <p>//====== End previous post</p> <p>Basically, change this line:</p> <pre><code>while($row = mysql_fetch_array($result)) { echo "&lt;option value=$row[style]&gt;$row[style] $row[color]&lt;/option&gt;&lt;br /&gt;"; } </code></pre> <p>to</p> <pre><code>while($row = mysql_fetch_array($result)) { echo "&lt;option value='".$row['id']."'&gt;$row['style'] $row['color']&lt;/option&gt;&lt;br /&gt;"; } </code></pre> <p>and add this in <code>process_form.php</code> to get the description:</p> <pre><code>$desc = mysql_query("SELECT style FROM products WHERE id='".$_POST['item']."';"); </code></pre> <p>You can also use this to get all other related info from the DB right when you need it.</p> <p>// Another edit</p> <p>@Cambraca - right on - I forgot to sanitize the quote.</p> <p>@Ottoman - Your solution is a temporary fix. I strongly recommend applying an id/primary key system if it's not in place. An ounce of prevention is worth a pound of cure.</p>
 

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