更改mysql查询中的列宽

时间:2010-05-24 22:57:36

标签: php mysql database

<?php

// Connection Database
$search = $_POST ['Search'];

mysql_connect("xxxxxx", "xxxxxxxxx", "xxxxxx") or die ("Error     Connecting to Database");
      mysql_select_db("xxxxxx") or die('Error');
     $data = mysql_query("SELECT* FROM course WHERE MATCH (CourseName, CourseDescription,   CourseLeader) AGAINST ('". $search ."')")
      or die (mysql_error());
Print "<table border cellpadding=3>";
while($info = mysql_fetch_array( $data ))
{
Print "<tr>";
Print "<th>Course Name:</th> <td>".$info['CourseName'] . "</td> ";
Print "<th>Course Description:</th><td>".$info['CourseDescription'] . "</td> ";
Print "<th>Course Leader:</th><td>".$info['CourseLeader'] . " </td></tr>";

}
Print "</table>";

?>

在我的php代码中,我在搜索后打印了CourseName,CourseDescription,CourseLeader列作为结果集。 CourseDescription有很多文字,我该如何打印?有没有办法改变列宽?

1 个答案:

答案 0 :(得分:0)

使用

中的宽度参数进行调整
<th width="25%">

OR

<th width="400px">

您的代码应该类似于

Print "<tr>";
Print "<th width='20%'>Course Name:</th> <td width='80%'>".$info['CourseName'] . "</td> ";
Print "<th width='20%'>Course Description:</th><td width='80%'>".$info['CourseDescription'] . "</td> ";
Print "<th width='20%'>Course Leader:</th><td width='80%'>".$info['CourseLeader'] . " </td></tr>";