私はこれを出力しようとしているimに取り組んでいるこのコードを持っています:
{
title:"<?php echo $sender_fullname; ?>",
mp3:"link",
},
これをphpで使用してjavascriptで表示する
//database include
require_once "db.php";
//get email from session
$email = $_SESSION['username'];
//fetch user fullname and id based on session
$name_query = mysql_query("SELECT fullname,id FROM users WHERE email = '$email'");
$name = mysql_fetch_object($name_query);
//fecth sender id, receiver id, audioclip, fullname and email
$query = "SELECT m.sender,m.receiver, m.audioclip, u.fullname, u.email
FROM `users` AS u
JOIN `messages` AS m ON m.receiver = u.id
WHERE u.email = '".$email."'";
$result = mysql_query($query);
これが同じものを出力するために何をすべきかというループです
while(
$row = mysql_fetch_assoc($result)) {
$sender = $row['sender'];
$sender_name_query = mysql_query("SELECT fullname FROM users WHERE id = '$sender'");
$sender_name = mysql_fetch_object($sender_name_query);
$sender_fullname = $sender_name->fullname;
echo '{<br/>title:".'$sender_fullname'.",<br/>mp3:"link",<br/>},';
}