UltraFlux
asked on
SELECT help with PHP and DATA
What is the correct way to do this?
SELECT : I see this type of select everywhere.
<option value="1" <?php echo (($row['position']==1? ' selected ': '')) ?>>CEO</option>
<option value="2" <?php echo (($row['position']==1? ' selected ': '')) ?>>VP</option>
<option value="3" <?php echo (($row['position']==1? ' selected ': '')) ?>>HR</option>
SELECT : I use this at the moment
<option value="CEO" <?php echo (($row['position']==1? ' selected ': '')) ?>>CEO</option>
<option value="VP" <?php echo (($row['position']==1? ' selected ': '')) ?>>VP</option>
<option value="HR" <?php echo (($row['position']==1? ' selected ': '')) ?>>HR</option>
I do this so the data that is selected by the user is stored in the database, therefore when I retrieve the data it is correct. Otherwise I end up retrieving 0,1,2,3,4 which means nothing. How do I keep track that value = x means Marketing Manager?
SELECT : I see this type of select everywhere.
<option value="1" <?php echo (($row['position']==1? ' selected ': '')) ?>>CEO</option>
<option value="2" <?php echo (($row['position']==1? ' selected ': '')) ?>>VP</option>
<option value="3" <?php echo (($row['position']==1? ' selected ': '')) ?>>HR</option>
SELECT : I use this at the moment
<option value="CEO" <?php echo (($row['position']==1? ' selected ': '')) ?>>CEO</option>
<option value="VP" <?php echo (($row['position']==1? ' selected ': '')) ?>>VP</option>
<option value="HR" <?php echo (($row['position']==1? ' selected ': '')) ?>>HR</option>
I do this so the data that is selected by the user is stored in the database, therefore when I retrieve the data it is correct. Otherwise I end up retrieving 0,1,2,3,4 which means nothing. How do I keep track that value = x means Marketing Manager?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
So I should use your method in all of my code then.
Country ( yours )
<option value="1">Canada</option>
<option value="2">Mexico</option>
<option value="3">Japan</option>
Country ( mine )
<option value="Canada">Canada</opt ion>
<option value="Mexico">Mexico</opt ion>
<option value="Japan">Japan</optio n>
Then update User to reflect countryID
Modify my current mysql queries and selects
Country ( yours )
<option value="1">Canada</option>
<option value="2">Mexico</option>
<option value="3">Japan</option>
Country ( mine )
<option value="Canada">Canada</opt
<option value="Mexico">Mexico</opt
<option value="Japan">Japan</optio
Then update User to reflect countryID
Modify my current mysql queries and selects
ASKER
Is there somewhere on the internet I can get a list of countries and possibly even cities which I can use in my database? I know there are over 200+ countries and based on our talks I will have to rebuild my tables.
ASKER
:/
Hielo, thanks for the Wiki and Yahoo links, I'm far beyond finding the information on google. I'm sure I could manually enter the Countries if I had to however I don't think I have the time to manually enter the cities.
I will post this as another question
Hielo, thanks for the Wiki and Yahoo links, I'm far beyond finding the information on google. I'm sure I could manually enter the Countries if I had to however I don't think I have the time to manually enter the cities.
I will post this as another question
ASKER
Table Position ( I just used this to generate the drop down box )
+positionID
+position
Table User
+position ( I stored the actual value in the user table ) ex: Mechanic not positionID
I thought this was the best way when I started because it allows me to retrieve all of my data directly from my User table. SELECT * FROM User....
Is this considered wrong and should I change this?