Advanced Search

Page 2 of 9 FirstFirst 1234 ... LastLast
Results 11 to 20 of 86

Thread: MySQL Database showing on a page.

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

    Default

    Well someone gave me this script...

    Code:
    <html>
    <title>Request Line</title>
    
    <?php
    $username = DBUSERNAME;
    $password = DBPASSWORD;
    $database = "DBNAME";
    $db = mysql_connect(localhost, $username, $password) or die(mysql_error());
    mysql_select_db($database, $db) or die("Unable to select database");
    $query = "SELECT Habbo Name, Song Request, Shoutout/Joke";
    $result = mysql_query($query, $db);
    
    echo '<h1 style="text-align: center; font-weight: bold;">Season 2006/07 Squad</h1><br/><br/>';
    
    while ($row = mysql_fetch_assoc($result)) {
      foreach ($row as $key => $value) {
        $$key = htmlspecialchars($value);
      }
    
      echo '<table cellspacing="3" cellpadding="5" align="center" style="border:1px solid #999999; width: 70%;">';
      echo "<tr><td><b>Habbo Name</b></td><td>$Habbo Name</td></tr>";
      echo "<tr><td><b>Song Request</b></td><td>$Song Request</td></tr>";
      echo "<tr><td><b>Shoutout/Joke</b></td><td>$Shoutout/Joke</td></tr>";
      echo "</table><br/><br/>";
    }
    mysql_close($db);
    ?>
    </html>
    It just needs the delete function.
    Cheap Webhosting At ONE TIME fees! Also offering Scripts, Software, Web Designs, and Graphic Designs. Outstanding Designs and Webhosting!

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

    Default

    However you created the table in the first place.

    Errrr... I'm pretty sure that won't work.
    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!

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

    Default

    Idk I really want a simple code to have it show up in a table with a delete button. can you do that like without all the ID crap... Or teach me the ID CRAP?
    Cheap Webhosting At ONE TIME fees! Also offering Scripts, Software, Web Designs, and Graphic Designs. Outstanding Designs and Webhosting!

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

    Default

    All you need is a unique column, which your table must already have. Just change the 'id' to the name of your unique column, and surround the value with quotes where it's used in to delete a row if the value isn't numerical.
    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. #15
    Join Date
    Jun 2006
    Posts
    148
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ok I Get This error.

    Warning: Invalid argument supplied for foreach() in /fpgs/fpgshttpd/smileyoureahabbo/scripts/radiobox/requests.php on line 14
    del



    :/ what should i do?
    Cheap Webhosting At ONE TIME fees! Also offering Scripts, Software, Web Designs, and Graphic Designs. Outstanding Designs and Webhosting!

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

    Default

    Is that with my script, or the other?
    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. #17
    Join Date
    Jun 2006
    Posts
    148
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

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

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

    Default

    I'm guessing you missed a quote somewhere.
    Code:
    <?php
    $conn = mysql_connect('dbserver', 'dbusername', 'dbpassword');
    mysql_select_db('databasename');
    $tablename = 'mytable';
    $uniquerow = 'id';
    if(isset($_GET['delete']))
      if(!is_numeric($_GET['delete'])) die();
      else mysql_query('delete from `' . $tablename . '` where ' . $uniquerow . '=\'' . $_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[$uniquerow] . '" 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>');
    ?>
    Should work if you just change the details.
    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!

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

    Default

    Now i got this error.

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /fpgs/fpgshttpd/smileyoureahabbo/scripts/radiobox/requests.php on line 12

    Warning: Invalid argument supplied for foreach() in /fpgs/fpgshttpd/smileyoureahabbo/scripts/radiobox/requests.php on line 14
    del


    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /fpgs/fpgshttpd/smileyoureahabbo/scripts/radiobox/requests.php on line 30


    and lets say the Uneque colom is named ID would it be (ID)

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

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

    Default

    and lets say the Uneque colom is named ID would it be (ID)
    Eh?

    Paste the top bit of the script after you've configured it (without username and password, obviously).
    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!

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
  •