SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    a fresh, new start... dujmovicv's Avatar
    Join Date
    Aug 2006
    Location
    Earth
    Posts
    559
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Select box from Database

    Hope I've placed this post at the right place (I think my problem can be solved with JavaScript).
    I have a mySql database with companies, their addresses, phone numbers, etc. Now there's a form with a select-->option drop down menu with company names. I have to solve that when a company name is chosen from the drop down menu, it's address, phone numbers, contact persons are all displayed simultaneously on the same page.
    Here's the code :
    PHP Code:
    <select name="company">

    <?

    $query = "SELECT id, firma, mesto, post_broj, adresa, PIB, kontakt1, kontakt2, kontakt3, kontakt4, kontakt5, pozicija1, pozicija2, pozicija3, pozicija4, pozicija5, telefon1, telefon2, telefon3, telefon4, telefon5, fax1, fax2, fax3, fax4, fax5, mobilni1, mobilni2, mobilni3, mobilni4, mobilni5, email1, email2, email3, email4, email5, web ".
             "FROM table_firme ".
             "ORDER BY firma ASC ";           // using ORDER BY to show the most current entry first
                 
             
     $result = mysql_query($query) or die('Error : ' . mysql_error());
     $row = mysql_fetch_array($result);

        while($row = mysql_fetch_array($result))
        {
            // list() is a convenient way of assign a list of variables
            // from an array values
            list($id, $firma, $mesto, $post_broj, $adresa, $PIB, $kontakt1, $kontakt2, $kontakt3, $kontakt4, $kontakt5, $pozicija1, $pozicija2, $pozicija3, $pozicija4, $pozicija5, $telefon1, $telefon2, $telefon3, $telefon4, $telefon5, $fax1, $fax2, $fax3, $fax4, $fax5, $mobilni1, $mobilni2, $mobilni3, $mobilni4, $mobilni5, $email1, $email2, $email3, $email4, $email5, $web, $date, $napomena, $uneo, $modifikovao) = $row;
     
    ?>

        <option value=""><? printf($row['firma']); ?></option>
    <?
    }
    ?>
    </select></td>
    </tr>
    <tr>
        <td><p class="fields">ADDRESS : </p></td>
        <td><p class="fields">I WANT HERE THE ADDRESS</p></td>
    </tr>
    <tr>
        <td><p class="fields">PHONE : </p></td>
        <td><p class="fields">I WANT HERE PHONE NR</p></td>
    </tr>
    Am I right that this can be done with JavaScript?

    Full time ADMIN - art community
    Part time coder - dsign

  2. #2
    SitePoint Member WeatherSquareCom's Avatar
    Join Date
    Sep 2008
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes it can but you need to store the data serverside...say in an array or something.


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
  •