473,385 Members | 1,673 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,385 software developers and data experts.

how to combine textfield with counter variables?

17
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3. <p>
  4.   <?php
  5. $result = mysql_query("SELECT distinct room_type,room_price from room1 WHERE room_no NOT IN ( SELECT id_room_no
  6. FROM reservation1 WHERE datein >='$datein' AND dateout <='$dateout')");
  7.  
  8. ?>
  9. </p>
  10. <p><strong><strong>Room Availbility</strong></p>
  11. <p>&nbsp; </p>
  12. <td><table width="61%" height="64" border="1" cellpadding="0" cellspacing="0" bordercolor="#CC66CC" class="report2">
  13.       <tr>
  14.         <td width="38" bgcolor="#E8E8E8"><div align="center"><strong>BIL</strong></div></td>
  15.         <td width="190" bgcolor="#E8E8E8"><div align="center"><strong>Room Type </strong></div></td>
  16.         <td width="218" bgcolor="#E8E8E8"><div align="center"><strong>Room Price </strong></div></td>
  17.         <td bgcolor="#E8E8E8"><div align="center"><strong>Quantity</strong></div></td>
  18.       </tr>
  19.       <?php
  20.         $counter=1;
  21.         while ($data = mysql_fetch_array($result)):
  22.         ?>
  23.       <tr>
  24.         <td height="28"><center><?php echo $start + $counter?>        
  25.         </center></td>
  26.         <td><?php echo $data['room_type']; ?></td>
  27.         <td><?php echo $data['room_price']; ?></td>
  28.         <td width="153">
  29.         <?php input type="text" name="qty".$counter; id="qty" ?>
  30.         </td>
  31.     </tr>
  32.       <?php
  33.           $counter++;
  34.           endwhile;
  35.         ?>
  36.     </table>
  37.   <p>
  38.     <label>
  39.     <input type="submit" name="submit" id="submit" value="Submit">
  40.     </label>
  41.   <a href="DisplayDetails.php">Next&gt;&gt;  </a></p>
  42. </body>
  43. </html>
  44.  
i'm really stuck here. May i know how can i combine the variables $counter with the textfield so whenever it's looping, the textfield will become text1, text2 , txt3 ?
Hopefully someone can help me..
Mar 14 '10 #1
2 1897
Markus
6,050 Expert 4TB
Line 29 should look like:

Expand|Select|Wrap|Line Numbers
  1. <input type="text" name="qty<?php echo $counter; ?>" id="qty<?php echo $counter; ?>">
  2.  
Mar 14 '10 #2
digituf
17
thanks marcus for the reply..
but still, i have some difficulties here.
How can i make when i click the submit button, it will go to the page 'DisplayDetails.php' where on the page it will only display the row where i have insert value in the textfield?

here's the current code.
Expand|Select|Wrap|Line Numbers
  1.  
  2. <html>
  3. <body>
  4. <form action="DisplayDetails.php" method="post">
  5. <p>
  6.   <?php
  7.  
  8. mysql_connect("localhost","root","alifah89"); 
  9.  
  10. mysql_select_db("unik"); 
  11.  
  12. $datein=$_POST["datein"];
  13. $dateout=$_POST["dateout"];
  14.  
  15. $result = mysql_query("SELECT distinct room_type,room_price from room1 WHERE room_no NOT IN ( SELECT id_room_no
  16. FROM reservation1 WHERE datein >='$datein' AND dateout <='$dateout')");
  17. ?>
  18. </p>
  19. <p><strong><strong>Room Availbility</strong></p>
  20. <p>&nbsp; </p>
  21. <td><table width="61%" height="64" border="1" cellpadding="0" cellspacing="0" bordercolor="#CC66CC" class="report2">
  22.       <tr>
  23.         <td width="38" bgcolor="#E8E8E8"><div align="center"><strong>BIL</strong></div></td>
  24.         <td width="190" bgcolor="#E8E8E8"><div align="center"><strong>Room Type </strong></div></td>
  25.         <td width="218" bgcolor="#E8E8E8"><div align="center"><strong>Room Price </strong></div></td>
  26.         <td bgcolor="#E8E8E8"><div align="center"><strong>Quantity</strong></div></td>
  27.       </tr>
  28.       <?php
  29.         $counter=1;
  30.         while ($data = mysql_fetch_array($result)):
  31.         ?>
  32.       <tr>
  33.         <td height="28"><center><?php echo $start + $counter?>        
  34.         </center></td>
  35.         <td><?php echo $data['room_type']; ?></td>
  36.         <td><?php echo $data['room_price']; ?></td>
  37.   <td width="153"><label>
  38.     <input type="text" name="qty<?php echo $counter; ?>" id="qty<?php echo $counter; ?>">
  39.   </label></td>
  40.     </tr>
  41.       <?php
  42.           $counter++;
  43.           endwhile;
  44.         ?>
  45.     </table>
  46.   <p>
  47.     <label>
  48.     <input type="submit" name="submit" id="submit" value="Submit">
  49.     </label>
  50.     </form>
  51.   </body>
  52. </html>
  53.  
  54.  
Mar 15 '10 #3

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

Similar topics

2
by: C. Armour | last post by:
Help me, I'm suffering! Situation: I have a load() function which loads a bunch of TextFields with values. There are TextListeners registered for each of these TextFields. Thus, changing the...
1
by: Suresh | last post by:
How do I insert a char into the textfield on the keypress event of another textfield? I have two textboxes, "text1" and "text2". Important: "text1" is outside the table. "text2" is inside...
3
by: Sidney Linkers | last post by:
Hi, I'm trying to make a calculated text field in a query where the textvalue is being populated from multiple records. I already use a VBA function to loop through records and concatenate the...
8
by: mark | last post by:
Access2000 How do I write a query that combines the CTC field from each record below into one record? I need to concatenate the CTC field with a separator, like below: ...
24
by: trint | last post by:
add them into one PrintDocument: PrintDocument pd1 = new PrintDocument(); PrintDocument pd2 = new PrintDocument(); PrintDocument pdCombined = new PrintDocument(); pdCombined = pd1 + pd2;...
1
by: platostoteles | last post by:
Hallo NG, I am new to JavaScript and would really appreciate any help to solve my problem. I am using the blow code in my form to validate form fields. What I would like to accomplish is that...
7
by: mistral | last post by:
I use htaccess to protect directory and granting access to download file only for the authorized users. Just want implement simple PHP file download counter for single file. I need track the number...
15
by: d4 | last post by:
I have a vbscript (below) I want to rewrite in C# but I cannot get it to work (unless there is a better way to do it). The script will combine 2 lines if the (next) line contains a "+",...
0
by: Trevor L. | last post by:
I decide to put a custom Hit Counter on my page (below). Then I won't be reliant on the standard FrontPage one which uses webbots. It is called by <b>Hit Counter: </b><!--#include...
1
by: zwieback89 | last post by:
Hi, I am still not able to get this working in a simple page. Please help me. I am badly stuck.... I am trying to view the contents of the Beverage Category. I have built it like a hierarchy...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.