如果用户单击修改视频链接有条件,我试图让前面代码中查询的行在其中回显。但是,当我直接在 if ($videoEdit) { 条件上方回显 $video 变量时,它会显示在页面上,但是如果我尝试在 if ($videoEdit) { 条件下回显它,由于某种原因它不会输出。我很困惑。这是我的代码(不包括查询,但 echo $video 在有条件之前会输出正确的结果)
添加:::
require ('../mysql_connect.php'); // Connect to DB
// Handle Video Edit
if ($_GET['video'] == "EDIT") {
$videoEdit = TRUE;
}
$query = "SELECT inventory.inv_key, inventory.mdl_key, inventory.serial, inventory.date_aquired, inventory.location, inventory.price, model.mdl_key, model.man_key, model.cls_key, model.sub_cls_key, model.model, model.video, model.picture, model.pdf, subclass.sub_cls_key, subclass.subclass, class.cls_key, class.class, manufacturer.man_key, manufacturer.manufacturer FROM inventory, manufacturer, model, class, subclass WHERE inventory.mdl_key='$_GET[mdl_key]' AND model.mdl_key='$_GET[mdl_key]' AND class.cls_key='$_GET[cls_key]' AND subclass.sub_cls_key='$_GET[sub_cls_key]' AND manufacturer.man_key='$_GET[man_key]' AND manufacturer=manufacturer.manufacturer AND class=class.class AND subclass=subclass.subclass";
$result = @mysql_query ($query); // Run the query
while ($row = mysql_fetch_array
($result, MYSQL_ASSOC)) {
$model = $row['model'];
$mdl_key = $row['mdl_key'];
$video = $row['video'];
$picture = $row['picture'];
$pdf = $row['pdf'];
$description = $row['description'];
$manufacturer = $row['manufacturer'];
$man_key = $row['man_key'];
}
上面的补充::::
if ($_GET['video'] == 'EDIT') {
$videoEdit = TRUE;
}
while ($row = mysql_fetch_array($result)) {
$video = $row['video'];
}
if ($videoEdit) { // <-- boolean comparison
echo '<form action="edit_media.php" method="post">
<p>Video Link: <input type="text" name="serial" size="25" maxlength="100" value=';
if (isset($video))
echo $video;
}
echo ' /></p><p><input type="submit" name="submit" value="Submit Video" /></p> <input type="hidden" name="submitted" value="TRUE" />
</form>';
}
加法::这是,在我的代码中,直接在上面的代码下面
if ($video != "") {
echo '<iframe width="420" height="315" src=' . $video . ' frameborder="0" allowfullscreen></iframe> | <a href=edit_media.php?video=EDIT&mdl_key=' . $mdl_key . '&man_key=' . $man_key . '>Modify Video Link</a>';
} else {
echo "Video Not Present | <a href=edit_media.php?video=EDIT>Add a Video</a>";
}