I have a sp in mssql which gives multiple resultsets.I need to display the result in html table using php .
I am using mssql_fetch_assoc() & mssql_next_result().
How to store each resultset in a array and retrieve it.
$result=student_sp('1231','1')
do
curlybrace
while($row=mssql_fetch_assoc($result))
brace
$name=$row[name];
$age=$row[age];
$marks=$row[marks];
$term=$row[terms];
$Subject=$row[sub];
$html="<table><tr><td>$name</td></tr><tr><td>$age</td></tr></table>"
$mark="<table><tr><td>$subject</td></tr><tr><td>$marks</td></tr></table
brace
bracewhile(mssql_next_result($result));
echo $html;
echo $mark
I need to display the name & age below name & age the marks for each terms should be displayed.
The issue is
SP will return 2 resultset
1st resultset : name & age(1 row)
2nd resultset: subject,marks and terms(Multiple rows);

Now for the above code it should print the name & age one time and the marks(Multiple rows) below it .But it is printing the name& age and empty tables for (multiple row as in second resultset) and then the second resultset
How to handle this looping.

Recommended Answers

All 2 Replies

How about you repost your code as a proper code block?

$result=sp_multiset('123');
do
{
while($row=mssql_fetch_assoc($result))
{
$name=$row[name];
$age=$row[age];
$marks=$row[marks];
$term=$row[terms];
$Subject=$row[sub];
$html="<table><tr><td>$name</td></tr><tr><td>$age</td></tr></table>"
$mark="<table><tr><td>$subject</td></tr><tr><td>$marks</td></tr></table>
}
}while(mssql_next_result($result));

echo $html;
echo $mark
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.