473,324 Members | 2,313 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

send data at same id?

27
i have alot of check boxes and through that check boxex one select seat and send tha seat number to database.

i have a table named called trip in which i have some fields which are ok but they are on the start page user send booking time and selects "from" "to" after sending that there is a page of seat selection when ever im sending data of seat selection it sends data to the other line how can i send that too on the same line as the others are???


im sending data through this its working.

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. $connection = mysql_connect("localhost","root","autodeskmaya") or die("error connect");
  4. mysql_select_db("online_bus_project");
  5.  
  6.  
  7. if(isset($_POST['team']))
  8.  
  9. {
  10.  
  11. foreach($_POST['team'] as $value) {
  12.  
  13. $insert="INSERT INTO trip (seat) VALUES ('$value')";
  14.  
  15. mysql_query($insert);
  16.  
  17. }
  18.  
  19. }
  20.  
  21. ?>
May 10 '09 #1
4 1414
prabirchoudhury
162 100+
it seems like you have a wrong relational data structure or sql injection. so far i am making sense from your question. if i am not wrong then

Problems
1. you are trying to insert data in the same table twice, once for selection dates and other for selecting seat no, then it would come two lines.

2. if you want to put all data in the same table then insertion seat no would be a UPDATE table rather INSERT.

3. But if you have more then one selection for seat no (seat no 10 and 11 ) one column for "seat" in table then it is a wrong structure. would insert into more then one line.. thats probably happening for you in this case.

Solutions.

1. you must have a trip table (say trip ) with each trip details. get the primary key (say trip_id)

2. you must have a main booking table (say booking), get this primary key (say booking_id)

3.Could make a seperate table called "seat" and with booking_id and seat_no fields and booking_id is the foreign key of main booking table that would be filled with

4. have to avoid the over booking for one seat for same trip


Expand|Select|Wrap|Line Numbers
  1. Table seat
  2.  
  3. booking_id | trip_id |  seat_no |
  4.  
  5.  
  6.  
  7.  
  8. foreach($_POST['team'] as $value) { 
  9.  
  10. $insert="INSERT INTO seat (booking_id, trip_id, seat_no) VALUES ('$booking_id','$trip_id', '$value')"; 
  11.  
  12. mysql_query($insert); 
  13.  
  14.  
  15. }


might help this ..
May 11 '09 #2
obtrs
27
thanx for the help....

so how much fields i make for the seat selection say i made 8 OK so how that would be done if a person say select more than one field how it will insert that into separate fields?
May 11 '09 #3
obtrs
27
how can i insert more than one values in this???

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. $connection = mysql_connect("localhost","root","autodeskmaya") or die("error connect");
  4. mysql_select_db("online_bus_project");
  5.  
  6.  
  7. if(isset($_POST['team']))
  8.  
  9. {
  10.  
  11. foreach($_POST['team'] as $value) {
  12.  
  13. $insert="INSERT INTO seats (seat) VALUES ('$value')";
  14.  
  15. mysql_query($insert);
  16.  
  17. }
  18.  
  19. }
  20.  
  21. ?>
  22.  
i have table called seats in this i have these fields "seat, seat_two, seat_three, seat_four, seat_five, seat_six"

if a user wants to reserve more than one fields so he can upto six.


HTML Form:-

Expand|Select|Wrap|Line Numbers
  1. <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
  2.  
  3.  
  4.   <table width="94%" bgcolor="#cacb98" border="1" cellpadding="0" cellspacing="0">
  5.     <tbody><tr> 
  6.             <td width="12%">  
  7.               <input name="team[]" value="1" type="checkbox">
  8.               <font size="2" face="verdana">1</font>  </td>
  9.             <td width="12%">  
  10.               <input name="team[]" value="2" type="checkbox">
  11.               <font size="2" face="verdana">2</font>  </td>
  12.             <td width="13%">  
  13.               <input name="team[]" value="3" type="checkbox">
  14.               <font size="2" face="verdana">3</font>  </td>
  15.             <td width="13%">  
  16.               <input name="team[]" value="4" type="checkbox">
  17.               <font size="2" face="verdana">4</font>  
  18.             </td>
  19.             <td width="20%">  
  20.               <input name="team[]" value="5" type="checkbox">
  21.               <font size="2" face="verdana">5</font>  </td>
  22.           </tr>
  23.           <tr> 
  24.             <td width="12%">  
  25.               <input name="team[]" value="6" type="checkbox">
  26.               <font size="2" face="verdana">6</font>  </td>
  27.             <td width="12%">  
  28.               <input name="team[]" value="7" type="checkbox">
  29.               <font size="2" face="verdana">7</font>  </td>
  30.             <td width="13%">  
  31.               <input name="team[]" value="8" type="checkbox">
  32.               <font size="2" face="verdana">8</font>  </td>
  33.             <td width="13%">  
  34.               <input name="team[]" value="9" type="checkbox">
  35.               <font size="2" face="verdana">9</font>  </td>
  36.             <td width="20%">  
  37.               <input name="team[]" value="10" type="checkbox">
  38.               <font size="2" face="verdana">10</font>  </td>
  39.           </tr>
  40.           <tr> 
  41.             <td width="12%">  
  42.               <input name="team[]" value="11" type="checkbox">
  43.               <font size="2" face="verdana">11</font>  </td>
  44.             <td width="12%">  
  45.               <input name="team[]" value="12" type="checkbox">
  46.               <font size="2" face="verdana">12</font>  </td>
  47.             <td width="13%">  
  48.               <input name="team[]" value="13" type="checkbox">
  49.               <font size="2" face="verdana">13</font>  </td>
  50.             <td width="13%">  
  51.               <input name="team[]" value="14" type="checkbox">
  52.               <font size="2" face="verdana">14</font>  </td>
  53.             <td width="20%">  
  54.               <input name="team[]" value="15" type="checkbox">
  55.               <font size="2" face="verdana">15</font>  </td>
  56.           </tr>
  57.           <tr> 
  58.             <td width="12%">  
  59.               <input name="team[]" value="16" type="checkbox">
  60.               <font size="2" face="verdana">16</font>  </td>
  61.             <td width="12%">  
  62.               <input name="team[]" value="17" type="checkbox">
  63.               <font size="2" face="verdana">17</font>  </td>
  64.             <td width="13%">  
  65.               <input name="team[]" value="18" type="checkbox">
  66.               <font size="2" face="verdana">18</font>  </td>
  67.             <td width="13%">  
  68.               <input name="team[]" value="19" type="checkbox">
  69.               <font size="2" face="verdana">19</font>  </td>
  70.             <td width="20%">  
  71.               <input name="team[]" value="20" type="checkbox">
  72.               <font size="2" face="verdana">20</font>  </td>
  73.           </tr>
  74.           <tr> 
  75.             <td width="12%">  
  76.               <input name="team[]" value="21" type="checkbox">
  77.               <font size="2" face="verdana">21</font>  </td>
  78.             <td width="12%">  
  79.               <input name="team[]" value="22" type="checkbox">
  80.               <font size="2" face="verdana">22</font>  </td>
  81.             <td width="13%">  
  82.               <input name="team[]" value="23" type="checkbox">
  83.               <font size="2" face="verdana">23</font>  </td>
  84.             <td width="13%">  
  85.               <input name="team[]" value="24" type="checkbox">
  86.               <font size="2" face="verdana">24</font>  </td>
  87.             <td width="20%">  
  88.               <input name="team[]" value="25" type="checkbox">
  89.               <font size="2" face="verdana">25</font>  </td>
  90.           </tr>
  91.           <tr> 
  92.             <td width="12%">  
  93.               <input name="team[]" value="26" type="checkbox">
  94.               <font size="2" face="verdana">26</font>  </td>
  95.             <td width="12%">  
  96.               <input name="team[]" value="27" type="checkbox">
  97.               <font size="2" face="verdana">27</font>  </td>
  98.             <td width="13%">  
  99.               <input name="team[]" value="28" type="checkbox">
  100.               <font size="2" face="verdana">28</font>  </td>
  101.             <td width="13%">  
  102.               <input name="team[]" value="29" type="checkbox">
  103.               <font size="2" face="verdana">29</font>  </td>
  104.             <td width="20%">  
  105.               <input name="team[]" value="30" type="checkbox">
  106.               <font size="2" face="verdana">30</font>  </td>
  107.           </tr>
  108.     <tr>
  109.             <td width="12%">  
  110.               <input name="team[]" value="31" type="checkbox">
  111.               <font size="2" face="verdana">31</font>  </td>
  112.             <td width="12%">  
  113.               <input name="team[]" value="32" type="checkbox"> <font size="2" face="verdana">32</font>
  114.                </td>
  115.             <td width="13%">  
  116.               <input name="team[]" value="33" type="checkbox"> <font size="2" face="verdana">33</font>
  117.                </td>
  118.             <td width="13%">  
  119.               <input name="team[]" value="34" type="checkbox"> <font size="2" face="verdana">34</font>
  120.  
  121.             </td>
  122.             <td width="20%">  
  123.               <input name="team[]" value="35" type="checkbox"> <font size="2" face="verdana">35</font>
  124.                </td>
  125.     </tr>
  126.     <tr>
  127.             <td width="12%">  
  128.               <input name="team[]" value="36" type="checkbox">
  129.               <font size="2" face="verdana">36</font>  </td>
  130.             <td width="12%">  
  131.               <input name="team[]" value="37" type="checkbox">
  132.               <font size="2" face="verdana">37</font>  </td>
  133.             <td width="13%">  
  134.               <input name="team[]" value="38" type="checkbox">
  135.               <font size="2" face="verdana">38</font>  </td>
  136.             <td width="13%">  
  137.               <input name="team[]" value="39" type="checkbox">
  138.               <font size="2" face="verdana">39</font>  </td>
  139.             <td width="20%">  
  140.               <input name="team[]" value="40" type="checkbox"> <font size="2" face="verdana">40</font>
  141.                </td>
  142.     </tr>
  143.           <tr> 
  144.             <td width="12%">  
  145.               <input name="team[]" value="41" type="checkbox"> <font size="2" face="verdana">41</font>
  146.                </td>
  147.             <td width="12%">&nbsp;  </td>
  148.             <td width="13%">&nbsp;  </td>
  149.             <td width="13%">&nbsp;  </td>
  150.             <td width="20%">  </td>
  151.           </tr>
  152.         </tbody></table>
  153.   <p align="center">&nbsp;</p>
  154.   <p></p><table>
  155.       <tbody><tr>
  156.       <td>
  157.  
  158.       <div align="center"><input type="submit" name="submit" value="submit">
  159.       </div>
May 13 '09 #4
prabirchoudhury
162 100+
Try this should wrk .. you have to pass the booking_ID and trip_id in hidden field and run a foreach loop to get the seat no checked and then insert each seat no with trip_id and booking_id



Expand|Select|Wrap|Line Numbers
  1.  
  2. <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> 
  3.  
  4.  
  5.   <table width="94%" bgcolor="#cacb98" border="1" cellpadding="0" cellspacing="0"> 
  6.     <tbody><tr>  
  7.             <td width="12%">   
  8.               <input name="team[]" value="1" type="checkbox"> 
  9.               <font size="2" face="verdana">1</font>  </td> 
  10.             <td width="12%">   
  11.               <input name="team[]" value="2" type="checkbox"> 
  12.               <font size="2" face="verdana">2</font>  </td> 
  13.             <td width="13%">   
  14.               <input name="team[]" value="3" type="checkbox"> 
  15.               <font size="2" face="verdana">3</font>  </td> 
  16.             <td width="13%">   
  17.               <input name="team[]" value="4" type="checkbox"> 
  18.               <font size="2" face="verdana">4</font>   
  19.             </td> 
  20.             <td width="20%">   
  21.               <input name="team[]" value="5" type="checkbox"> 
  22.               <font size="2" face="verdana">5</font>  </td> 
  23.           </tr> 
  24.           <tr>  
  25.             <td width="12%">   
  26.               <input name="team[]" value="6" type="checkbox"> 
  27.               <font size="2" face="verdana">6</font>  </td> 
  28.             <td width="12%">   
  29.               <input name="team[]" value="7" type="checkbox"> 
  30.               <font size="2" face="verdana">7</font>  </td> 
  31.             <td width="13%">   
  32.               <input name="team[]" value="8" type="checkbox"> 
  33.               <font size="2" face="verdana">8</font>  </td> 
  34.             <td width="13%">   
  35.               <input name="team[]" value="9" type="checkbox"> 
  36.               <font size="2" face="verdana">9</font>  </td> 
  37.             <td width="20%">   
  38.               <input name="team[]" value="10" type="checkbox"> 
  39.               <font size="2" face="verdana">10</font>  </td> 
  40.           </tr> 
  41.           <tr>  
  42.             <td width="12%">   
  43.               <input name="team[]" value="11" type="checkbox"> 
  44.               <font size="2" face="verdana">11</font>  </td> 
  45.             <td width="12%">   
  46.               <input name="team[]" value="12" type="checkbox"> 
  47.               <font size="2" face="verdana">12</font>  </td> 
  48.             <td width="13%">   
  49.               <input name="team[]" value="13" type="checkbox"> 
  50.               <font size="2" face="verdana">13</font>  </td> 
  51.             <td width="13%">   
  52.               <input name="team[]" value="14" type="checkbox"> 
  53.               <font size="2" face="verdana">14</font>  </td> 
  54.             <td width="20%">   
  55.               <input name="team[]" value="15" type="checkbox"> 
  56.               <font size="2" face="verdana">15</font>  </td> 
  57.           </tr> 
  58.           <tr>  
  59.             <td width="12%">   
  60.               <input name="team[]" value="16" type="checkbox"> 
  61.               <font size="2" face="verdana">16</font>  </td> 
  62.             <td width="12%">   
  63.               <input name="team[]" value="17" type="checkbox"> 
  64.               <font size="2" face="verdana">17</font>  </td> 
  65.             <td width="13%">   
  66.               <input name="team[]" value="18" type="checkbox"> 
  67.               <font size="2" face="verdana">18</font>  </td> 
  68.             <td width="13%">   
  69.               <input name="team[]" value="19" type="checkbox"> 
  70.               <font size="2" face="verdana">19</font>  </td> 
  71.             <td width="20%">   
  72.               <input name="team[]" value="20" type="checkbox"> 
  73.               <font size="2" face="verdana">20</font>  </td> 
  74.           </tr> 
  75.           <tr>  
  76.             <td width="12%">   
  77.               <input name="team[]" value="21" type="checkbox"> 
  78.               <font size="2" face="verdana">21</font>  </td> 
  79.             <td width="12%">   
  80.               <input name="team[]" value="22" type="checkbox"> 
  81.               <font size="2" face="verdana">22</font>  </td> 
  82.             <td width="13%">   
  83.               <input name="team[]" value="23" type="checkbox"> 
  84.               <font size="2" face="verdana">23</font>  </td> 
  85.             <td width="13%">   
  86.               <input name="team[]" value="24" type="checkbox"> 
  87.               <font size="2" face="verdana">24</font>  </td> 
  88.             <td width="20%">   
  89.               <input name="team[]" value="25" type="checkbox"> 
  90.               <font size="2" face="verdana">25</font>  </td> 
  91.           </tr> 
  92.           <tr>  
  93.             <td width="12%">   
  94.               <input name="team[]" value="26" type="checkbox"> 
  95.               <font size="2" face="verdana">26</font>  </td> 
  96.             <td width="12%">   
  97.               <input name="team[]" value="27" type="checkbox"> 
  98.               <font size="2" face="verdana">27</font>  </td> 
  99.             <td width="13%">   
  100.               <input name="team[]" value="28" type="checkbox"> 
  101.               <font size="2" face="verdana">28</font>  </td> 
  102.             <td width="13%">   
  103.               <input name="team[]" value="29" type="checkbox"> 
  104.               <font size="2" face="verdana">29</font>  </td> 
  105.             <td width="20%">   
  106.               <input name="team[]" value="30" type="checkbox"> 
  107.               <font size="2" face="verdana">30</font>  </td> 
  108.           </tr> 
  109.     <tr> 
  110.             <td width="12%">   
  111.               <input name="team[]" value="31" type="checkbox"> 
  112.               <font size="2" face="verdana">31</font>  </td> 
  113.             <td width="12%">   
  114.               <input name="team[]" value="32" type="checkbox"> <font size="2" face="verdana">32</font> 
  115.                </td> 
  116.             <td width="13%">   
  117.               <input name="team[]" value="33" type="checkbox"> <font size="2" face="verdana">33</font> 
  118.                </td> 
  119.             <td width="13%">   
  120.               <input name="team[]" value="34" type="checkbox"> <font size="2" face="verdana">34</font> 
  121.  
  122.             </td> 
  123.             <td width="20%">   
  124.               <input name="team[]" value="35" type="checkbox"> <font size="2" face="verdana">35</font> 
  125.                </td> 
  126.     </tr> 
  127.     <tr> 
  128.             <td width="12%">   
  129.               <input name="team[]" value="36" type="checkbox"> 
  130.               <font size="2" face="verdana">36</font>  </td> 
  131.             <td width="12%">   
  132.               <input name="team[]" value="37" type="checkbox"> 
  133.               <font size="2" face="verdana">37</font>  </td> 
  134.             <td width="13%">   
  135.               <input name="team[]" value="38" type="checkbox"> 
  136.               <font size="2" face="verdana">38</font>  </td> 
  137.             <td width="13%">   
  138.               <input name="team[]" value="39" type="checkbox"> 
  139.               <font size="2" face="verdana">39</font>  </td> 
  140.             <td width="20%">   
  141.               <input name="team[]" value="40" type="checkbox"> <font size="2" face="verdana">40</font> 
  142.                </td> 
  143.     </tr> 
  144.           <tr>  
  145.             <td width="12%">   
  146.               <input name="team[]" value="41" type="checkbox"> <font size="2" face="verdana">41</font> 
  147.                </td> 
  148.             <td width="12%">&nbsp;  </td> 
  149.             <td width="13%">&nbsp;  </td> 
  150.             <td width="13%">&nbsp;  </td> 
  151.             <td width="20%">  </td> 
  152.           </tr> 
  153.         </tbody></table> 
  154.   <p align="center">&nbsp;</p> 
  155.   <p></p><table> 
  156.       <tbody><tr> 
  157.       <td> 
  158.  
  159.       <div align="center"><input type="submit" name="submit" value="submit"> 
  160.       </div> 
  161.       <INPUT TYPE="hidden" NAME="booking_id" VALUE=102>
  162.       <INPUT TYPE="hidden" NAME="trip_id" VALUE=10>
  163.  
  164. </form>
  165.  
  166. <br><br>
  167.  
  168.  
  169.  
  170. <?
  171.  
  172. //echo "submitred result=".$_POST["booking_id"]."<br>";
  173.  
  174.  
  175. foreach($_POST['team'] as $seat=> $value)
  176. {
  177.     $seat =$seat+1;
  178.     echo "The seat no $seat is $value<br>"; 
  179.   $sql = "INSERT into table_name (booking_id, trip_id, seat_no )";
  180.   $sql .= "VALUES ('".$_POST['booking_id']."','".$_POST['trip_id']."','".$value."' )";
  181.   mysql_query($sql)or die("cant execute : $sql");
  182.  
  183. }
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190. ?>
  191.  
  192.  
May 14 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Etienne Charland | last post by:
Hi, there is an application running on a remote desktop (under Citrix ICA, but the same problem applies for RDC or PC Anywhere). Now, I want to send keys to the remote application from a local app....
1
by: Kitchen Bin | last post by:
Hi. I am trying to use Sockets to do multiple Send and Receives via HTTP (not simultaneously). A first pair of Send/Receives works fine and sure enough I receive HTML back, but the next...
0
by: zhimin | last post by:
Hi, I'm writing a program to send large file(100m) through dotnet using TCPListener & TCPClient, I'm sending the file with a ask and response loop: 1. Client send a flag 1 to server indicate it...
2
by: Matt | last post by:
Hi, I've got a C# client/service application using a Socket object to communicate. I have a socket bug that I can't solve without kludged-code. Does anyone know a more elegant solutions? Is this...
9
by: eswanson | last post by:
I have a web page I need to post a file plus some other fields to it. How can I do this from a asp.net page. I know I can send individual fields to the other page, but how do I send a file to the...
2
by: yvan | last post by:
Hi, Here is my client/server scenario: Step1: Client connects to server and sends data sucessfully (using Socket.Send()). Step2: Server gracefully exists (calls Socket.Shutdown() and...
4
by: Joseph Geretz | last post by:
We use a Soap Header to pass a token class (m_Token) back and forth with authenticated session information. Given the following implementation for our Logout method, I vastly prefer to simply code...
2
by: Jack | last post by:
Hi all, I am writing an application that sends and receives large amount of data to and from a server. I want to encode each packet similar to a struct such that, each message has a 4 bit code...
3
by: Jason | last post by:
Hello I've got some test code that I've found on the web that is a TCP server and a TCP client. The server sends data to the client on the port i specify. I know because get the port number...
1
by: danfolkes | last post by:
Hey Everyone, I am trying to send repeated messages from a "Node" to a "Server". It works the first time I send the from the Node to Server, but after that it either errors, or does not do...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.