在行上串联数据库值

时间:2018-11-20 02:12:51

标签: php rows concat

我想将此数据库值连接成一行,但我没有这样做。有人可以帮我解决这个问题吗?非常感谢!

         <tr>
            <td><?php echo $i;$i++; ?></td>
            <td><?php print($row['vfname'. " " & 'vmname' & " " & 'vlname']); ?></td>
            <td><?php print($row['vage']); ?></td>
            <td><?php print($row['vprecinct']); ?></td>
            <td><?php print($row['vworkstat']); ?></td>
            <td><?php print($row['vleaders']); ?></td>
            <td><?php print($row['vclass']); ?></td>
            <td><?php print($row['vaddress']); ?></td>
            <td><?php print($row['vcontact']); ?></td>
            <td><?php print($row['vdatereg']); ?></td>    
            </tr>

1 个答案:

答案 0 :(得分:1)

完成。我将其合并到sql语句中,希望这对任何人都可以帮助

$tablecontent = '';
                                    $start = '';
                                    $selectStmt = $con->prepare("SELECT vaddress, Concat(vfname, ' ', vmname, ' ', vlname) AS Name, vage, vcontact, vworkstat, vclass, vprecinct, vleaders, vdatereg FROM votersinfotbl ORDER BY vaddress ASC");
                                    $selectStmt->execute();
                                    $votersinfotbl = $selectStmt->fetchAll();