我很想知道是否有办法在 $article_content 的输出中包含变量。具体来说,我试图在第一个实例<p></p>
或第一段之后输出。用快速插入中断我的变量的其余部分,然后继续该变量
我这样做的原因是我已将旧内容添加到数据库中,以使我的生活更轻松。我在其中有 google(ad) 代码(在第一段之后),它不再来自数据库。这是必须在之后添加的东西,因为该输出不起作用。有没有办法做到这一点?例如,我以前就是这样做的。
<h1>The Page Title</h1>
<p>Some content goes here</p>
<div>Goog script</div>
<p>Content continues here</p>
当我写这篇文章时,我正在想象一个变量,它开始然后在页面的后面结束,就像这样
$variable .= 'First Part of content = Some content goes here';
$variable .= 'First Part of content = Some content goes here';
<?php echo $variable; ?>
<div>Goog script</div>
<?php echo $variable; ?>
当然 $variable 开始然后变量使用相同的 $article_content 变量结束。
请让我知道这是否令人困惑
<?php
// Check to see the URL variable is set and that it exists in the database
if (isset($_GET['id'])) {
// Connect to the MySQL database
include "newInclude/db_conx.php";
$id = preg_replace('#[^0-9]#i', '', $_GET['id']); // filter everything but numbers
// Use this var to check to see if this ID exists, if yes then get the product
$sqlCommand = "UPDATE articles SET views=views+1 WHERE ID=$id";
// Execute the query here now
$query = mysqli_query($db_conx, $sqlCommand);
//--------------------------------------------------------------------------------------
$sqlcount = "SELECT * FROM articles WHERE id=$id LIMIT 1";
$sql_count = mysqli_query($db_conx,$sqlcount);
$blogCount = mysqli_num_rows($sql_count);
//--------------------------------------------------------------------------------------
if ($blogCount > 0) {
// get all the product details
while($row = mysqli_fetch_array($sql_count)){
$article_title = $row["article_title"];
$category = $row["category"];
$readmore = $row["readmore"];
$author = $row["author"];
$date_added = $row["date_added"];
$article_content = $row["content"];
}
} else {
echo "That item does not exist.";
exit();
}
} else {
echo "Data to render this page is missing.";
exit();
}
//--------------------------------------------------------------------------------------
?>
这是你指的@gabe吗?
<?php echo $beginning_text . <script type="text/javascript"></script> . $the_rest; ?>