PHP在mysqli_query中创建url,同时循环每个记录

时间:2017-09-24 16:24:11

标签: php mysql

我想在while循环中创建一个链接,其中锚链接是来自查询的记录,并且href将同一查询中的变量传递给另一个页面,因此我只需创建一个显示基于信息的页面传递的变量。

echo "<td>";
echo '<a href="stats_game.php?idGame=.$row['idGame']">'$row['result']'</a>'';
echo "</td></tr>";

此链接会杀死我的网页并返回错误。

3 个答案:

答案 0 :(得分:1)

echo "<td>";
echo '<a href="stats_game.php?idGame='.$row['idGame'].'">'.$row['result'].'</a>';
echo "</td></tr>";

修复你的代码你的报价没有正确关闭

答案 1 :(得分:1)

您的href字符串连接不正确。

好像你试图关闭你的字符串并将它们连接到一半然后停止。即使使用Stack Overflow,您也可以看到字符串错误。

这是href echo的外观:

echo '<a href="stats_game.php?idGame=' .$row['idGame'] . '>' . $row['result'] . '</a>';

答案 2 :(得分:0)

它适用于我

string dir = Path.Combine(MenGinPath, @"Groups\TimesMessages");
string file = Path.Combine(dir, "timedmessages.txt");

// this automatically creates all directories in specified path
// unless it already exists
Directory.CreateDirectory(dir);

//of course, you still need to check if the file exists
if (!File.Exists(file) {
   File.WriteAllLines(filePath, new string[] { "Seperate each message with a new line" });
}
/* or if file exists, do your stuff (optional)
* else {
*  //do something else? maybe edit the file?
* }
*/