define ("HOST", "localhost");
define("USERNAME", "root");
define("PASSWORD", "");
define("DBNAME","faltu");
$conn = mysqli_connect(HOST,USERNAME,PASSWORD,DBNAME);
$wp = mysqli_connect("localhost", "root", "", "wordpress");
$id = 16;
$query = "SELECT * FROM movies ORDER By id ASC";
$run = mysqli_query($conn,$query);
if(mysqli_num_rows($run) > 0){
while($row = mysqli_fetch_array($run)){
$movie_name = $row['movie_name'];
$star_cast = $row['star_cast'];
$movie_id = $row['id'];
$content1 = '<h3><strong> '.$movie_name.' Movie Description:</strong></h3>
<p> </p>
<p><strong>Details:</strong> </p>
<p>'.$star_cast.' </p>
<p><strong>Original Download Links of Hindi Movie '.$movie_name.' Mp3 Songs</strong></p>
<table style="height: 395px;" width="601">
<tbody>
<tr>
<td><strong>Movie Song Name</strong></td>
<td><strong>(128 Kbps)</strong></td>
<td><strong>(320 Kbps)</strong></td>
</tr>';
$id++;
$iquery = " INSERT INTO wp_posts (post_title, post_content) VALUES ('$movie_name', '$title') ";
$irun = mysqli_query ($wp, $iquery);
$hquery = "SELECT * FROM songs WHERE movie_id = $movie_id";
$hrun = mysqli_query($conn,$hquery);
if(mysqli_num_rows($hrun) > 0){
while($hrow = mysqli_fetch_array($hrun)){
$hsong_name = $hrow['song_name'];
$singer = $hrow['singer_name'];
$hsong_link = $hrow['song_link'];
echo $content2 ='<tr>
<td>'.$hsong_name.'
<em>'.$singer.'</em></td>
<td><strong><a href="'.$hsong_link.'">Download</a></strong></td>
<td><strong><a href="'.$hsong_link.'">Download</a></strong></td>
</tr>';
echo $id;
$jquery = "UPDATE wp_posts SET post_content = CONCAT(post_content, '$content2') WHERE ID = $id";
$jrun = mysqli_query ($wp, $jquery);
if(mysqli_num_rows($jrun) > 0){
echo $content;}
}}}}
?>
首先很抱歉问这个愚蠢的问题,我是一个很大的NOOB 好我在这里要做的是:
我有2个数据库,我从第一个数据库(faltu)中提取并添加一些带有值的html并将这些值放在第二个数据库(wordpress)中,在$ query中我正在获取$ movie_name和$ star_cast值并添加一些html然后将它放入$ content1,之后通过iquery将其插入到wordpress.wp_posts中,现在我想要$ hquery给我一些movie_id相同的歌曲列表, 然后我想在content2中保存该列表,并希望在同一列上的同一wordpress.wp_posts中将该内容CONCATINATE, 我可以很好地回应这些列表,但它没有被添加到数据库中,请帮助我, 感谢
我想像这样制作帖子内容值
<h3><strong>Kaabil 2016 Movie Description:</strong></h3>
StarCast:Hrithik Roshan, Yami Gautam
Music by :Sanjay Gupta
Music<strong>:</strong> Rajesh Roshan
<strong>Original Download Links of Hindi Movie Kaabil Mp3 Songs</strong>
<table style="height: 395px;" width="601">
<tbody>
<tr>
<td><strong>Movie Song Name</strong></td>
<td><strong>(128 Kbps)</strong></td>
<td><strong>(320 Kbps)</strong></td>
</tr>
<tr>
<td><strong>01 –</strong> Kaabil Hoon
<em>Jubin Nautiyal, Palak Muchhal</em></td>
<td><strong><a href="#">Download</a></strong></td>
<td><strong><a href="#">Download</a></strong></td>
</tr>
<tr>
<td><strong>02 –</strong> Haseeno Ka Deewana
<em>Raftaar, Payal Dev</em></td>
<td><strong><a href="#">Download</a></strong></td>
<td><strong><a href="#">Download</a></strong></td>
</tr>
<tr>
<td><strong>03 –</strong> Kuch Din
<em>Jubin Nautiyal</em></td>
<td><strong><a href="#">Download</a></strong></td>
<td><strong><a href="#">Download</a></strong></td>
</tr>
<tr>
<td><strong>04 –</strong> Mon Amour
<em>Vishal Dadlani</em></td>
<td><strong><a href="#">Download</a></strong></td>
<td><strong><a href="#">Download</a></strong></td>
</tr>
<tr>
<td><strong>05 –</strong> Kaabil Hoon (Sad Version)
<em>Jubin Nautiyal</em></td>
<td><strong><a href="#">Download</a></strong></td>
<td><strong><a href="#">Download</a></strong></td>
</tr>
<tr>
<td><strong>06 –</strong> Kisi Se Pyar Ho Jaye
<em>Jubin Nautiyal</em></td>
<td><strong><a href="#">Download</a></strong></td>
<td><strong><a href="#">Download</a></strong></td>
</tr>
</tbody>
</table>