Jump to content


Photo

Chaning a Database Default Answer


  • Please log in to reply
2 replies to this topic

#1 kenwvs

kenwvs
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts

Posted 22 July 2006 - 11:23 PM

I know absolutely nothing about this, but am hoping to make a minor change in a program.  I have an online auction site and when a member registers, or lists an item for the auction, one of the fields is Country.  In that spot, it says "Please Select Country".  You then choose from a list of countries, which has pretty much all the countries I could think of, plus some.  I would like to change it so that the default country is Canada.  I know the code for Canada is "32", just like the code for the USA is "210".  In the database, there is a table called "Countries" which has all the countries listed, along with their country code.  I have tried setting this to "32" for a default, but it made no difference.  I don't know if there would be another setting in there that I need to change.  In the code itself, there is some various spots, where they have put a "0" which refers to the "Please Select Category" or invalid entry.  I have tried changing the numbers in this general area around, and again it makes no difference.

I am not sure if I need to change it in the DB or if it would be in the script that I need to change it.

Here is an example of the membership form that they complete (the portion relating to country).  Not sure if that tells you anything as to where I should be looking to set the default.

 <TR>
              <TD width="44%" height="25" align=left valign="top" class="innertablestyle"><font  class="normal"><B>Country<br>
                </B></font></TD>
              <TD width="6" align=left valign="top"><font class="normal"><FONT class=red>*</font></FONT></TD>
              <TD> <SELECT name="sb_country">
                  <OPTION value=0
                          <? if($sb_country==0) {echo " selected ";}?>>Select
                  a country
                  <?
                                                  $country1=mysql_query("select * from sbauctions_country order by country");
                                                  while($rst= mysql_fetch_array($country1))
                                                  {
                                                  ?>
                  <OPTION value=<? echo $rst["id"];?> <? if($rst["id"]==$sb_country) {echo " selected ";}?>><? echo $rst["country"];?></OPTION>
                  <?
                                                           } // wend
                                                           ?>
                </SELECT> </TD>
            </TR>


thanks in advance,

Ken

#2 king arthur

king arthur
  • Members
  • PipPipPip
  • Advanced Member
  • 335 posts
  • LocationUK HQ

Posted 23 July 2006 - 12:34 AM

This is not a MySQL question.

Somewhere in your script you need to set the variable $sb_country to the value you want, then the country corresponding to that value will be selected by default in the menu.
Sir Isaac Newton said "If I have seen farther, it is by standing on the shoulders of giants". But it is not recorded as to whether he said it before or after he was hit on the head by a falling apple.

#3 kenwvs

kenwvs
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts

Posted 23 July 2006 - 01:07 AM

Thanks for sending me in the right direction.

Ken




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users