Showing posts with label MySql. Show all posts
Showing posts with label MySql. Show all posts

Thursday, May 10, 2012

Populating a Drop-Down list using PHP and MySQL

In web based applications you may need to develop a drop-down list using elements taken from a database table. This code will help you to easily populate a drop-down list from a field of a database table.

 function get_dropdown($user){
         connect_to_db();
                if (!mysql_select_db('cars'))
                {
                    echo "could not select ('db')";
                }
                            $add_query = "SELECT names
                           FROM cars 
                             WHERE owner = '$user'
                            ";
                    $res = mysql_query($add_query);
               <select name="car" class="dropdownmenus" value="Select me">
     <option selected> Select Car </option>
     <?
           while ($row = mysql_fetch_array($res)) {
         extract($row);
           echo "<option value='$row'>$row[names]</option>";
           }
     ?>
     </select>
     }

Tuesday, May 1, 2012

Installing Horde in Fedora 10

As an open source project Horde will work better on Linux platform. This will guide you to install horde together will http server, MySql, PostFix SMTP server and Dovecot IMAP server.

Horde version - 3.3.8
PHP version - 5.2.9
Dovecot version - dovecot v1.1.20

1. Installing Apache  server
        $ yum install apache server

2. Installing MySql server
        $ yum install mysql-server

3. Install PostFix and Dovecot servers
        $ yum install postfix
        $ yum install dovecot

4. Configure PosFix SMTP server and Dovecot IMAP server
         http://workaround.org/ispmail/etch

5. Move /hordre folder to /var/www/html/ folder

6. Start servers.
        $ service httpd start
        $ service mysqld start
        $ service postfix start
        $ service dovecot start

6. Run the setup.php file
         $ php horde/scripts/setup.php

7. Check whether horde is working
         http://localhost/horde

8. Can use the users in the virtual_users table to login into horde. But have  to use the full domain names as,

    john---> john@example.com