将表格除以结果

时间:2013-03-20 06:13:43

标签: html

我有一个查询,用于选择表格中的名称 我想把结果分成每个表数据15个名字 接下来的15个名字可能会显示在下一个表数据中吗?如何?

 <?php
    extract($_POST);
    if($_POST['filter1'] == "Individual"){
    if(isset($submitsearch)){
        //if(!empty($searchquery)){
        $sql    = "SELECT * FROM contact_individual WHERE name LIKE '%$searchquery%' ORDER BY name";
        $query  = mysql_query($sql);
        $count  = mysql_num_rows($query);

            for($x=0;$x<$count;$x++){
                $data   = mysql_fetch_array($query);
?>
<table class="tsearch">
    <tr>
        <td>
            <form method="GET" action="resultindividualprofile.php">
                <input type="text" name="text" hidden="hide" value="<?echo $data['contactID_individual'];?>"/>
                <input type="submit" class="rep" name="this" value="<?echo $data['name'];?>"/>
                <!--<a href="?view=<?php //echo $data['contactID_individual']; ?>"><?php //echo $data['name']; ?></a>-->
            </form>
        </td>
    </tr>
</table>

编辑:

enter image description here

1 个答案:

答案 0 :(得分:0)

这样做:

<?php 
if($_POST['filter1'] == "Individual"){
    $sql    = "SELECT * FROM contact_individual WHERE name LIKE '%".$searchquery."%' ORDER BY name";
    $query  = mysql_query($sql) or die(mysql_error());
    $count  = mysql_num_rows($query);
?>
<table class="tsearch">
<?php 
$x=0;
while($data = mysql_fetch_array($query))
{     
    if($x > 0 && $x%15==0)
    {
       echo '</table><table class="tsearch">';
    }       
?>

<tr>
    <td>
        <form method="GET" action="resultindividualprofile.php">
            <input type="text" name="text" hidden="hide" value="<?echo $data['contactID_individual'];?>"/>
            <input type="submit" class="rep" name="this" value="<?echo $data['name'];?>"/>
            <!--<a href="?view=<?php //echo $data['contactID_individual']; ?>"><?php     //echo $data['name']; ?></a>-->
        </form>
    </td>
</tr>
<?php $x++; } ?>
</table>
<?php } ?>