can only loop through one time with mssql_fetch_array($result)) !!!

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", &$...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-22-2004
Thomas Miller
 
Posts: n/a
Default can only loop through one time with mssql_fetch_array($result)) !!!

$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?
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 06:13 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0