php - How to style data from mysql database? -


i got php code display comments database:

<?php   $con = mysql_connect("localhost","root","");   if (!$con){     die("cannot connect: " . mysql_error());   }    mysql_select_db("strek", $con);    $sql="select * comments";     $result=mysql_query($sql, $con);    while($row=mysql_fetch_array($result)){     $name=$row['name'];     $comment=$row['comment'];     echo $name. "<br>" .$comment;     echo"<br>";   } ?> 

i'd both name , comment aligned in center , i'd name bold. please me how that.

"i'd both name , comment aligned in center , i'd name bold. please me how that."

since op has double quotes in echo $name. "<br>" .$comment; in think working , needs have centered , in bold, use of code below valid.

consider following:

echo "<div align='center'><b>" . $name. "<br>" .$comment . "</b></div>"; 

a working example:

<?php  $name = "john";  $comment = "this comment";  echo "<div align='center'><b>" . $name. "<br>" .$comment . "</b></div>";  ?> 

you make use of stylesheet either div id, and/or class.

for example:

echo "<div align='center' id='names_comments' class='centered bold_text'>" . $name. "<br>" .$comment . "</div>"; 

then using css:

#names_comments { font-family:georgia; font-size:12pt; }  .centered bold_text { text-align:center; font-weight:bold; } 

note: align='center' omitted, won't hurt keep it.


Comments

Popular posts from this blog

design - Custom Styling Qt Quick Controls -

Unable to remove the www from url on https using .htaccess -