开发者

NICE DISPLAY in PHP + MYSQL

i want to know how seperate each line of what i make appear on the screen.

I try <br> \t (spacebar) but it wont work. it appears like that Ex:

USER PASSWD 
aUser aPasswd

i want it appears like that:

USER         PASSWD
aUser        aPasswd

More clear, no?! :D

here is my code $tab is the title : USER PASSWD

 function db_select($prep, $username, $tab){        
      error_reporting(-1);  //Activer le rapport de toutes les genres d'erreurs
      $querycon = "SELECT $prep FROM info_compte WHERE username = '$username'";
     if(!$response = mysql_query($querycon)){
        echo "Il n\'y a aucun $username dans la base de données";
    }
     else{
            echo $tab.'<br>';
            while ($row = mysql_fetch_array($response, MYSQL_AS开发者_如何学CSOC))
                foreach($row as $item)
                {
                    echo $item.' ';
                }
        }
    return $response;   
}//db_select


Wrap your output in <pre> tags:

echo "<pre>\n";
while ($row = mysql_fetch_array($response, MYSQL_ASSOC)) {
 foreach($row as $item) {
   echo "$item\t";
 }
 echo "<br>\n";
}
echo "</pre>\n";


I would put it into a table

<table>  
<tr><td>Username</td><td>Passwd</td></tr>
<tr><td><?php echo $username ?></td><td><?php echo $passwd ?></td></tr>
</table>

This way it will have equal spacing, and you can adjust the width of the cell

UPDATE (assuming your pulling both username and password):

echo "<table>";  
echo "<tr><td>Username</td><td>Passwd</td></tr>";
foreach($row as $key => $value) {
                    echo "<tr><td>".$key.'</td><td>'.$value.'</td></tr>';
}
echo "</table>";
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜