This is a discussion on can only loop through one time with mssql_fetch_array($result)) !!! within the PHP General forums, part of the PHP Programming Forums category; $query = mssql_init("mt_selectChurchesByCityNameUsa", $s); mssql_bind($query, "@city", &$searchString, SQLVARCHAR); mssql_bind($query, "@state", &$...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
$query = mssql_init("mt_selectChurchesByCityNameUsa", $s);
mssql_bind($query, "@city", &$searchString, SQLVARCHAR); mssql_bind($query, "@state", &$state, SQLVARCHAR); mssql_bind($query, "@country", &$country, SQLVARCHAR); $result = mssql_execute($query); while($row = mssql_fetch_array($result)) { $Id = $row["Id"]; $ChurchId = $row["ChurchId"]; $Country = $row["Country"]; $Diocese = $row["Diocese"]; echo("<h3>first loop$Id</h3>"); } while($row2 = mssql_fetch_array($result)) { $Id2 = $row2["Id"]; $ChurchId2 = $row2["ChurchId"]; $Country2 = $row2["Country"]; $Diocese2 = $row2["Diocese"]; echo("<h3>second loop $Id2 </h3>"); } no matter how I do it I can only loop through $result ONE TIME. The first time it loops through perfectly, the second time it appears that $result is empty. So I changed the code to $query = mssql_init("mt_selectChurchesByCityNameUsa", $s); mssql_bind($query, "@city", &$searchString, SQLVARCHAR); mssql_bind($query, "@state", &$state, SQLVARCHAR); mssql_bind($query, "@country", &$country, SQLVARCHAR); $result = mssql_execute($query); result2 = $result; while($row = mssql_fetch_array($result)) { $Id = $row["Id"]; $ChurchId = $row["ChurchId"]; $Country = $row["Country"]; $Diocese = $row["Diocese"]; echo("<h3>first loop$Id</h3>"); } while($row2 = mssql_fetch_array($result2)) { $Id2 = $row2["Id"]; $ChurchId2 = $row2["ChurchId"]; $Country2 = $row2["Country"]; $Diocese2 = $row2["Diocese"]; echo("<h3>second loop $Id2 </h3>"); } STRANGELY $result2 is empty and so it never echo's the second loop!!!! ARGHHH. Any ideas? |