Page 1 of 9 123 ... LastLast
Results 1 to 10 of 86

Thread: MySQL Database showing on a page.

  1. #1
    Join Date
    Jun 2006
    Posts
    148
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry MySQL Database showing on a page.

    Hello,
    Is their anyway to make MySQL Database results show up in a web browser? As in the MySQL database tabel results will be shown on any page I want it to? The only option I want is for each seperate result to be deleted with a simple delete button. Anyone know of a script that can do this?

    Thanks in advance,
    Joe
    Cheap Webhosting At ONE TIME fees! Also offering Scripts, Software, Web Designs, and Graphic Designs. Outstanding Designs and Webhosting!

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Clearly, you want this secure... so don't code it yourself.

    The point of mysql is to use php (and other languages) to get the data then display, yes, as html.


    however, in this case, you'd want to use a real manager for it, so it's secure, can do a bunch, etc.

    I'd recomment myphpadmin, if you don't already have that. If you do, get used to it... it's a good way to navigate, once you get used to the controls.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Jun 2006
    Posts
    148
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry

    Err... Dosen't need to be secure... I'm going to password protect it so its fine. And if its still not secure after the password than its not that big if a deal... Dosent matter to me if people can see it. I just want it to show on a page.
    Cheap Webhosting At ONE TIME fees! Also offering Scripts, Software, Web Designs, and Graphic Designs. Outstanding Designs and Webhosting!

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Code:
    <?php
    $conn = mysql_connect('dbserver', 'dbusername', 'dbpassword');
    mysql_select_db('databasename');
    $tablename = 'mytable';
    if(isset($_GET['delete']))
      if(!is_numeric($_GET['delete'])) die();
      else mysql_query('delete from `' . $tablename . '` where id=' . $_GET['delete'] . ';');
    
    $rs = mysql_query('select * from `' . $tablename . '`;');
    $row = mysql_fetch_array($rs);
    $cols = array();
    foreach($row as $k => $v)
      array_push($cols, $k);
    array_push($cols, 'del');
    echo('<table><tr>');
    for($i = 0; $i < count($cols); ++$i)
      echo('<th>' . $cols[$i] . '</th>');
    echo('</tr>');
    do {
      $row['del'] = '<form action="?delete=' . $row['id'] . '" method="get"><input type="submit" value="Delete"></form>';
      echo('<tr>');
      for($i = 0; $i < count($cols); ++$i) {
    ?>
    <td><?php echo($row[$i]); ?></td>
    <?php
      }
      echo('</tr>');
    } while($row = mysql_fetch_array($rs));
    echo('</table>');
    ?>
    Untested.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Jun 2006
    Posts
    148
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry

    Ok do I need to change anything accept for the db info????
    Cheap Webhosting At ONE TIME fees! Also offering Scripts, Software, Web Designs, and Graphic Designs. Outstanding Designs and Webhosting!

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    No, so long as you have a unique numerical column called "id".
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    Jun 2006
    Posts
    148
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    And how do you get that???
    Cheap Webhosting At ONE TIME fees! Also offering Scripts, Software, Web Designs, and Graphic Designs. Outstanding Designs and Webhosting!

  8. #8
    Join Date
    Jun 2006
    Posts
    148
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    ?___?
    Cheap Webhosting At ONE TIME fees! Also offering Scripts, Software, Web Designs, and Graphic Designs. Outstanding Designs and Webhosting!

  9. #9
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Uh... you... add it to your table.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  10. #10
    Join Date
    Jun 2006
    Posts
    148
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Huhhh? Can you tell me how?
    Cheap Webhosting At ONE TIME fees! Also offering Scripts, Software, Web Designs, and Graphic Designs. Outstanding Designs and Webhosting!

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
  •