首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在日期更改时有日期标题和断线。

在日期更改时有日期标题和断线。
EN

Stack Overflow用户
提问于 2017-02-26 20:55:26
回答 1查看 47关注 0票数 0

我有三个领域。身份证,文章链接地址和日期。这些链接目前正按日期水平填充该页。例如,我有6个链接用于2/26/2017,6个链接用于2/25/2017。我想知道是否有可能添加,当日期改变,日期将在每列的底部,然后有一个水平的断线。然后,它会转到第二天在数据库中。这是我想要的格式。

代码语言:javascript
复制
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
____________________________________________________________________________
代码语言:javascript
复制
<?php
$con = mysql_connect("localhost", "*****", "*****") or
die("Could not connect: " . mysql_error());
mysql_select_db("*****");
$result = mysql_query("select Article from crypto");
// set up loop counter 
$col_count = 0; 

// start table and first tr 
echo '<table border="0" style="width: 100%; table-layout: fixed;"><tr>'; 

while ($row=mysql_fetch_array($result)) { 
   // 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 
   echo '<td>' . $row['Article'] . '</td>'; 
  // and count the column 
  $col_count++; 
} 

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

mysql_close($con);
?>
EN

回答 1

Stack Overflow用户

发布于 2017-02-26 22:51:57

我相信这就是你要找的东西,我用你的mysql_connect代替了一个简单的数组,如果你想看到这里的代码,它是://$ar = array("Link1","Link2","Link3","Link4","Link5","Link6","02/25/17"); //$arz = array("Link1","Link2","Link3","Link4","Link5","Link6","02/26/17");

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

代码语言:javascript
复制
<?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>';
?>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42474162

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档