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
    Regular Coder
    Join Date
    Jun 2008
    Posts
    680
    Thanks
    114
    Thanked 2 Times in 2 Posts

    Editing Information

    I don't know what I'm doing wrong. What I want to happen is when I want to edit the name of a division I click on edit next to the division name and it takes me to the editdivision function where it should go to the DB and grab the name but it isn't. I'm not sure what I'm doing wrong?

    PHP Code:
    function divisions() {
        print 
    '<h1 class="backstage">Division Management</h1><br />';
        print 
    "<h2 class=backstage>Divisions :: <a href=\"#\" onclick=\"ajaxpage('adddivision', 'content'); return false;\">Add New</a></h2><br />";
      
    $query "SELECT * FROM divisions ORDER BY `division`";
         
    $result mysql_query $query ); // Run The Query
         
    $rows mysql_num_rows($result);
         if (
    $rows 0)
         {
               print 
    '<table width="100%" class="table1">';
                print 
    '<tr class="rowheading">';
                print 
    '<td>&nbsp;</td>';
                print 
    '<td>Name</td>';
                print 
    '</tr>';
             
    // Fetch and print all records.
             
    $i 0;
             
    $current_row 0;
             while ( 
    $row mysql_fetch_array $resultMYSQL_ASSOC ) )
             { 
                
    $current_row++; 
                 
    $sClass 'row2';
                 if (
    $i ++ & 1)
                 {
                     
    $sClass 'row1';
                 }
                 
    printf "<tr class=\"%s\">"$sClass );
                 print 
    "<td valign=\"top\" align=\"center\" width=\"30\"><a href=\"#\" onclick=\"ajaxpage('editdivision', 'content', '".$row['division']."'); return false;\">Edit</a></td>";
                  
    printf "<td valign=\"top\">%s</td>"$row [division] );
                 print 
    '</tr>';
             }
             echo 
    '</table>';
         }
         else
         {
         print 
    '<span>There are no divisions.</span><br />';
         }
         print 
    '<br />';
    returnmain();

    PHP Code:
    function editdivision() 
    {
        
    $division $_GET['division']; 
        
    $query mysql_query("SELECT * FROM `divisions` WHERE `division` = '" $division "'");
          
    $row mysql_fetch_array($query); 
        print 
    '<h1 class="backstage">Division Management</h1><br />';
        print 
    '<h2 class="backstage">Edit Division</h2><br />';
        print 
    '<form name="editmatchtype" method="post" action="backstage.php" id="editmatchtype">';    
        print 
    '<table width="100%" class="table2">';
        print 
    '<tr>';
        print 
    "<td width=\"120\" class=\"rowheading\" valign=\"center\">Division:</td><td class=\"row3\"><input type=\"text\" name=\"division\" class=\"fieldtext490\" value=\"".$row['division']."\"></td>";
        print 
    '</tr>';
        print 
    '</table><br />';
        print 
    '<center>';
        print 
    '<input type="checkbox" name="deletedivision"><span class="table1heading">Delete Division?</span><br /><br />';
        print 
    '<input type="hidden" name="division" value="'.$division.'">'
        print 
    '<input type="hidden" name="olddivision" value="'.$row['division'].'">';
        print 
    '<input type="submit" value="Edit Division" class=button name="editdivision"><br /><br />';
        print 
    '<input type="button" value="Return to Divisions List" class="button200"><br /><br />';
        
    returnmain();


  • #2
    met
    met is offline
    Regular Coder
    Join Date
    Oct 2009
    Location
    United Kingdom
    Posts
    728
    Thanks
    4
    Thanked 119 Times in 119 Posts
    can't see what the onclick(ajaxpage) is doing, but the only thing I can see is that you aren't setting the <a> (so nothing is being entered in to the $_GET array)

    unless thats what the onclick is doing, can't really tell.

    my code below will make the link "page.php#?division=division"

    which should then work with your function.

    also check the source to see if the hidden field is being set.

    PHP Code:
         print "<td valign=\"top\" align=\"center\" width=\"30\"><a href=\"#?division=".$row['division']."\" onclick=\"ajaxpage('editdivision', 'content', '".$row['division']."'); return false;\">Edit</a></td>"


  •  

    Posting Permissions

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