Jump to content

multi div layered form only last input populates


powpow

Recommended Posts

Hello Everyone,

 

I know one freak's forum post shouldn't be more important than the next but I am the last hours of a web project and could really use the quickest help possible. 

 

I have coded a html form that has elements on multiple divs.  The hope of this to add toggle functionality so the user does not have to view all of the information if they do not want to. 

 

here is my code(CTRL F <!-- FORM STARTS HERE -->)

 

session_start();
#print_r($_SESSION);
include '../connect.php';

function alert($test, $name){
$text = "this is ".$name." :";
$text .= $test;
echo "<SCRIPT language=\"JavaScript\"> 

alert('".$text."'); 

</SCRIPT> ";
};


//checking to see if edit button has been submitted
if(isset($_POST['Special']) && ($_POST['Special'] !== ""))
{
echo "<p> is set </p>";

  // set session
  $row0 = $_SESSION['editPage'];
  $row1 = $_SESSION['title'];
  $row2 = $_SESSION['slide'];
  $row3 = $_SESSION['subtitle'];
  $text = htmlentities($_POST['adminText']);

$postSet = True;


}
else  //if post hasn't been submitted
{
  $row0 = $_SESSION['editPage'] = htmlentities($_GET['pagename']);

  //select * from pages table with this page name
  $sql="SELECT * 
        FROM rpowell_ariana.pages
        where `page`='".$row0."'";
  $results = mysql_query($sql);
  if(!$results){
    die("<p> SQL pages error :<br/> sql: " .$sql. "<p/>".mysql_error());
  }
  else
  {
    //use sql query results to pop sess and shorthand variables
    $row = mysql_fetch_array( $results );
    $row1 = $_SESSION['title'] = $row['title'];
    $row2 = $_SESSION['slide'] = $row['slide'];
    $row3 = $_SESSION['subtitle'] = $row['subtitle'];
}
}
##### 1.1 ######
   
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
   <meta name="description" content="Ariana Restaurant Cuisine from Afghanastan" />
   <meta name="keywords" content="Boston, Ariana, Afghanastan food, Allston Massachusetts" />
   <meta name="author" content="Rob Powell" />
   <meta name="ROBOTS" content="INDEX, NOFOLLOW"/>
   <meta charset="UTF-8" />
   
   <title>Admin Panel</title>
   
   <link rel="stylesheet" type="text/css" href="../style/reset.css" />
   <link rel="stylesheet" type="text/css" href="../style/style.css" />
   <link rel="stylesheet" type="text/css" href="../style/admin.css" />
   <!--[if lt IE 7]>
      <link rel="stylesheet" type="text/css" href="../style/style-ie.css" />
   <![endif]-->

<!-- include jQuery library -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
</head>

<body>

   <div id="page-wrap">
      <div id="inside">
         
         <div id="header">
           <div id="hTitle">
             <div id="lTitle">
             <div id="titleImg">
               <img src="../images/Tower.jpg" alt="Image of Afgany Tower"/>
             </div>
             </div> 
            
                       <div id="rTitle">
               
               <div id="title1">
                 <p>Ariana Restaurant <br/> Cuisine from Afghanistan</p>
                    </div>
                           
               <div id="title2"> 
             <p>129 Brighton Ave <br/>
              Allston, MA 02134 <br/>
              Tel 617-208-8072  <br/> 
              FAX 617-562-0237 <br/> 
              Sun-Thurs 5-10pm <br/> 
              Fri, Sat 5-11pm</p>
                    </div>
                  
                    <div style="clear: both;"></div>
             </div>
             <div style="clear: both;"></div>
           </div> <!-- row -->   
            
         </div> <!-- header -->
             
         <div id="left-sidebar">
            <ul>
            <li id = 'Home'><a href='home.php?pagename=index.php' id = 'Home1'>Home</a></li>
            <li id = 'Spec'><a href='specials.php?pagename=special.php' id = 'Spec1'>Specials</a></li>
            <li id = 'Apps'><a href='app.php?pagename=Apps.php' id = 'Apps1'>Appetizers</a></li>
            <li id = 'SS'><a href='ss.php?pagename=SS.php' id = 'SS1'>Soups & Salads</a></li>
            <li id = 'Ent'><a href='ent.php?pagename=Ent.php' id = 'Ent1'>Entrées</a></li>
                                <li id = 'Vent'><a href='vent.php?pagename=VEnt.php' id = 'Vent1'>Vegeterian Options</a></li>
            <li id = 'Des'><a href='des.php?pagename=Des.php' id = 'Des1' >Desserts</a></li>
            <li id = 'Wine'><a href='wine.php?pagename=Wine.php' id = 'Wine1'>Wine</a></li>
            <li id = 'CU'><a href='cu.php?pagename=CU.php' id = 'CU1'>Contact Us</a></li>
            <li id = 'Rev'><a href='rev.php?pagename=Reviews.php' id = 'Rev1'>Reviews</a></li>
      
            </ul>

         </div><!-- left-sidebar -->
         
         <div id="main-content">
         
         
         <h1 id="PageTitle"><? echo htmlentities($row1)?></h1>
                <div id="CUform">
                
<?

if($postSet =="True"){


echo "<p>";
print_r($_POST);
echo count($_POST);
echo "</p>";
}
else{
       echo "<table border='1'>";
       echo "<tr> <th>Link Text</th> <th>Linked Document</th> <th> Order</th> <th></th></tr>";
       ####1.3######
$row0="special.php";
$row1="Specials";
$row2=1;



   // Print out the contents of each row into a table
   echo "<tr><td>"; 
   echo $row0;
   echo "</td><td>"; 
   echo $row1;
   echo "</td><td>"; 
   echo $row2;
   echo "</td><td>";
   echo $row3;
   echo "</td></tr>";

        echo "</table>";

//find if default slide has been selected
  $sel0 = "";
  $sel1= "";
  switch ($row2){
    case 0:
      $sel0 = "selected=\"yes\"";
      
    break;
    case 1:
      $sel1 = "selected=\"yes\"";
    break;
   } 
   
   $disabled = "disabled=\"disabled\"";

?>

        <!--< for edit quick display>-->
   <form id="Edit" name="Edit" method="POST" action="home.php">
     <label for="pageNameE">Page Name : </label> 
       <? echo "<p id='pageNameE'> ".$row0."</p>"; ?>
          <label for="pageTitleE">Page Title : </label> 
       <? echo "<p id='pageTitelE'> ".$row1."</p>"; ?>
     <label for="pageSlideE">Default Slide Show : </label> 
            <select name="pageSlideE" <? echo $disabled ?>>
              <option value="0" <? echo $sel1;?>>Yes</option>
         <option value="1" <? echo $sel0;?>>No</option>
            </select>
            </form>
<?php


//find and retrieve any data associated to page and title 
    $sql="SELECT * 
         FROM rpowell_ariana.food
         where `parentpage`='".$row0."' 
         order by `parentord` ASC";
    $results = mysql_query($sql);
    if(!$results){
      die("<p> SQL pages error :<br/> sql: " .$sql. "<p/>".mysql_error());
    }
    else
    {
  
?>
<!-- FORM STARTS HERE -->
  <form name="specialA" action="<?php htmlentities( $_SERVER['PHP_SELF']);?>" method="post">   
<?
#echo "<p> $sql </p>";

$foodTitle ="";
    while($row = mysql_fetch_array($results, MYSQL_NUM)){
   
/*   echo "<p>";
    print_r($row);

   
  
    if(strlen($foodFTitle) ==0){
        echo strlen($foodFTitle);
       }
     if($foodFTitle ==""){
       echo ($foodFTitle);
       }
    echo "</p>";
  */   
    
    
      //if $foodtitle is populated and row[1] does not equal $foodTitle(previous row[1] 
    if((($foodTitle !=="") || (strlen($foodTitle) == 0)) && ($foodTitle !== $row[1])
       || (strlen($foodFTitle) == 0)) {

                 
  /*    echo "<p>this is food title \"".$foodTitle."\"</p>";
      echo "<p>".$foodTitle."</p>";
      echo "<p>".$row[1]."</p>";
   */   

?> 
    <fieldset class="specialAFields">    
    <div class="foodHeader">
     <div class="row">
      <p class="foodTitle"> <? echo $row[1]; ?></p>
      <div class="fHeaderR">
       <label for="foodOrder">Order: </label>
       <input type="text" name="foodOrder" class="foodOTxt" value="<? echo $row[2]; ?>">
      </div> <!-- // fheaderR-->
      </div> <!-- // row -->
    </div> <!-- //foodHeader -->
    </fieldset>
   <? 
    
     }

    ?>
    
    <fieldset class="specialAFields">
    <div id="menuDisplay">
    <div class="foodSub">
     
      
        <div class="row">
        
         <div class="cellL">
            <label for="foodT">Title: </label>
            <input type="text" name="foodT" class="foodTTxt" value="<? echo $row[3]; ?>">
          </div> <!-- //cellL -->
          
          <div class="cellC">
            <label for="foodO">Order: </label>
            <input type="text" name="foodO" class="foodOTxt" value="<? echo $row[4]; ?>">
          </div> <!-- //cellC -->
      
         
        </div> <!--  //row -->
     </div> <! -- //foodSub -->
        <div class="foodDdesc">
          <div class="row">
            <label for="foodD">Desc: </label>
            <textarea id='elementText' name='foodD' cols='45' rows='8'> <? echo $row[5]; ?></textarea>      
          </div> <!-- // row -->
           <div class="cellPrice">
            <label for="foodP">Price: </label>
            <input type="text" name="foodP" class="foodPTxt" value="<? echo $row[6]; ?>">
          </div> <!-- // <!--cellprice--> 
        </div> <!-- // foodDdesc -->
     </div> <!--  // menuDisplay -->
     </fieldset>

    <?  
    
    $foodTitle = $row[1];
    $foodFTitle = True;
    
    
    }// ~while row

    echo "<input type=\"submit\" name=\"Special\" value=\"Update\"></input>";
    echo "</form>";   
} // ~else result
} // ~ else post sub




?>
   </div>   <!--CUform -->

   
      </div><!-- main content-->
         <div style="clear: both;"></div>
         
         <div id="footer">
            <div id="fcontact">
            <p id="address">129 Brighton Ave</p>
            <p id="Tel">Tel (617) 208-8072</p>
            <p id="Fax">Fax (617) 562-0237</p>
            </div>
            <div id="fcopy">
               <p id="Copyright">Copyright ©</p>
            </div>
            <div id="fowner">
               <a id="frpp" href="http://www.rppdesigns.com/" target="_blank">Created By RPP Designs</a>
            </div>
         </div> <!-- footer -->
      
      </div><!--inside -->
      
      <div style="clear: both;"></div>
   
   </div><!--page wrap -->

</body>

</html>



 

 

When I click the update button on this form I am only returned the last input fields and the count of the array

 

Array ( [foodOrder] => 3 [foodT] => Trout [foodO] => 2 [foodD] => Fresh trout pan-fried then saut�ed with onions, peeled tomatoes, garlic, ginger, sun-dried tomatoes, radishes and potatoes served with challow rice. [special] => Update ) 5

 

if you want to play with it, you can find the form at the following url : http://arianadev.rppdesigns.com/Login1/login/specials1.php

 

Thank you in advance!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.