Hi!!
I have one tiny trouble that annoyes the heck out of me.
I have build a simple gallery where my page fetches the
name, imagename, imageplace a.s.o. from a mysql database,
but i can't get it to fetch the first row in the database it skips it
somehow and starts on row nr 2, so if i have 21 row in the database
it only fetches 20 row and skipping the first or last depending on how i sort the query.
Below is the code i use:
$table_name = $TBL_EXT.'mod_photo_album';
$sql = "SELECT * FROM $table_name ORDER BY id ASC";
$result = @($sql,$read_conn) or die("Could'nt execute query");
$num_rows = mysql_num_rows($result);
while ($row = mysql_fetch_array($result))
{
$id = $row['id'];
$name = $row['name'];
$description = $row['description'];
$thumb_filename = $row['thumb_filename'];
$unsized_filename = $row['unsized_filename'];
$category = $row['category'];
$photographer = $row['photographer'];
$when = $row['when'];
$where = $row['where'];
$equipment = $row['equipment'];
$cols = 4;
echo "$cols, $num_rows";
echo "<TABLE BORDER=\"1\">\n";
//changed this to a for loop so we can use the number of rows
for($i = 0; $i < $num_rows; $i++) {
$row = mysql_fetch_array($result);
if($i % $cols == 0) {
//if there is no remainder, we want to start a new row
echo "<TR>\n";
}
echo "<TD>" . $row['id'] . "</TD>\n";
if(($i % $cols) == ($cols - 1) || ($i + 1) == $num_rows) {
//if there is a remainder of 1, end the row
//or if there is nothing left in our result set, end the row
echo "</TR>\n";
}
}
echo "</TABLE>\n";
The $num_rows return the right value so the error is somewhere
in the loop, not in the fetching from the database but where???
Thanks in advance
Marcus