Results 1 to 5 of 5

Thread: data from one combo to another

  1. #1
    Join Date
    Feb 2013
    Posts
    49
    Thanks
    25
    Thanked 1 Time in 1 Post

    Default data from one combo to another

    Hi,
    I have created few tables and combo boxes in my site. Please have a check on raihans.co.uk, log in with userdb, pwd: open. then hover on User Log In/Out and click on DB Test.

    The Country, State or Province names are entered manually through codes.
    I wishes to get the country entries in 1st Combo from my table (named, 'Test_Country') in mysql. Then as I click on any country, on the 2nd combo it will show the State from another table (named, 'Test_State'). Just as it is now, but from the database tables.

    My table entries are like:
    Table Fields
    ------ ----------
    Test_Country - Country_Name, CountryID
    Test_State - State_Name, StateID
    Test_CountryState - CountryID, StateID

    How I may do that, pls help me.

    Thanking you in advance.


    Raihan
    Last edited by raihan; 04-03-2013 at 05:41 PM.

  2. #2
    Join Date
    Feb 2013
    Posts
    49
    Thanks
    25
    Thanked 1 Time in 1 Post

    Default

    Hi,

    No one replied anything yet to me.

    Anyway, I have tried a bit with myself. I am using Joomla 3.0 and for using my code in the Article I have used 'Sourcerer' extension. As mentioned before, please have a look on my site raihans.co.uk, then login as 'dbuser', password is 'passwd'. Hover on User Log In/Out, then click on DB Test.

    I have use the code as below in my Article:


    Code:
    <?php** $link = mysql_connect("localhost", "DB_User", "DB_Pwd");
    ** mysql_select_db("DB_Name");
    ** $query = "SELECT Column_Name FROM DB_Table";
    ** $result = mysql_query($query);
    ** while ($line = mysql_fetch_array($result))** {
    ** foreach ($line as $value) {
        **** echo*"This*is*<font*color=\"blue\">$value </font>! <br />";
    ** }* }
    ** mysql_close($link);
    ?>

    Note: Don't know why showing '*', instead of 'space' in the code, when submitted this reply.
    At the moment it showing the data from a column in a table, but showing twice. Can't figure-out, why? Can anyone please help me.

    Thanks in advance.

    Raihan
    Last edited by james438; 05-18-2013 at 09:42 PM. Reason: format

  3. #3
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    1,734
    Thanks
    82
    Thanked 90 Times in 88 Posts

    Default

    Sorry, but some questions get neglected sometimes. If you put the code in code tags you probably won't have that problem. It also makes code easier to read. As to your original question. I did look at your site a while back. Why not use javascript like you have been? It would be better than using php/mysql in this case. Why do you want to use php/mysql instead? I guess I am not quite sure what you are trying to accomplish.
    To choose the lesser of two evils is still to choose evil. My personal site

  4. #4
    Join Date
    Feb 2013
    Posts
    49
    Thanks
    25
    Thanked 1 Time in 1 Post

    Default Thanx to James

    Thanx a lot for ur reply. I will try as u suggest me. If I do with Javascript, then pls get back to me sometime.

    Raihan

  5. #5
    Join Date
    Feb 2013
    Posts
    49
    Thanks
    25
    Thanked 1 Time in 1 Post

    Default

    Hi, I have made a bit progress. I have the list of data from a column in the Table, to Combo Box. I have used the following code in my Joomla article:
    Code:
    {source}
    <select>
        <option value="" selected>Select a country</option>
        <?php
            $link = mysql_connect("Domain_Name","DB_User","DB_User_Passwd");
            if (!$link)
              {  die('Could not connect to Database: ' . mysql_error());
              }
            mysql_select_db("conct",$link);
            $category = "SELECT Country_Name FROM Test_Country";
            $query_result = mysql_query($category);
            while($result = mysql_fetch_assoc($query_result))
            {
        ?>
        <option value = "<?php echo $result['Country_Name']?>"><?php echo $result['Country_Name']?></option>
        <?php
            } ?>
    </select>
    {/source}
    But, I want as soon as I click on any item on the list, another list of data will retrieve from corresponding table. Just as example on the top, in my site. Is there anyone may help me, please.

    Thanking you in advance.

    Raihan
    UK
    Last edited by james438; 04-15-2013 at 04:16 PM. Reason: format

Similar Threads

  1. How click on combo data to show into another
    By raihan in forum JavaScript
    Replies: 3
    Last Post: 04-03-2013, 02:41 PM
  2. Combo Box
    By saloio in forum JavaScript
    Replies: 0
    Last Post: 01-21-2011, 09:04 PM
  3. Sending Combo Boxes data to PHP
    By busi6292 in forum Flash
    Replies: 0
    Last Post: 01-12-2009, 08:46 PM
  4. combo box
    By janakrai in forum HTML
    Replies: 3
    Last Post: 01-08-2009, 02:27 PM
  5. Replies: 2
    Last Post: 07-06-2006, 07:11 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •