Dear friends,
I developin a webside in php where clients can send their enquiry of material.I have text boxs which clients will fill when click add button this enquiry will goto down table on a same page..
Please give me idea.??

Recommended Answers

All 27 Replies

If you also mean the data should be stored in a database I would suggest following a CRUD tutorial. The twitter bootstrap part is optional, but comes with a ton of nifty pre-written CSS/HTML/JavaScript components.

If you just want to show the user the data in table form without storing it you could do it fairly easy using jQuery, specifically jQuery's after() function to insert a new row at the bottom.

yes , i want second option becase first data will collect in table one by one .for example i want 3 items .fisrt i will enter all description of first item and click button and first item all detail will goto table and text boxs will clear after i will enter second item all description and so on... last i will click button submit this button will store all three items detail in database.
like that..

I dont understand you say i want second one and then you say at last database .You want to show it on table or store it in database

ok lets first , i want to transfer all textbox values to table after clicking ADD bitton...how is it?

plz help me anyone

you have to add iframe to your index page and the form will be displayed in same manner in which you entered on the same page.Please share your code so that i can help

dear frd, plz check my code

<form action="">
<fieldset>
Company Name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<?php
include "conn.php";
  $sql="SELECT * FROM login1 ";
  $result=$conn->query($sql);
  echo "<select name=cn value=''>Company Name</option>"; // list box select command
foreach ($conn->query($sql) as $row){//Array or records stored in $row
echo "<option value=$row[id]>$row[L1]</option>";
/* Option values are added by looping through the array */
}
echo "</select>";// Closing of list box <br>
?>     <br><br>
  Item Descriptiop:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="ItemN" /><br> <br>
  Item Quantity:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="ItemQ" /> <br>   <br>
  Item Size/wt(kg)/unit: <input type="text" name="ItemS" /><br> <br>
  Remarks:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="text" name="Rem" /><br>                     <br>
   <input type="submit" name="submit" value="ADD" />
  </fieldset>
  </form>
    <table style="width: 100%">
    <tr>
    <th>SR #</th>
    <th> Company Name</th>
    <th>Item description</th>
    <th> Quantity</th>
    <th>Size/Unit/Wgt</th>
    <th>Remarks</th>
    </tr>
    <tr>
      <td>1</td>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
      <td></td>

    </tr>
    <tr>
      <td>2</td>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
</tr>
<tr>
      <td>3</td>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
</tr>
<tr>
      <td>4</td>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
</tr>
<tr>
      <td>5</td>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
</tr>
     </table>
          <br>
     <input type="submit" name="submit1" value="SUBMIT" />

this code is ok but what i want, when user came ad enter equery detail when he will click ADD button a textboxes data transfer to table and textboxes will cleare for next enquery......and when he done after it will submit his his order.

YOu have included conn.php where is that

ok got it

then what to do ?

nobody is here to reply?

It's the new year holiday today, so you can't really expect instant replies. A little patience, and someone will be along to help when they have the time.

@zebnoon1 bro sorry i was out not at home.Now i will check it just give me some time.I always fight with my wife why you have not cooked something .Her reply always is as usual.I have put all the things in a pot let it boil if i take it off the stove it will get wasted.
So be patient smile coding needs patience.If i dont reply their are hundereds here who can reply you as Sir has already told becaues of holiday you have not got answer otherwise you would have got .

friends,
First off all congratilate u all HAPPY new years...and appologize ,i did remember.thx ur remind me....

I worked a little bit on your project.I have shown in my code how you can display the form data on same page ,however lot more e.g formating etc you have to do.We will still work on it .I got little time to work on it.
THis is your first page you have to include i.php in it

<?php
include "i.php";
?>

<!DOCTYPE html >

<head>
<title>Refresher test</title>
</head>
<body>
<br/><br/><h2>What Me Refresh</h2>


<?php




if($itemN != "") {
    echo "Item Description : $itemN";

if($itemQ != "") {
    echo "Item Quantity :</br> $itemQ";

if($itemS != "") {
    echo "Item Size :</br> $itemS";
}
}
}
else {
?>



<p><h3>Enter text in the box then select "Go":</h3></p>

<form method="post" target= "iframe">
<textarea rows="2" cols="20" name="itemN" >
</textarea>
<textarea rows="2" cols="20" name="itemQ" >
</textarea>
<textarea rows="2" cols="20" name="itemS" >
</textarea>
<input type="submit" name="submit" value="Go" />
</form>

<?php } ?>

</body>
</html>

This is next file

<iframe src="/samepage/i.php" name="iframe">
height="400" 
width="600"
<?php

$itemN = "";
$itemQ = "";
$itemS = "";


session_start();


if (isset($_POST['submit']) && ($_POST['itemN']) != "" && (($_POST['itemQ']) != "") && (($_POST['itemS']) != "")) {
    $_SESSION['itemN'] = $_POST['itemN'];
    $_SESSION['itemQ'] = $_POST['itemQ'];
    $_SESSION['itemS'] = $_POST['itemS'];
    header("Location: ". $_SERVER['REQUEST_URI']);
    exit;
}
 else 

 {
    if(isset($_SESSION['itemN']) && ($_SESSION['itemQ']) && ($_SESSION['itemS'])) {

        //Retrieve show string from form submission.

        $itemN = $_SESSION['itemN'];
        $itemQ = $_SESSION['itemQ'];
        $itemS = $_SESSION['itemS'];

        unset($_SESSION['itemN']);
    }
}

?>
</iframe>

This may not be a solution but this will give you an ideo how to display data on same page

dear frd I just want to tranfer data from textboxes to Table rows after clicking add button iframe is note good idea..

dear frd ,
check my code..

<!DOCTYPE html>
<html>

<head>
  <title>Online enquiry form</title>
     <style>

     #header{
         background-color: black;
         color: white;
         text-align: center;
         padding: 5px;

     }
     #nav{
       line-height: 30px;
       background-color: #eeeeee;
       height: 550px;
       width: 100px;
       float: left;
       padding: 5px;

     }
     #section{
       width: 1000px;
      float: left;
       padding: 50px;
       }
     #footer{
       background-color: black;
       color: white;
       clear:  both;
       text-align: center;
       padding: 5px;
     }

     table,th,td{
        border: 1px solid black;
        border-collapse: collapse;
     }
     th,td{
           padding: 5px;

     }
     td{
          border:2px solid #456879;
    border-radius:10px;
    height: 10px;
    width: 230px;
     }

     th{
       text-align: left;

     }

     </style>
</head>

<body>
<div id="header">
   <center><h1> Online Enquiry</h1></center>
   </div>
   <div id="nav">
   Home<br>
   Logout<br>
   Close<br>
   </div>


<div id="section">

<form  method="post">
<fieldset>
Company Name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<?php
include "conn.php";
  $sql="SELECT * FROM login1 ";
  $result=$conn->query($sql);
  echo "<select name=cn value=''>Company Name</option>"; // list box select command
foreach ($conn->query($sql) as $row){//Array or records stored in $row
echo "<option value=$row[id]>$row[L1]</option>";
/* Option values are added by looping through the array */
}
echo "</select>";// Closing of list box <br>
?>     <br><br>
  Item Descriptiop:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="ItemN" /><br> <br>
  Item Quantity:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="ItemQ" /> <br>   <br>
  Item Size/wt(kg)/unit: <input type="text" name="ItemS" /><br> <br>
  Remarks:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="text" name="Rem" /><br>                     <br>
   <input type="submit" name="submit" value="ADD" />
  </fieldset>
  </form>

      <table style="width: 100%">
    <tr>

    <th> Company Name</th>
    <th>Item description</th>
    <th> Quantity</th>
    <th>Size/Unit/Wgt</th>
    <th>Remarks</th>
    </tr>
  <?php
if(isset($_POST['submit'])){
   $in=filter_input(INPUT_POST,'ItemN',FILTER_SANITIZE_SPECIAL_CHARS);
      while ($row=$in->fetch_assoc()){
echo ("<tr><td>$in</td></tr>");
//echo ("<td>$row[enqDate]</td>");
//echo ("<td>$row[pn]</td>");
//echo ("<td>$row[sp]</td>");
//echo ("<td>$row[cn]</td>");
///echo ("<td>$row[cph]</td>");
//echo ("<td>$row[cd]</td>");
//echo ("<td>$row[cem]</td>");
//echo ("<td>$row[enq]</td>");
       }
}  else{
 if (!(isset($_POST['ItemN']))){
  echo
 "<script type=\"text/javascript\">".
  "window.alert('You must enter your full name.');".

  "</script>";
}
}
     ?>
     </table>
          <br>
     <input type="submit" name="submit1" value="SUBMIT" />
     </div>


 <div id="footer">
 National Industrialink @ All coppies rights reserved..
 </div>

</body>
</html>

please tell me how to increase rows when i enter data again and adain on clicking ADD button...

Do you want to use database or without database i mean you want to send data to phpadmin and then display that data in table or you want to use sessions to store data.

i dont want to use database, just on clicking ADD button and textboxes data have to come in table 1 row ,and textboxs become clear then again user enter data in textboxs and clicks, data have to trnasfer in second row and so on...

i dont want to use session also.
for example on online purchase system ,client come and book diffirents item and last he click Submit button.

YOu dont want to use database then why have you written code for that?

dear friend ,
after the filling table ..user will click button of submit all data will goto database,but i devided this form first part is to fill table diffirent item name,quantity and second is sending data to database.

no body can help me?

Again, use jQuery to collect the user input and store it in your table. Then use the AJAX functions in jQuery to POST your table data to a PHP page that will store them in a database. Since I take it you don't want to add the information to the database until all the "row" inputs have been made.

Use the selectors and manipulators to retrieve the data from the inputs and attach them to the table. The add button you mentioned could then call the POST function and send the gathered data to your PHP page for database storage.

if you are table created in MySQLi the you can esily exicute this query:
$conn = mysqli_connect($servername, $username, $password, $dbname);
by:
itecg.com

Dear Friends,
thaks for response.please check my code

<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<script language="javascript" type="text/javascript">
var i=1;
function addRow()
{
          var tbl = document.getElementById('table1');
          var lastRow = tbl.rows.length;
          var iteration = lastRow - 1;
          var row = tbl.insertRow(lastRow);

          var firstCell = row.insertCell(0);
          var el = document.createElement('input');
          el.type = 'text';
          el.name = 'name' + i;
          el.id = 'name' + i;
          el.size = 20;
          el.maxlength = 20;
          firstCell.appendChild(el);

          var secondCell = row.insertCell(1);
          var el2 = document.createElement('input');
          el2.type = 'text';
          el2.name = 'address' + i;
          el2.id = 'address' + i;
          el2.size = 20;
          el2.maxlength = 20;
          secondCell.appendChild(el2);

          var thirdCell = row.insertCell(2);
          var el3 = document.createElement('input');
          el3.type = 'text';
          el3.name = 'contactNum' + i;
          el3.id = 'contactNum' + i;
          el3.size = 20;
          el3.maxlength = 20;
          thirdCell.appendChild(el3);
         frm.h.value=i;
                  i++;


}
</script>
<head>
  <title>Online enquiry form</title>
     <style>

     #header{
         background-color: black;
         color: white;
         text-align: center;
         padding: 5px;

     }
     #nav{
       line-height: 30px;
       background-color: #eeeeee;
       height: 550px;
       width: 100px;
       float: left;
       padding: 5px;

     }
     #section{
       width: 1000px;
      float: left;
       padding: 50px;
       }
     #footer{
       background-color: black;
       color: white;
       clear:  both;
       text-align: center;
       padding: 5px;
     }

     table,th,td{
        border: 1px solid black;
        border-collapse: collapse;
     }
     th,td{
           padding: 5px;

     }
     td{
          border:2px solid #456879;
    border-radius:10px;
    height: 10px;
    width: 230px;
     }

     th{
       text-align: left;

     }

     </style>
</head>

<body>
<div id="header">
   <center><h1> Online Enquiry</h1></center>
   </div>
   <div id="nav">
   Home<br>
   Logout<br>
   Close<br>
   </div>


<div id="section">

<form  method="post">
<fieldset>
Company Name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<?php
include "conn.php";
  $sql="SELECT * FROM login1 ";
  $result=$conn->query($sql);
  echo "<select name=cn value=''>Company Name</option>"; // list box select command
foreach ($conn->query($sql) as $row){//Array or records stored in $row
echo "<option value=$row[id]>$row[L1]</option>";
/* Option values are added by looping through the array */
}
echo "</select>";// Closing of list box <br>
?>     <br><br>
  Item Descriptiop:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="ItemN" /><br> <br>
  Item Quantity:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="ItemQ" /> <br>   <br>
  Item Size/wt(kg)/unit: <input type="text" name="ItemS" /><br> <br>
  Remarks:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="text" name="Rem" /><br>                     <br>
   <input type="submit" name="submit" value="ADD" onclick="addRow()" />
  </fieldset>
  </form>

      <table style="width: 100%">
    <tr>

    <th> Company Name</th>
    <th>Item description</th>
    <th> Quantity</th>
    <th>Size/Unit/Wgt</th>
    <th>Remarks</th>
    </tr>
  <?php
if(isset($_POST['submit'])){
   $in=filter_input(INPUT_POST,'ItemN',FILTER_SANITIZE_SPECIAL_CHARS);
   $r=1;

   while ($r<=1){
echo ("<tr><td>$r</td>");
echo ("<td>$in</td>");
//echo ("<td>$row[pn]</td>");
//echo ("<td>$row[sp]</td>");
//echo ("<td>$row[cn]</td>");
///echo ("<td>$row[cph]</td>");
//echo ("<td>$row[cd]</td>");
//echo ("<td>$row[cem]</td>");
//echo ("<td>$row[enq]</td>");
$r++;
       }
}  else{
 if (!(isset($_POST['ItemN']))){
  echo
 "<script type=\"text/javascript\">".
  "window.alert('You must enter data....');".

  "</script>";
}
}
     ?>
     </table>
          <br>
     <input type="submit" name="submit1" value="SUBMIT" />
     </div>


 <div id="footer">
 National Industrialink @ All coppies rights reserved..
 </div>

</body>
</html>

this data is transforing from text box to table, but problem is that when i enter second time data and click add button it dose not goto second line ,it changes fist data into second .i think there is any loop has to work for adding more and more lines if i enter data and click ADD button.

plz reply me professionals?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.