Mombu the Php Forum sponsored links

Go Back   Mombu the Php Forum > Php > mssql_fetch_array question
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 26th April 19:00
merrittr
External User
 
Posts: 1
Default mssql_fetch_array question



I was wondering if when I am using mssql_fetch_array if even though I
am stepping through '
the array using index numbers is there a way to also get the field
name (IE the associative array key)
IE

$row = mssql_fetch_array($result)
echo $row[1] ;
echo $row[1]['filedname']; <-this would be the actual sql field name?

$link = mssql_connect("sql.site.com:9999/Engineering", "username",
"password");
mssql_select_db('beaver_research', $link) or die ('Could not
select to beaver_college database');

$sql="SELECT * from person order by personid";


$result = mssql_query($sql, $link);
//$rows = mssql_fetch_array($result);
foreach ($rows as $row_num => $row)
{
echo $row."<br>\n";
}

echo "<person>";
while($row = mssql_fetch_array($result))
{
//echo("$row[0]<br>");
for ( $counter = 0; $counter <= 9; $counter += 1)
{
echo "<".$row[$counter]['name'].">".$row[$counter]."</".$row[$counter]
['name'].">\n";
if ($row[$counter]=='') echo ".";
}
echo "</person>";
  Reply With Quote


  sponsored links


2 26th April 22:07
mrclay
External User
 
Posts: 1
Default mssql_fetch_array question



Use mssql_fetch_assoc instead then step through the row with foreach.
Steve
  Reply With Quote
Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666