I am using Dreamweaver MX. It creates a recordset that other code is dependent upon so I cannot alter the recordset code. Within this code mysql_fetch_assoc is called creating an array of records from the results. Later I use mysql_fetch_array on the same results. The code works but the pointer in the array is advanced once item by the first fetch call. So, the array for the second fetch call is missing the first record in the results set. The code is listed below. If I comment out the first fetch call in the Dreamweaver MX recordset block ($row_rsCommunitiesServed = mysql_fetch_assoc($rsCommunitiesServed);), it works fine. However, I need to leave it unaltered. How can I solve this problem without altering the Dreamweaver MX recordset block?
Thank you, Blaine
// This page displays a list of cites from a database table with a link in two columns in a table.
<?php require_once('Connections/connDatabase.php'); ?>
<?php
// Begin Macromedia PHP/MySQL recordset
// Cannot be altered
mysql_select_db($database_connDatabase, $connDatabase);
$query_rsCommunitiesServed = "SELECT city.ServiceType, city.CityID, city.City FROM city";
$rsCommunitiesServed = mysql_query($query_rsCommunitiesServed, $connDatabase) or die(mysql_error());
$row_rsCommunitiesServed = mysql_fetch_assoc($rsCommunitiesServed);
$totalRows_rsCommunitiesServed = mysql_num_rows($rsCommunitiesServed);
// End Macromedia PHP/MySQL recordset
// Creat Columns for Cities
// Set number of rows
$columns = 2;
//Set variable $rows
$rows = ceil($totalRows_rsCommunitiesServed / $columns);
// Loop to populate array
while($row = mysql_fetch_array($rsCommunitiesServed)) {
$servicetype[] = $row['ServiceType'];
$cityid[] = $row['CityID'];
$city[] = $row['City'];
}
?>
<html>
<head>
<title>Untitled Document</title>
</head>
<body>
<?php echo "<TABLE class=\"normal\" BORDER=\"0\">\n";
// Set condition to $i < $rows
for($i = 0; $i < $rows; $i++) {
echo "<TR>\n";
// Run loop for the number of columns
for($j = 0; $j < $columns; $j++) {
if(isset($cityid[$i + ($j * $rows)])) {
echo "<TD><a href=\"" . $servicetype[$i + ($j * $rows)]. ".php?cityid=" . $cityid[$i + ($j * $rows)] . "\">" . $city[$i + ($j * $rows)] . "</a></TD>\n";
}
}
echo "</TR>\n";
}
echo "</TABLE>\n";
?>
</body>
</html>
<?php
mysql_free_result($rsCommunitiesServed);
?>
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php