Php 有日期标题,并在变更日期处换行

Php 有日期标题,并在变更日期处换行,php,html,Php,Html,我有三个领域。id、文章链接地址和日期。链接当前按日期水平填充页面。例如,2017年2月26日我有6个链接,2017年2月25日我有6个链接。我想知道是否可以补充一点,当日期发生变化时,日期会出现在每列的底部,然后有一条水平分隔线。然后,它将转到数据库中的第二天。这是我想要的格式 Link1............................Link2...............................Link3 Link4............................L

我有三个领域。id、文章链接地址和日期。链接当前按日期水平填充页面。例如,2017年2月26日我有6个链接,2017年2月25日我有6个链接。我想知道是否可以补充一点,当日期发生变化时,日期会出现在每列的底部,然后有一条水平分隔线。然后,它将转到数据库中的第二天。这是我想要的格式

Link1............................Link2...............................Link3
Link4............................Link5...............................Link6
2/25/2017......................2/25/2017...........................2/25/2017
____________________________________________________________________________
Link7............................Link8...............................Link9
Link10...........................Link11..............................Link12
2/26/2017......................2/26/2017...........................2/26/2017
____________________________________________________________________________


我相信这就是您要找的,如果您想在这里看到代码,我确实用您的
mysql\u connect
替换了一个简单的数组:
/$ar=数组(“Link1”、“Link2”、“Link3”、“Link4”、“Link5”、“Link6”、“02/25/17”)
/$arz=数组(“Link1”、“Link2”、“Link3”、“Link4”、“Link5”、“Link6”、“02/26/17”)

这应该显示一种通过匹配sql数组日期部分中的
/
来获得所需结果的方法:

<?PHP
$con = mysql_connect("localhost", "*****", "*****") or
die("Could not connect: " . mysql_error());
mysql_select_db("*****");
$result = mysql_query("select Article from crypto");
$col_count = 0; 

// start table and first tr 
echo '<table border="0" style="width: 100%; table-layout: fixed;"><tr>'; 
$row=mysql_fetch_array($result);
foreach($row as $rows) { 
   // if you have output 3 cols then end tr and start a new one 
   if ($col_count == 3) { 
      echo '</tr><tr>'; 
      //  and reset the col count 
      $col_count = 0; 
   } 
   // always output the td 
   if(preg_match("/\//", $rows, $b)) echo '<td>' . $rows . '</td><td>' . $rows . '</td><td>' . $rows . '</td></tr><tr><td colspan=\'3\'><hr>&nbsp;</td></tr>'; 
   else echo '<td>' . $rows . '</td>';
  // and count the column
  //echo '</tr>';
  $col_count++; 
}

// then close off the last row and the table 
echo '</tr></table>';
?>

这个问题有多个问题。问题还不清楚。您正在使用mysql。您只查询
文章
,但询问ID、链接和日期。请做一个问题编辑。另外,请阅读以下内容:我澄清了这篇文章是链接地址,我确实希望答案中包含日期。不确定“多个问题”是什么意思?您的查询在结果集中每行只收集一列,但您希望处理三列。我可能误解了你的问题,但那是因为它写得太差了。你的代码基本上需要完全重写,问题可能会被标记为太宽/不清楚/无法解决。我有1个文章链接字段,我将结果分布在3个栏中,这已经很好地工作了。我只是想问,是否有一种方法可以用一条虚线将结果按日期分开,并在虚线上方列出该日期。这一点很难解释。如果你不明白我在说什么,你可以看到我在手动硬编码的地方寻找的结果,或者你可以看看我在ThanksHey对mysql数据库做了什么,谢谢。我可能完全误解了你的代码,但我肯定需要它从mysql数据库工作,我不想硬代码的日期或任何链接。我希望所有这些都能通过将信息输入数据库来完成。这就是从数据库中显示的。。。您可以将
foreach($rows作为$rows){
更改为
while($row=mysql\u fetch\u数组($result)){
,但是
if(preg\u-match($rows,$rows,$b))
更改为
if(preg\u-match(“/\/\/”,$row['Article'],$b))
并将每个
$rows
更改为
$row['Article']
您能解释一下这些更改会起什么作用吗?很抱歉我不太了解。
<?PHP
$con = mysql_connect("localhost", "*****", "*****") or
die("Could not connect: " . mysql_error());
mysql_select_db("*****");
$result = mysql_query("select Article from crypto");
$col_count = 0; 

// start table and first tr 
echo '<table border="0" style="width: 100%; table-layout: fixed;"><tr>'; 
$row=mysql_fetch_array($result);
foreach($row as $rows) { 
   // if you have output 3 cols then end tr and start a new one 
   if ($col_count == 3) { 
      echo '</tr><tr>'; 
      //  and reset the col count 
      $col_count = 0; 
   } 
   // always output the td 
   if(preg_match("/\//", $rows, $b)) echo '<td>' . $rows . '</td><td>' . $rows . '</td><td>' . $rows . '</td></tr><tr><td colspan=\'3\'><hr>&nbsp;</td></tr>'; 
   else echo '<td>' . $rows . '</td>';
  // and count the column
  //echo '</tr>';
  $col_count++; 
}

// then close off the last row and the table 
echo '</tr></table>';
?>