我怎么能改变PHP里面的字体大小

时间:2016-03-27 17:33:02

标签: php html css

我有这个代码,但是如何将图片放在中心,如何更改字体的大小以及如何将其放在中心。 如果HTML标签不在PHP标签内,但在此代码中PHP内的HTML标签,我知道如何通过CSS来实现。

<html>
<head>
<title> page 1</title>
<body>
<?php
session_start();
$get_id= $_GET['id'];
$get_pass = $_GET['pass'];
$name = "";
$_SESSION['user_id']=$get_id;
$_SESSION['user_pass']=$get_pass;
$con = mysqli_connect('localhost', 'root', '');
if(!$con)
{
    die("not ok");
}

mysqli_select_db($con,"uoh");  
$q = " SELECT * FROM student WHERE id = " . $get_id ." and password = " . $get_pass;
$result = mysqli_query($con , $q ) ;
if($row = mysqli_fetch_array($result))
{
    if ($row["major"]=="computer engineerig")
    {
   echo "welcome ". $row["name"];
   echo " and your id is ".$row["id"];
   echo " and your major ".$row["major"];
   echo "<br />";
   echo '<a href="tran.php?page=A"><img src="tran.png"/></a>';
   echo '<a href="course_list.php?page=A"><img src="courselist.png"/></a>';
   echo '<a href="comp.php?page=A"><img src="comp.png"/></a>';
   }

   elseif ($row["major"]=="software engineerig")
   {
   echo "welcome ". $row["name"];
   echo " and your id is ".$row["id"];
   echo " and your major ".$row["major"];
   echo '<p>academic transcript <a href="tran.php?page=B">here</a></p>';
   echo '<p>courses list<a href="course_list.php?page=B">here</a></p>'; 
   echo '<p>student compliance <a href="comp.php?page=B">here</a></p>';
   }
   else
   echo "your ID not found";
}
?>
</body>
</html>

1 个答案:

答案 0 :(得分:0)

有几种方法可以做到这一点。 为简单起见,您可以使用<style>标记。

对齐图像:

echo '<p style="text-align:center"><a href="tran.php?page=A"><img src="tran.png"/></a></p>';

减少字体大小并居中对齐文字:

echo '<p style="font-size:10px;text-align:center">academic transcript <a href="tran.php?page=B">here</a></p>';