算不了。 文本字段并在另一页中显示总数

search.php

<?php
$serial_no = 1;
$total_seats = $_SESSION['total_seats'];
$seats = explode(',', rtrim($total_seats, ","));
foreach ($seats as $seat) { ?>
<tr>
<td><?php echo $serial_no++; ?></td>
<td><?php echo $seat; ?> </td> </tr>

view.php

<td>Total seats</td>
<td> : </td>    
<td> </td>

Here in view.php page in the <td> , i want to show the total no of seats displayed in search.php page.. i mean when there are 4 text fields displayed in search.php page, i want to show in the view.php page, total seats : 4

You just have to use the same code you use in search.php, just with the function count() added to count the array elements.
Try this:

<?php
    session_start();
    if(isset($_SESSION['total_seats'])){
        $total_seats = $_SESSION['total_seats'];
        $seats = explode(',', rtrim($total_seats, ","));
    }
?>
<tr>
    <td>Total seats: <?php echo count($seats); ?></td>
</tr>

This will work provided your $_SESSION['total_seats'] does not change mid-way.

You can also use ,

<?php
    session_start();
    $total_seats = $_SESSION['total_seats'];
    $seats = explode(',', rtrim($total_seats, ","));
    $totalCount=count($seats);
?>

Where count is the inbuilt function returning the length of the array element.

Try this...this code will help in your work.

search.php

<form action="" method="post">
<input type="text" name="total_seats" />
<input type="submit" name="search" value="search" />
</form>
<?php
if(isset($_POST['search'])){
$serial_no = 1;
$total_seats = $_POST['total_seats'];

$seats = explode(',', rtrim($total_seats, ","));
//echo "<pre>";print_r($seats);die;
?>
<table>
<?php foreach ($seats as $seat) { ?>
<tr>
<td><?php echo $serial_no; ?></td>
<td><?php echo $seat; ?> </td> 
</tr>
<?php $serial_no++; 
}
$serial_no--;
session_start();
$_SESSION['seats'] = $serial_no;
header("Location:view.php");
?>
</table>
<?php } ?>

view.php

<?php
session_start();
echo "Hello " . $_SESSION['seats'];