missing array element
- From: david.g.robinson@xxxxxxxxxxxxxxxx
- Date: 29 May 2005 11:19:50 -0700
Hi,
I was wondering if anyone could help me with a problem I am having with
an array. I am only a beginner, so please be gentle!
I am trying to store the id's for 3 hotel rooms into an array called
$rooms, using a simple mysql select statement. Here is the code:
<?php require_once('Connections/Vita_Italiano.php'); ?>
<?php mysql_select_db($database_Vita_Italiano, $Vita_Italiano);
$query_rsAllRooms = "SELECT * FROM room";
$rsAllRooms = mysql_query($query_rsAllRooms, $Vita_Italiano) or
die(mysql_error());
$row_rsAllRooms = mysql_fetch_assoc($rsAllRooms);
$totalRows_rsAllRooms = mysql_num_rows($rsAllRooms);
// create array of all rooms
while ($row_rsAllRooms = mysql_fetch_assoc($rsAllRooms))
{
$rooms[]= $row_rsAllRooms['Room_Number'];
}
?>
When I use <?php print_r($rooms);?> to display the contents of the
variable, the array only contains 2 room numbers, instead of 3. These
are stored in $rooms[0] and $rooms[1].
Does anyone have any ideas what is going on here?
Thanks in advance,
David Robinson
.
- Follow-Ups:
- Re: missing array element
- From: Ewoud Dronkert
- Re: missing array element
- Prev by Date: Re: Extensions other than .php
- Next by Date: php and javascript
- Previous by thread: Dynamic Site Methodology
- Next by thread: Re: missing array element
- Index(es):
Relevant Pages
|