简体   繁体   中英

Displaying the result of an SQL query in an HTML table

I'm stuck for a while, I try to display the result of a variable that executes a sql query in an html table, here is my code;

$REQUT = Doctrine_Query::create()
->select('DISTINCT r.prod , r.di, COUNT(*) as Result')
->from('tabl r')
->groupBy('r.di')
->orderBy('Result ASC') ;

$REQUT->fetchArray();

PS : I work in symfony, I am looking to have a view like mysql

You need to loop through the result set. I don't know this particular API, but assuming it works similarly to others:

$REQUT = // all that query stuff
while($ROW = $REQUT->fetchArray()) {
    // do something
    var_dump($ROW);
}

You can try this to display as a html table...

 $REQUT = Doctrine_Query::create()
->select('DISTINCT r.prod , r.di, COUNT(*) as Result')
->from('tabl r')
->groupBy('r.di')
->orderBy('Result ASC') ;

echo "<table>";
while($ROW = $REQUT->fetchArray()) 
{

echo "<tr><td>".$ROW["prod"]."<td>";
echo "<td>".$ROW["di"]."<td></tr>";
}
echo "</table>";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM