Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unable to delete

    Hi all!

    I created a form where users are allowed to delete a specific row of data by clicking the "cancel" button from the drop down menu. However, I have a problem deleting my data using the javascript. Apparently, I only able to delete the first row of the data but not for the rest!

    The following is the code i have:


    PHP Code:
    <html>
    <body style="background-color:#E0FFFF;">


    <script language="javascript" >
    <!-- hide
    function submitRequest(val) {
    document.forms[0].submit();
    }

    // end hide -->
    </script>

    <?php

    $con 
    mysql_connect("localhost","root","");
    if (!
    $con)
      {
      die(
    'Could not connect: ' mysql_error());
      }

    mysql_select_db("my_course"$con);

    $result mysql_query("SELECT * FROM Courses ORDER BY Year, Sem, CourseCode");
    $result1 mysql_query("SELECT * FROM Courses ORDER BY Year, Sem, CourseCode");

    echo 
    "<table border='1' cellpadding='2' cellspacing='0'>
    <tr>
    <th>CourseCode</th>
    <th>CourseName</th>
    <th>Year</th>
    <th>Sem</th>
    <th>Grade</th>
    <th>Option</th>
    </tr>"
    ;

    ?>

    <?php

    while($row mysql_fetch_array($result))
    {
      echo 
    "<tr>";
      echo 
    "<td>" $row['CourseCode'] . "</td>";
      echo 
    "<td>" $row['CourseName'] . "</td>";
      echo 
    "<td>" $row['Year'] . "</td>";
      echo 
    "<td>" $row['Sem'] . "</td>";
      echo 
    "<td>" $row['Grade'] . "</td>";
      echo 
    "<td>";

    ?>
    <?php
    ?>

             <form name="form1" action="submitDelete.php" method="post">
           <select name="cancel" onchange="submitRequest(this.value);">
           <option value=> </option>
         <option value="<?php echo $row['CourseName'];?>">Cancel</option>
             </select>
             </form>

    <?php
      
    echo "</td>";
      echo 
    "</tr>";
      }

    echo 
    "</table>";

    mysql_close($con);
    ?>
        
    <br/>
    <br/>

    </body>
    </html>
    Thanks in advance!

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Apparently there is no javascript delete function within your code. It might be a php feature of this kind, but no javascript visible there, except a small code which simply submits the form's values to a php file.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •