Page 3 of 9 FirstFirst 12345 ... LastLast
Results 21 to 30 of 86

Thread: MySQL Database showing on a page.

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

    Default

    Code:
    <?php
    $conn = mysql_connect('localhost', '', '');
    mysql_select_db('smiletest');
    $tablename = 'request';
    $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.
    Cheap Webhosting At ONE TIME fees! Also offering Scripts, Software, Web Designs, and Graphic Designs. Outstanding Designs and Webhosting!

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

    Default

    No, not (ID), just 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!

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

    Default

    Gots an error...

    Code:
    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
    Cheap Webhosting At ONE TIME fees! Also offering Scripts, Software, Web Designs, and Graphic Designs. Outstanding Designs and Webhosting!

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

    Default

    Usually means there were no results. What's the layout of 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!

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

    Default

    Lol there are no results...
    Cheap Webhosting At ONE TIME fees! Also offering Scripts, Software, Web Designs, and Graphic Designs. Outstanding Designs and Webhosting!

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

    Default

    Not working:

    Code:
    <?php
    
    $conn = mysql_connect('localhost', '', '');
    mysql_select_db('');
    $tablename = 'request';
    $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>');
    ?>

    Gets error:
    Warning: Invalid argument supplied for foreach() in /fpgs/fpgshttpd/smileyoureahabbo/scripts/radiobox/requests.php on line 14
    del
    Cheap Webhosting At ONE TIME fees! Also offering Scripts, Software, Web Designs, and Graphic Designs. Outstanding Designs and Webhosting!

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

    Default

    Any one have any idea about the above??? ^^^^^^
    Cheap Webhosting At ONE TIME fees! Also offering Scripts, Software, Web Designs, and Graphic Designs. Outstanding Designs and Webhosting!

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

    Default

    You still haven't answered my question.
    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. #29
    Join Date
    Jun 2006
    Posts
    148
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

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

  10. #30
    Join Date
    Apr 2006
    Posts
    429
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Twey
    What's the layout of your table?
    this question

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
  •