Results 1 to 4 of 4

Thread: Php MySql and Tables

  1. #1
    Mentor coltrane's Avatar
    Join Date
    May 2001
    Location
    North Carolina
    Posts
    1,390

    Php MySql and Tables

    I have written a script that accesses my MySql dB and outputs the data into html tables...what I want to do now is add the ability to edit and delete data in MySql tables INSIDE the html tables.......for some reason my logic is off and its not working

    Can someone put me in the right path?

  2. #2
    Moderator
    Advisor
    redhead's Avatar
    Join Date
    Jun 2001
    Location
    Copenhagen, Denmark
    Posts
    811

    Re: Php MySql and Tables

    What are you looking for?? something like:
    Code:
     DELETE FROM table WHERE somthing = selected;
    
    or
    
    UPDATE table SET item = change_item WHERE something = selected;
    ::edit::
    Or is it the ALTER trigger you're looking for ?? if you want to change the table structure it self.

  3. #3
    Mentor coltrane's Avatar
    Join Date
    May 2001
    Location
    North Carolina
    Posts
    1,390

    Re: Php MySql and Tables

    Code:
    <?php
    
    if (!isset($query) || empty($query))
        {$query = "select * from sccp";}
    //stripslashes are needed because the select statement is
    //coming from a form.
    $query=stripslashes($query);
    
    mysql_connect("localhost", "dba", "purge26")
        or die("Could not connect to MySql Server");
    mysql_select_db("shift")
        or die("Could not open the Shift Database");
    $result = mysql_query($query) or
        die( mysql_error() );
    
    $number_cols = mysql_num_fields ($result);
    
    echo "<b>query: $query</b>";
    //layout table header
    echo "<table border = 1>\n";
    echo "<tr align=center>\n";
    
    for ($i=0; $i<$number_cols; $i++)
    {
        echo "<th>" . mysql_field_name($result, $i). "</th>\n";
    }
    echo "</tr>\n"; //end table header
    
    
    //layout table body
    while ($row = mysql_fetch_row($result))
    {
        echo "<tr align=left>\n";
        for ($i=0; $i<$number_cols; $i++)
        {
            echo "<td>";
            if (!isset($row[$i])) //test for null value
                {echo "NULL";}
            else
                {echo $row[$i];}
            echo "</td>\n";
        }
        echo "</tr>\n";
    }    
    
    echo "</table>";
    ?>
    And I want to able to perform INSERTS and UPDATES from within the html tables, but I cant figure it out the best way to do it....I need more caffeine, but until then, I need assistance/opinions.

  4. #4
    Mentor coltrane's Avatar
    Join Date
    May 2001
    Location
    North Carolina
    Posts
    1,390

    Re: Php MySql and Tables

    nevermind, i got it
    will post the code later

Similar Threads

  1. IP tables
    By saswata in forum Linux - Hardware, Networking & Security
    Replies: 2
    Last Post: 11-11-2007, 11:48 AM
  2. Tutorial on IP tables
    By saswata in forum Linux - Hardware, Networking & Security
    Replies: 1
    Last Post: 10-11-2007, 12:20 AM
  3. IP Tables
    By explorer in forum BSD
    Replies: 2
    Last Post: 08-02-2007, 03:57 PM
  4. IP Tables Sanity Check
    By Gahwani in forum Linux - General Topics
    Replies: 5
    Last Post: 09-23-2002, 05:37 PM
  5. ip tables question
    By amberhalo in forum Linux - Hardware, Networking & Security
    Replies: 2
    Last Post: 11-27-2001, 03:55 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
  •