0

我有它显示来自 MySQL 数据库的记录。目前我将它设置为一个表格,其中一个重复区域总共显示了 6 个条目。

我希望将其重复到右侧,制作两列,即左侧一张表显示记录 1 ~ 6,右侧一张表显示记录 7 ~ 12。我非常重视你能提供的任何帮助...谢谢你

我的 HTML 是:

<table width="600" border="0">
  <?php do { ?>
  <tr>
    <td><?php echo $row_glossary_main['term']; ?>:</td>
    <td><?php echo $row_glossary_main['definition']; ?></td>
  </tr>
  <?php } while ($row_glossary_main = mysql_fetch_assoc($glossary_main)); ?>
</table>

该页面的php是:

<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$maxRows_glossary_main = 6;
$pageNum_glossary_main = 0;
if (isset($_GET['pageNum_glossary_main'])) {
  $pageNum_glossary_main = $_GET['pageNum_glossary_main'];
}
$startRow_glossary_main = $pageNum_glossary_main * $maxRows_glossary_main;

mysql_select_db($database_ships, $ships);
$query_glossary_main = "SELECT * FROM glossary_main ORDER BY term ASC";
$query_limit_glossary_main = sprintf("%s LIMIT %d, %d", $query_glossary_main, $startRow_glossary_main, $maxRows_glossary_main);
$glossary_main = mysql_query($query_limit_glossary_main, $ships) or die(mysql_error());
$row_glossary_main = mysql_fetch_assoc($glossary_main);

if (isset($_GET['totalRows_glossary_main'])) {
  $totalRows_glossary_main = $_GET['totalRows_glossary_main'];
} else {
  $all_glossary_main = mysql_query($query_glossary_main);
  $totalRows_glossary_main = mysql_num_rows($all_glossary_main);
}
$totalPages_glossary_main = ceil($totalRows_glossary_main/$maxRows_glossary_main)-1;
?>
4

1 回答 1

1

将所有结果放入数组中

$resultrow=array();
while ($row_glossary_main = mysql_fetch_assoc($glossary_main))
  {$resultrow=$row_glossary_main; }

计算数组 $resultrow 的总数

那么你必须在哪里输出

$count=count($resultrow)/2;
  for($i=0;$i<$count;$i++)
     {
       <td>$resultrow[$i]</td><td>$resultrow[$count*2-1]</td> 
     }
于 2013-07-07T19:07:12.730 回答