我有一个搜索结果页面,我设法为每个结果项动态包含一个推文按钮。
我遇到的问题是,当点击推文按钮时,它只推文页面标题而不是搜索结果项。
你能帮助我吗?
这是我的代码:
<html>
<font face="arial">
<title>Bible Verses Search</title>
<?php
// db req
$db_host="localhost";
$db_username="username";
$db_password="password";
$db_name="dbname";
$db_tb_name="tablename";
$db_tb_atr_name="line";
$db_tb_atr_name2="book";
$db_tb_atr_name3="cap";
$db_tb_atr_name4="verse";
//do search task
mysql_connect("$db_host","$db_username","$db_password");
mysql_select_db("$db_name");
$query=mysql_real_escape_string($_GET['query']);
$query_for_result=mysql_query("SELECT * FROM $db_tb_name WHERE
$db_tb_atr_name like '%".$query."%' OR $db_tb_atr_name2 like '%".$query."%'
OR $db_tb_atr_name3 like '%".$query."%' OR $db_tb_atr_name4 like '%".$query."%'");
echo "Search Results<ol>";
//bible query new section begins
define ('HOSTNAME', 'localhost');
define ('USERNAME', 'username');
define ('PASSWORD', 'password');
define ('DATABASE_NAME', 'dbname');
$db = mysql_connect(HOSTNAME, USERNAME, PASSWORD) or die ('I cannot connect to
MySQL.');
mysql_select_db(DATABASE_NAME);
$query = "SELECT id,book,cap,verse,line FROM tablename ORDER BY RAND() LIMIT 1 ";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
echo "<center><a href='page25.php?id=$row[id]'>Back</a></center>";
//mysql_free_result($result);
//mysql_close();
//new bible query section ends
while($data_fetch=mysql_fetch_array($query_for_result))
{
echo "<li>";
echo substr($data_fetch[$db_tb_atr_name2], 0,160)," ";
echo substr($data_fetch[$db_tb_atr_name3], 0,160)," ";
echo substr($data_fetch[$db_tb_atr_name4], 0,160)," ";
echo substr($data_fetch[$db_tb_atr_name], 0,160);
echo '<a href="https://twitter.com/share" class="twitter-share-button" data-
url="page25.php?id=$row[id]">Tweet</a>';
echo "</li><hr/>";
}
echo "<center><a href='page25.php?id=$row[id]'>Back</a></center> ";
echo "</ol>";
//mysql_close();
?>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)
[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id))
{js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';
fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
</font>
</html>