【发布时间】:2020-09-07 14:35:19
【问题描述】:
我正在尝试将 song_id 传递给模态,然后通过 href 将从模态中的 song_id 获得的值传递到另一个页面。 song_id 值存储在 span id 中,然后我想通过存储在 php 变量中的 href 传递 span id 值并显示在下一页中,但是 span 值没有使用 href 传递到下一页,请我需要有关如何使用 href 将存储在变量中的 span id 值传递到下一页的指南。
这是我的代码:
// This is where am getting song_id from
<?php
require '../db.php';
$sql = "select * from songs order by song_id desc Limit 20";
$sql_query = mysqli_query($con,$sql);
while ($row = mysqli_fetch_array($sql_query)) {
$song_id = $row['song_id'];
?>
// This is the code triggering the modal and passing the song_id to the modal
<li><a data-id="<?php echo $row['song_id']; ?>" onclick="$('$playlist_id').text($(this).data('id')); $('#myModal3').modal('show');"><span class='icon icon_playlst'></span>Add To Playlist</a></li>
// This is the modal which would receive song_id and pass it to my_playlist.php through href.
<!-- Select Playlist Start-->
<div id="myModal3" class="modal centered-modal" role="dialog">
<div class="modal-dialog login_dialog">
<!-- Modal content-->
<div class="modal-content">
<button type="button" class="close" data-dismiss="modal">
<i class="fa_icon form_close"></i>
</button>
<div class="modal-body">
<form action="create_playlist.php" method="post">
<div class="ms_register_form">
<h2>Add to Playlist</h2>
<div class="ms_weekly_box">
<div class="weekly_left">
<div class="w_top_song">
<div class="w_tp_song_name">
//This is where i store the song_id in a php variable and pass it in the href of my_playlist.php.
<h2><?php $playlist_id = '<span id="playlist_id"/>'; echo $playlist_id; ?></h2>
<h3><a href="my_playlist.php?new_id=<?php echo $playlist_id; ?>">Hip-Hop</a></h3>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
【问题讨论】:
标签: php