Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/269.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/67.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显示/隐藏链接_Php_Mysql - Fatal编程技术网

PHP显示/隐藏链接

PHP显示/隐藏链接,php,mysql,Php,Mysql,我有一个从我的数据库打印文章的功能,还有编辑、添加、显示/隐藏三个链接。 在show/hide链接中,我希望能够隐藏/显示特定的文章。 我该怎么做? 编辑:我需要能够隐藏/显示我的后端页面的文章,它需要保持在前端页面隐藏 function displaynews() { $data = mysql_query("SELECT * FROM news") // query or die(mysql_error()); while ($info = mysql_fet

我有一个从我的数据库打印文章的功能,还有编辑、添加、显示/隐藏三个链接。 在show/hide链接中,我希望能够隐藏/显示特定的文章。 我该怎么做? 编辑:我需要能够隐藏/显示我的后端页面的文章,它需要保持在前端页面隐藏

function displaynews()
{
    $data = mysql_query("SELECT * FROM news")  // query
    or die(mysql_error());   
    while ($info = mysql_fetch_array($data)) 
    {
        $id = $info['id']; 
        echo "<br>
              <a href=Edit.php?id=$id>Edit</a></a>
              <a href='addnews.php'> Add </a>
              <a href='#'>Show/Hide</a><br><strong>" .
              $info['date'] .
              "</strong><br>" . 
              $info['news_content'] . 
              "<hr><br>"; // Print Articles and Date
    }
}

您可以使用一些Javascript并将style属性设置为display:none以隐藏,然后display:block以再次显示它。或者使用jQuery。

您可以使用一些Javascript并将style属性设置为display:none以隐藏,然后display:block以再次显示它。或者使用jQuery。

使用jQuery

<head>
 <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>
</head>

<a href='#' onclick="$('#whatever').toggle();return false;">show/hide</a>
<div id="whatever">
  Content
</div>
<script>
 //Try these too
$('#whatever').hide();
$('#whatever').show();
$('#whatever').toggle();
</script>
使用jquery

<head>
 <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>
</head>

<a href='#' onclick="$('#whatever').toggle();return false;">show/hide</a>
<div id="whatever">
  Content
</div>
<script>
 //Try these too
$('#whatever').hide();
$('#whatever').show();
$('#whatever').toggle();
</script>
使用以下代码:

PHP代码:

Javascript/jQuery代码别忘了在页面中添加jQuery

<script type="text/javascript">
$(document).ready(function(){
 $(".news").click(function(){
  $(this).toggle();
});
});
</script>
使用以下代码:

PHP代码:

Javascript/jQuery代码别忘了在页面中添加jQuery

<script type="text/javascript">
$(document).ready(function(){
 $(".news").click(function(){
  $(this).toggle();
});
});
</script>

像这样使用jquery:$'.something'.hide;一定要提高投票率或标出最能解决你问题的答案;像这样使用jquery:$'.something'.hide;一定要提高投票率或标出最能解决你问题的答案;我假设我必须把所有的文章都放在div标签中,或者你可以把那一行放在span标签中,引用它的ID,做同样的事情。不管你走哪条路。。将display设置为none或block是一种方法。我假设我必须将所有文章放在div标记中?或者您可以将该特定行放在span标记中,并引用其ID,然后执行相同的操作。不管你走哪条路。。将“显示”设置为“无”或“阻止”是执行此操作的方法。如果在后端页面中执行此操作,文章是否会在前端页面中保持隐藏?如果在后端页面中执行此操作,文章是否会在前端页面中保持隐藏?