Note that there are some explanatory texts on larger screens.

plurals
  1. PORunning a MySQL query, storing a temp value, then running another query
    primarykey
    data
    text
    <p>To give some context, the following dropdown is within a form that gives the current profile description of an animal stored in the database: i.e, this pony is yea high, of this gender, owned by somesuch, etc. The purpose of the form is to edit these current values. There are various options that can be overwitten freely, others where I want the choice limited to options from a dropdown menu. </p> <p>The following is the current code I am using for the Gender field, which - although it does work - cannot be the proper way of doing things. I would be more interested in a method that queried the current state, gave the current state as the default option, stored the current state, queried other available states not equal to the stored current state, then gave the remaining states as options. It is that method that I could best adapt to all the other dropdowns on the form.</p> <p>There are two tables referenced - the profile tbl and the prm_breedgender tbl. Each gender is given an ID, each profile is then given a corresponding ID to signify their gender (male=1, female=2, etc.). The $profile variable is that which signifies the current profile being looked at.</p> <pre><code>&lt;label for="profile-gender"&gt;Gender / Type:&lt;/label&gt; &lt;select name="profile-gender"&gt; &lt;?php $genderresult = mysql_query("SELECT prm_breedgender.BreedGender FROM profiles, prm_breedgender WHERE ProfileID = $profile AND prm_breedgender.BreedGenderID = profiles.ProfileGenderID"); $row = mysql_fetch_array($genderresult); echo '&lt;option value="' . $row['BreedGenderID'] . '"&gt;' . $row[BreedGender] . '&lt;/option&gt;'; $exgenderresult = mysql_query("SELECT prm_breedgender.BreedGender FROM profiles, prm_breedgender WHERE ProfileID = $profile AND prm_breedgender.BreedGenderID != profiles.ProfileGenderID"); while ($row = mysql_fetch_array($exgenderresult)) { echo '&lt;option value="' . $row['BreedGenderID'] . '"&gt;' . $row[BreedGender] . '&lt;/option&gt;'; } ?&gt; &lt;/select&gt; </code></pre> <p>Any help would be greatly appreciated. I'm not all that experience (obviously!) so accompanying explainations would be fantastic.</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.
    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