Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何添加</tr>&书信电报;tr>;每2分钟后自动执行一次<;td>;_Php_Mysql - Fatal编程技术网

Php 如何添加</tr>&书信电报;tr>;每2分钟后自动执行一次<;td>;

Php 如何添加</tr>&书信电报;tr>;每2分钟后自动执行一次<;td>;,php,mysql,Php,Mysql,我正在使用基于用户搜索的PHP从MySQL检索结果 我想在结果中每隔2秒自动添加一个 <?php include_once("config.php"); isset( $_REQUEST['name'] ) ? $name=$_REQUEST['name'] : $name=''; $name = mysql_real_escape_string( $name ); if (strlen($name) >= 4) { $sql = "select * from place

我正在使用基于用户搜索的PHP从MySQL检索结果

我想在结果中每隔2秒自动添加一个

<?php
include_once("config.php");
isset( $_REQUEST['name'] ) ? $name=$_REQUEST['name'] : $name='';
$name = mysql_real_escape_string( $name );
if (strlen($name) >= 4) {

     $sql = "select * from places where speciality like '%$name%'";

     $rs = mysql_query( $sql ) or die('Database Error: ' . mysql_error
    $num = mysql_num_rows( $rs );

    if($num >= 1 ){     
        echo "<table id='result-table'><tr>";           
while($row = mysql_fetch_array( $rs )){

    echo "<td>row[cname]</td>"; //here i want to add </tr><tr> after 2 <td>s

 }

    }else{
        echo "no records found</table>";
    }
}
?>
echo”“;
$currentCount=-1;
while($row=mysql\u fetch\u数组($rs))
{
回显“行[cname]”;
$currentCount=($currentCount+1)%2;
如果($currentCount==1)
{
回声';
}
}
echo”“;
$currentCount=-1;
while($row=mysql\u fetch\u数组($rs))
{
回显“行[cname]”;
$currentCount=($currentCount+1)%2;
如果($currentCount==1)
{
回声';
}
}

使用的
$i=1
如果($i%2==0)
$i++

<?php 
include_once ("config.php");
isset ($_REQUEST['name']) ? $name = $_REQUEST['name'] : $name = '';
$name = mysql_real_escape_string($name);
if (strlen($name) >= 4) {
  $sql = "select * from places where speciality like '%$name%'";
  $rs = mysql_query($sql) or die('Database Error: '.mysql_error $num = mysql_num_rows($rs);
  if ($num >= 1) {
    $i = 1;
    echo "<table id='result-table'><tr>";
    while ($row = mysql_fetch_array($rs)) {
      echo "<td>row[cname]</td>"; //here i want to add </tr><tr> after 2 <td>s
      if ($i % 2 == 0)
        echo "</tr><tr>";
      $i++;
    }
  }
  else {
    echo "no records found</table>";
  }
}
?>

使用的
$i=1
如果($i%2==0)
$i++

<?php 
include_once ("config.php");
isset ($_REQUEST['name']) ? $name = $_REQUEST['name'] : $name = '';
$name = mysql_real_escape_string($name);
if (strlen($name) >= 4) {
  $sql = "select * from places where speciality like '%$name%'";
  $rs = mysql_query($sql) or die('Database Error: '.mysql_error $num = mysql_num_rows($rs);
  if ($num >= 1) {
    $i = 1;
    echo "<table id='result-table'><tr>";
    while ($row = mysql_fetch_array($rs)) {
      echo "<td>row[cname]</td>"; //here i want to add </tr><tr> after 2 <td>s
      if ($i % 2 == 0)
        echo "</tr><tr>";
      $i++;
    }
  }
  else {
    echo "no records found</table>";
  }
}
?>

我建议根本不要把它们放在表格中;相反,只需将它们放入
元素中,使用
float:left
width:50%
样式

如果必须将它们放入一个表中,并且希望按照要求的方式进行操作,则可以使用PHP的模运算符(
%
)将当前记录编号除以2,然后得到余数。如果为1,则添加
标记:

if(++$rowNum % 2) {print "</tr><tr>";}
if(++$rowNum%2){print”“;}

我建议不要把它们放在桌子上;相反,只需将它们放入
元素中,使用
float:left
width:50%
样式

如果必须将它们放入一个表中,并且希望按照要求的方式进行操作,则可以使用PHP的模运算符(
%
)将当前记录编号除以2,然后得到余数。如果为1,则添加
标记:

if(++$rowNum % 2) {print "</tr><tr>";}
if(++$rowNum%2){print”“;}

的可能重复和许多其他的可能重复和许多others@AdamTester字体当然不是,这真的不是小报。或者,如果是这样的话,他不是要求把它像小报上的数据一样摆出来;这只是一个匹配名字的列表。他希望它分为两列,但这并不能改变它基本上只是一个一维数据集的事实。@Adamtest:当然不,这真的不是小报。或者,如果是这样的话,他不是要求把它像小报上的数据一样摆出来;这只是一个匹配名字的列表。他希望它分为两列,但这并不能改变它基本上只是一个一维数据集的事实。