我是 SQL 和 PHP 的新手,需要帮助解决以下问题。
我有一个 SQL 数据库,例如,“用户名、密码、国籍、类别”,我想做的是,一个简单的 PHP 或 SQL 查询,它将从数据库中检查用户的类别字段并显示相应的 URL在指定的 iFrame 中(例如,类是 J1、J2、J3,如果该字段已包含 J3,则在加载时显示相应的 URL,无需任何用户输入。(所有这些都将提前决定)
您可以将其视为学生个人资料,一旦学生成功登录,查询将读取类(class)字段,并根据找到的内容返回带有正确链接的可点击 URL。
这对我现在的水平来说太难了,希望有人能对我有所启发。
这是用户登录成功后的代码。
<!-- NOTIFICATIONS STARTS HERE -->
<?php
require_once('connection.php');
$id=$_SESSION['SESS_MEMBER_ID'];
$result3 = mysql_query("SELECT * FROM member where mem_id='$id'");
while($row3 = mysql_fetch_array($result3))
{
$fname=$row3['fname'];
$country=$row3['country'];
$class=$row3['class'];
$headteacher=$row3['headteacher'];
$attendance=$row3['attendance'];
$homework=$row3['homework'];
$messageparents=$row3['messagestudent'];
}
?>
<table width="468" border="0" align="center" cellpadding="0">
<tr class="FONTS">
<td valign="top"><div align="left" class="FONTS">
<table width="468" border="0" align="center" cellpadding="0">
<tr>
<td class="FONTS"><div align="left" class="FONTS"><b>名前:</b></div>
<?php echo $fname ?></td>
</tr>
<tr class="FONTS">
<td valign="top"><div align="left" class="FONTS"><b>国:</b></div>
<?php echo $country ?></td>
</tr>
<tr class="FONTS">
<td valign="top"><div align="left" class="FONTS"><b>クラス:</b></div>
<?php echo $class ?></td>
</tr>
<tr class="FONTS">
<td valign="top"><div align="left" class="FONTS"><b>家庭教師の先生:</b></div>
<?php echo $headteacher ?></td>
</tr>
<tr class="FONTS">
<td valign="top"><div align="left" class="FONTS"><b>出席率:</b></div>
<?php echo $attendance ?></td>
</tr>
<tr class="FONTS">
<td valign="top"><div align="left" class="FONTS"><b>宿題率:</b></div>
<?php echo $homework ?></td>
</tr>
<tr class="FONTS">
<td valign="top"><div align="left" class="FONTS"><b>先生からメッセージ:</b>
</div>
<?php echo $messagestudent ?></td>
</tr>
</table>
</div></td>
</tr>
</table>
<p align="center" class="FONTS"><a href="index.php">ログアウト</a></p>
<!-- NOTIFICATIONS ENDS HERE -->
它已经按预期工作,所以除非完全必要,否则我不会更改它,我只需要能够显示该 URL 链接。
提前致谢!
最佳答案
<?php
if($class=='J1')
echo "<a href='www.first_url.com'>Click Here</a>";
else if($class=='J2')
echo "<a href='www.second_url.com'>Click Here</a>";
..............
?>
关于php - 使用 php 和 mysql 在 iFrame V2 中显示特定的 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30477002/