How to dynamically delete rows from database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lisles
    New Member
    • Jan 2010
    • 40

    How to dynamically delete rows from database

    hey,i've got a page that displays rows from a db.im want a function to dynamically delete rows.i've put it 1,bt i get an error as follows:
    Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\xampp\htdocs \panchayats\adm in\login_attemp t.php on line 36


    my code is given below:
    [code=php]
    <?php
    require_once "../inc/functions.php";
    sessionCheck();
    ?>
    <?php include_once "admin_template s/case_header.php "; ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Contro l Panel</title>
    <link rel="stylesheet " type="text/css" href="admin.css " />
    <script language="javas cript" type="text/javascript" src="menu.js"></script>
    <script language="javas cript">
    function delRow()
    {
    function deleteRow(i){
    document.getEle mentById('myTab le').deleteRow( i)
    }
    }
    </script>
    </head>

    <body>

    <h3> Login Attempts</h3>
    <?php
    $page = $_GET['page'];
    $records_per_pa ge = 10;
    if (!ctype_digit($ page)) $page=1;
    $offset = ($page-1) * $records_per_pa ge;

    $getlogs = "SELECT * FROM login_attempts ORDER BY id desc LIMIT $offset, $records_per_pa ge";
    $result = caseQuery($getl ogs) or die ("<div style='padding: 20px; font-weight:bold; color:#FF0000;' >There was an error in selecting login logs</div>");
    $rows = mysql_num_rows( $result);
    if ($rows) {
    echo "<div style='padding-left:20px;'><ta ble id="myTable" style='border-collapse:collap se; border-color:#000' border='1' cellspacing='0' cellpadding='5' width='400'>";
    echo "<tr><td width='100'>IP Address</td><td width='60'>Atte mpts</td><td width='150'>Tim e Stamp</td><td>reset</td></tr>";
    for($i=1;$i<=$r ows;$i++) {
    $res=mysql_fetc h_array($result ); // i've changed $result to $rows
    echo "<tr><td>{$ res['ipaddress']}</td><td>{$res['attempts']}</td><td>{$res['timestamp']}</td><td><input type="button" value="Delete" onclick="delete Row(this.parent Node.parentNode .rowIndex)"></td></tr>";
    }
    echo "</table></div>";
    //paging toolbar
    $count_result = caseQuery("SELE CT COUNT(*) FROM login_attempts" );
    $count_row = mysql_fetch_arr ay($count_resul t);
    $count = $count_row["COUNT(*)"]; //fetch the total number of rows in the table
    $numofpages = ceil($count/$records_per_pa ge); // how many pages we have when using paging?
    echo "<div style='margin-left:20px;width :400px;'>";
    if ($numofpages > '1' ) { pagingScript("l ogin_attempt.ph p", $page, $numofpages); }
    echo "</div>";
    } else {
    echo "<div style='margin-left:20px;'>No Login Attempts</div>";
    }
    ?>
    </body>
    </html>
    [/code]


    i dont kno y im getting the error.please help me
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    yupp, the quotes of the table id terminate the string. you either escape them or use single quotes.

    Comment

    • kovik
      Recognized Expert Top Contributor
      • Jun 2007
      • 1044

      #3
      This same problem is also on line 40. I'd suggest getting a program such as Notepad++ that highlights syntax. It would show you that your strings are being terminated. If the whole string isn't the same color, there's a problem.

      Comment

      • lisles
        New Member
        • Jan 2010
        • 40

        #4
        thanx alot:)...apprec iate the help

        Comment

        Working...