Forum Moderators: coopster

Message Too Old, No Replies

how to count html table row? plz hlp.

while loop ...<input type=hidden>

         

hello

11:50 pm on Apr 28, 2007 (gmt 0)

10+ Year Member



i am trying to echo "room_Type_break" field, the problem is it only prints twice of each room_Type. for e.g.

cal.php

room_type
--------
ensuite
ensuite
single
single

book.php : Output:

single single

it is not printing out ensuite...any idea?

cal.php------------------------------------------------

if($qty!== '0'){
$p=0;
while($fday<$tday){
echo "<td>$room_Type<input type='text' name='room_Type_break' value='$room_Type'></td>
$p++;
}
echo "<input type='hidden' name='count' value='$p'>"; }

book.php--------------------------------------------------

for ($i = 0; $i <= $_POST['count']; $i++) {

$room_Type_break = $_REQUEST['room_Type_break_'.$i.''];

echo "$room_Type_break";
}

eelixduppy

12:04 am on Apr 29, 2007 (gmt 0)



Hello, and Welcome to WebmasterWorld!

Try adding this to book.php and tell me what you are getting:


echo '<pre>';
print_r($_REQUEST);
echo '</pre>';

It seems as though there is something on the previous page that is not allowing the information to be sent via the form correctly, or you aren't handling the info on book.php correctly. The code above will let us know that everything is being sent to the action page correctly.

hello

1:46 am on Apr 30, 2007 (gmt 0)

10+ Year Member



hi

thanks for you reply...i managed to solve it using foreach loop...

:)

Problem after problem....now i am trying to insert into table using foreach loop...anyidea?

for e.g.

$query = mysql_query("INSERT INTO people (name)VALUES ('$name')")or die(mysql_error());
--------------------------------------------------------
foreach($names as $name){
echo "$name";
}

how do i now insert using foreach loop?

coopster

1:53 pm on Apr 30, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



When doing multiple inserts I find building the VALUES list is often the easiest approach. There is an example in this thread [webmasterworld.com] that you can study to see how it can be accomplished.

It looks like you are using MySQL, but no matter which database you are using, never trust the user-supplied data. Edit it first to make sure it contains data you expect, and then escape it or use prepared statements.

hello

6:06 pm on Apr 30, 2007 (gmt 0)

10+ Year Member



this gives me error message: Subquery returns more than 1 row

"INSERT INTO customerbook (booking_ID,room_Type)
values((select booking_ID from bookings where booking_ID = bookings.booking_ID),'$a')"

any solution?

output should be like this:

ID Type
1 single
1 ensuite

i am new to php...can you tell me plz how the above code should be done?