使用PHP使用MySQL数据填充HTML表

时间:2012-04-22 22:57:28

标签: php mysql html css

我正在尝试使用MySQL数据填充HTML表格,但是我在第128行(即在$row['location']的行之后)收到的错误是:T_CONSTANT_ENCAPSED_STRING。我用Google搜索过,但我无法真正理解这意味着什么或我可能出错的地方。任何帮助都会非常赞赏。谢谢:))

echo "<table id='row1_border'>";
                    while($row = mysql_fetch_array($result)) ;
                    {
                    echo "<tbody>";
                        echo "<tr class='job_listing'>";
                            echo "<td class='job'>";
                                echo "<div class='company_image'></div>";

                                echo "<div class='job_title'>";
                                    echo "<span class='job_title_style'></span>";
                                echo "</div>";
                                echo "<div class='company_name'>";
                                    echo "<span class='company_name_style'>Akin, Gump, and Smith</span>";
                                echo "</div>";
                                echo "<div class='company_tagline'>";
                                    echo "<span class='company_tagline_style'>This is just a test.</span>";
                                echo "</div>";
                            echo "</td>";
                            echo "<td class='location'>";
                                echo "<div class='location_div'>";
                                    echo "<span class='location_style'>";
                                        $row['location']

                                "</span>";
                                echo "</div>";
                            echo "</td>";
                            echo "<td class='job_type'>";
                                echo "<div class='job_type_div'>";
                                    echo "<span class='job_type_style'>";

                                        echo .$row['job_type'].
                                    "</span>";
                                echo "</div>";
                            echo "</td>";
                        echo "</tr>";
                    echo "</tbody>";
                    }
                echo "</table>"

                ?>

4 个答案:

答案 0 :(得分:1)

在相关行之前没有回声,请尝试:

echo $ row ['location'];

此后的线路也没有正确回显。

确保你回应每一行。

答案 1 :(得分:0)

这是因为你需要分号。

我建议你以后阅读错误。

答案 2 :(得分:0)

试试这个

echo "<td class='location'>";
     echo "<div class='location_div'>";
         echo "<span class='location_style'>".$row['location']."</span>";                   
     echo "</div>";
 echo "</td>";
 echo "<td class='job_type'>";
     echo "<div class='job_type_div'>";
         echo "<span class='job_type_style'>".$row['job_type']."</span>";
     echo "</div>";
 echo "</td>";

答案 3 :(得分:0)

祝你好运

<table><tbody>
<?php while($row = mysql_fetch_array($result)) { ?>
                    <tr class='job_listing'>
                        <td class='job'>
                            <div class='company_image'></div>

                            <div class='job_title'>
                                <span class='job_title_style'></span>
                            </div>
                            <div class='company_name'>
                                <span class='company_name_style'>Akin, Gump, and Smith</span>
                            </div>
                            <div class='company_tagline'>
                                <span class='company_tagline_style'>This is just a test.</span>
                            </div>
                        </td>
                        <td class='location'>
                            <div class='location_div'>
                                <span class='location_style'>
                                   <?php  echo $row['location']; ?>

                            </span>
                            </div>
                        </td>
                        <td class='job_type'>
                            <div class='job_type_div'>
                                <span class='job_type_style'>

                                    <?php  $row['job_type']; ?>
                                </span>
                            </div>
                        </td>
                    </tr>
                    <?php } ?>
                </tbody>
            </table>