SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Feb 2012
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Getting started : designing a web front end for mysql?

    I have never programmed in the Linux environment before, and need a few pointers really.

    I have a mySQL database on CENTOS and need to produce a simple web page able to query and SQL table, and update one field, thats all!

    Where do I start?
    * is ECLIPSE the best IDE to use?
    * are there any demo PHP projects that I can start from, and hack?

    Thanks, Peter

  2. #2
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    73 Post(s)
    Tagged
    0 Thread(s)
    Personally, I use Notepad++. Not really an IDE, but for what PHP is, it works.

    Where do you start.
    Step 1: Design the HTML. (Take your pick on HTML editors)
    Step 2: Add the PHP to make it work.

    Consider that unless you're modifying only 1 record in 1 row of 1 table, you're going to need something a -wee- bit more complex than what you described.
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  3. #3
    Foozle Reducer ServerStorm's Avatar
    Join Date
    Feb 2005
    Location
    Burlington, Canada
    Posts
    2,699
    Mentioned
    89 Post(s)
    Tagged
    6 Thread(s)
    @theasarius

    I have development machines in Debian and in OpenSuse - (the tumbleweed versions) and I love using Eclipse with the rse target management http://jpablobr.com/past/install-ecl...roject-plug-in to connect to various remote servers.

    You should learn about the different methods to connecting to your database from PHP. I like using the PDO (PHP Data Objects
    http://www.php.net/manual/en/book.pdo.php) for connections it is also helpful for using prepared statements and if you are not using INNODB tables in MySQL (that have their own transactions) you can use PDO's transactions.

    So if you where using PDO you would connect to it like:

    PHP Code:
    $db = new PDO("mysql:host=localhost;dbname=myDb""user""secretPassword"); 
    You would then query the database like:
    PHP Code:
    <?php
     $sql 
    null;
     
    $sql "SELECT communication_type, communication_category_id FROM `communication_types`;";  
     
    $stmt null;
      
    $stmt $db->prepare($sql);
      
    $stmt->execute();
      
    $result null;
    // Fetch as an Associative Array// then loop through the results and display in a page
      
    $result $stmt->fetch(PDO::FETCH_ASSOC); 
    ?>
    <html>
    <body>
        <ul>
        <?php
            
    foreach($result as $key => $value){
               echo 
    "<li>$key$value</li>
            }
         ?>
         </ul>
    </body>
    </html>
    This will output the mysql stored values in a list

    I hope this helps.
    Steve
    ictus==""

  4. #4
    SitePoint Member
    Join Date
    Feb 2012
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Steve, thats *exactly* the pointers I needed. I'll download and start building code
    Thanks again!

    Peter


    Quote Originally Posted by ServerStorm View Post
    @theasarius

    I have development machines in Debian and in OpenSuse - (the tumbleweed versions) and I love using Eclipse with the rse target management http://jpablobr.com/past/install-ecl...roject-plug-in to connect to various remote servers.

    You should learn about the different methods to connecting to your database from PHP. I like using the PDO (PHP Data Objects
    http://www.php.net/manual/en/book.pdo.php) for connections it is also helpful for using prepared statements and if you are not using INNODB tables in MySQL (that have their own transactions) you can use PDO's transactions.

    So if you where using PDO you would connect to it like:

    PHP Code:
    $db = new PDO("mysql:host=localhost;dbname=myDb""user""secretPassword"); 
    You would then query the database like:
    PHP Code:
    <?php
     $sql 
    null;
     
    $sql "SELECT communication_type, communication_category_id FROM `communication_types`;";  
     
    $stmt null;
      
    $stmt $db->prepare($sql);
      
    $stmt->execute();
      
    $result null;
    // Fetch as an Associative Array// then loop through the results and display in a page
      
    $result $stmt->fetch(PDO::FETCH_ASSOC); 
    ?>
    <html>
    <body>
        <ul>
        <?php
            
    foreach($result as $key => $value){
               echo 
    "<li>$key$value</li>
            }
         ?>
         </ul>
    </body>
    </html>
    This will output the mysql stored values in a list

    I hope this helps.
    Steve


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
  •