Results 1 to 2 of 2
  1. #1
    Join Date
    May 2004
    Posts
    1

    Arrow Unanswered: Multiple Form Editing not working HELP!!

    PHP Code:
        global $conn;
        
        if($_POST['submitall']){
            
            $l_id    = $_POST['l_id'];
            $l_name  = $_POST['l_name'];
            $l_url   = $_POST['l_url'];
            $l_level = $_POST['l_level'];
            
            $sql = "SELECT * FROM $linkprefix";
            $result = mysql_query($sql);
            $linkcount = mysql_numrows($result);
            
        for ($i = 0; $i < $linkcount; ++$i){
            
        if (empty($l_name[$i])){
            $redirectmessage = "You must enter a link name.";
            $DIRECTURL = "Copy of editlinks.php";
        include("../direct.php");
        exit();
        }
        
        if (empty($l_level[$i]) || (preg_match('/[^0-9]/', $l_level[$i]))){
            $redirectmessage = "Position must be an integer value.";
            $DIRECTURL = "Copy of editlinks.php";
        include("../direct.php");
        exit();
        }
        
        list($l_id, $l_level) = mysql_fetch_row($result);
        $allsql = mysql_query("UPDATE $linkprefix SET l_name='$l_name[$i]', l_url='$l_url[$i]', l_level='$l_level[$i]' WHERE l_id='$l_id'");
        }
        }
        
        if (!$_POST['submit'] || !$_POST['submitall']){
            $sql = "SELECT * FROM $linkprefix";
            $result = mysql_query($sql);
            $linkcount = mysql_numrows($result);
            
        for ($i = 0; $i < $linkcount; ++$i)
            $linklist[] = mysql_fetch_row($result);

        for ($i = 0; $i < $linkcount; ++$i){
        list(, list($l_id, $l_name, $l_url, $l_description, $l_category, $l_level)) = @each($linklist);
    ?>
        <table class="main" cellpadding="4" cellspacing="1" width="100%">
            <tr class="head">
                <td class="head" valign="top"><b>Edit An Entry</b></td>
                <td class="headcent" valign="top"></td>
            </tr>
            <tr>
        <form action="<? echo $PHP_SELF ?>" method="post" name="message">
                <td class="con1" valign="top">Link Name</td>
                <td class="con2" valign="top"><input type="hidden" name="l_id[<?php echo $i ?>]" value="<? echo $l_id ?>" /><input type="text" name="l_name[<?php echo $i ?>]" size="45" value="<? echo $l_name ?>" /></td>
            </tr>
            <tr>
                <td class="con1" valign="top">Link URL</td>
                <td class="con2" valign="top"><input type="text" name="l_url[<?php echo $i ?>]" size="45" value="<? echo $l_url ?>" /></td>
            </tr>
        <input type="hidden" name="l_description" size="45" value="<? echo $l_description ?>" />
        <input type="hidden" name="l_category" size="45" value="<? echo $l_category ?>" />
            <tr>
                <td class="con1" valign="top">Link Display</td>
                <td class="con2" valign="top"><input type="text" name="l_level[<?php echo $i ?>]" size="45" value="<? echo $l_level ?>" /></td>
            </tr>
            <tr>
                <td class="con1" valign="top">Actions</td>
                <td class="con2" valign="top"><input type="submit" name="submit" value="Submit" /></td>
            </tr>
        </table>

    <br />

    <?php
        
    }
                echo 
    "    <table class=\"main\" cellpadding=\"4\" cellspacing=\"1\" width=\"100%\">\n";
                echo 
    "        <tr>\n";
                echo 
    "            <td class=\"con1\" valign=\"top\">Actions</td>\n";
                echo 
    "            <td class=\"con2\" valign=\"top\"><input type=\"submit\" name=\"submitall\" value=\"Submit All\" /></td>\n";
                echo 
    "        </tr>\n";
                echo 
    "    </table>\n";
                echo 
    "</form>\n";
        }
        if(
    $_POST['submit']){
            
    $updatesql "UPDATE $linkprefix SET l_name='$l_name[$i]', l_url='$l_url[$i]', l_level='$l_level[$i]' WHERE l_id='$l_id'";
            
    $updateresult mysql_query($updatesql);
        if(!
    $updateresult){
                echo 
    "There was a problem with your query.  Either the data you entered wasn't valid or there is an error.  Contact the Administrator.";
        exit();
        }else{
            
    $redirectmessage "Selected Link has been updated.";
            
    $DIRECTURL "Copy of editlinks.php";
        include(
    "../direct.php");
        exit();
        }
        
        }
    ?>

  2. #2
    Join Date
    May 2004
    Posts
    1
    if($_POST['submitall']){
    $_POST['submitall'] ==> $_POST['message']

    Quote Originally Posted by Shanksta
    PHP Code:
        global $conn;
        
        if($_POST['submitall']){
            
            $l_id    = $_POST['l_id'];
            $l_name  = $_POST['l_name'];
            $l_url   = $_POST['l_url'];
            $l_level = $_POST['l_level'];
            
            $sql = "SELECT * FROM $linkprefix";
            $result = mysql_query($sql);
            $linkcount = mysql_numrows($result);
            
        for ($i = 0; $i < $linkcount; ++$i){
            
        if (empty($l_name[$i])){
            $redirectmessage = "You must enter a link name.";
            $DIRECTURL = "Copy of editlinks.php";
        include("../direct.php");
        exit();
        }
        
        if (empty($l_level[$i]) || (preg_match('/[^0-9]/', $l_level[$i]))){
            $redirectmessage = "Position must be an integer value.";
            $DIRECTURL = "Copy of editlinks.php";
        include("../direct.php");
        exit();
        }
        
        list($l_id, $l_level) = mysql_fetch_row($result);
        $allsql = mysql_query("UPDATE $linkprefix SET l_name='$l_name[$i]', l_url='$l_url[$i]', l_level='$l_level[$i]' WHERE l_id='$l_id'");
        }
        }
        
        if (!$_POST['submit'] || !$_POST['submitall']){
            $sql = "SELECT * FROM $linkprefix";
            $result = mysql_query($sql);
            $linkcount = mysql_numrows($result);
            
        for ($i = 0; $i < $linkcount; ++$i)
            $linklist[] = mysql_fetch_row($result);

        for ($i = 0; $i < $linkcount; ++$i){
        list(, list($l_id, $l_name, $l_url, $l_description, $l_category, $l_level)) = @each($linklist);
    ?>
        <table class="main" cellpadding="4" cellspacing="1" width="100%">
            <tr class="head">
                <td class="head" valign="top"><b>Edit An Entry</b></td>
                <td class="headcent" valign="top"></td>
            </tr>
            <tr>
        <form action="<? echo $PHP_SELF ?>" method="post" name="message">
                <td class="con1" valign="top">Link Name</td>
                <td class="con2" valign="top"><input type="hidden" name="l_id[<?php echo $i ?>]" value="<? echo $l_id ?>" /><input type="text" name="l_name[<?php echo $i ?>]" size="45" value="<? echo $l_name ?>" /></td>
            </tr>
            <tr>
                <td class="con1" valign="top">Link URL</td>
                <td class="con2" valign="top"><input type="text" name="l_url[<?php echo $i ?>]" size="45" value="<? echo $l_url ?>" /></td>
            </tr>
        <input type="hidden" name="l_description" size="45" value="<? echo $l_description ?>" />
        <input type="hidden" name="l_category" size="45" value="<? echo $l_category ?>" />
            <tr>
                <td class="con1" valign="top">Link Display</td>
                <td class="con2" valign="top"><input type="text" name="l_level[<?php echo $i ?>]" size="45" value="<? echo $l_level ?>" /></td>
            </tr>
            <tr>
                <td class="con1" valign="top">Actions</td>
                <td class="con2" valign="top"><input type="submit" name="submit" value="Submit" /></td>
            </tr>
        </table>

    <br />

    <?php
        
    }
                echo 
    "    <table class=\"main\" cellpadding=\"4\" cellspacing=\"1\" width=\"100%\">\n";
                echo 
    "        <tr>\n";
                echo 
    "            <td class=\"con1\" valign=\"top\">Actions</td>\n";
                echo 
    "            <td class=\"con2\" valign=\"top\"><input type=\"submit\" name=\"submitall\" value=\"Submit All\" /></td>\n";
                echo 
    "        </tr>\n";
                echo 
    "    </table>\n";
                echo 
    "</form>\n";
        }
        if(
    $_POST['submit']){
            
    $updatesql "UPDATE $linkprefix SET l_name='$l_name[$i]', l_url='$l_url[$i]', l_level='$l_level[$i]' WHERE l_id='$l_id'";
            
    $updateresult mysql_query($updatesql);
        if(!
    $updateresult){
                echo 
    "There was a problem with your query.  Either the data you entered wasn't valid or there is an error.  Contact the Administrator.";
        exit();
        }else{
            
    $redirectmessage "Selected Link has been updated.";
            
    $DIRECTURL "Copy of editlinks.php";
        include(
    "../direct.php");
        exit();
        }
        
        }
    ?>

Posting Permissions

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