以相同的形式添加和编辑php

时间:2012-09-07 15:03:53

标签: php forms

我有这段代码:

<?php
////////////////////////////////////////
include "../includes/site_includes.php";//
//////////////////////////////////////
$sql = getallsitesettings();
if ($result = $mysqli->prepare($sql)) 
{
$rekza = 1;
$result->bind_param("i",$rekza);
$result->execute(); 
$result->store_result();
$rowsZ = $result->num_rows;
}
if($rowsZ>0)
{
$row = fetch($result);
}
$siteTitle= $row[0]["site_title"];
$sitePeleText= $row[0]["pele"];
?>
<?php

$act = $mysqli->real_escape_string($_GET["act"]);
if($act=="edit")
{
    $folderid = (int)$_GET["id"];
    $sql2 = getfolderbyId();
    if ($result2 = $mysqli->prepare($sql2)) 
    {
    $result2->bind_param("i",$folderid);
    $result2->execute();    
    $result2->store_result();
    $rowsZ2 = $result2->num_rows;
    }
    if($rowsZ2>0)
    {
    $row2 = fetch($result2);
    }
    for($j=0; $j<$rowsZ2; $j++) 
        {
    $foldername = $row2[$j]["fold_name"];
    $foldpath = $row2[$j]["fold_path"];
    $foldpic = $row2[$j]["fold_pic"];
        }
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html dir="rtl">
 <head>
  <title><?=$txt_folders?></title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta name="Generator" content="EditPlus">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <link href="<?=$site_url?>/css/styles.css" rel="stylesheet" type="text/css" />
 </head>
    <table align="center" cellspacing="0" cellpadding="0" width="1021">
        <tr>
            <td><?php
            include "../site_header.php";
            ?></td>
        </tr>
        <tr>
            <td style="background-color:#dcdbdb;">
                    <table align="center" cellspacing="0" cellpadding="0" width="1021">
                        <tr>
                            <td>
                                <div class="admintitle">
                                <a href="../main.php" style="color:black; text-decoration:none;"><?=$txt_main_admin?></a> > <?=$txt_folders?>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <table align="center" cellspacing="0" cellpadding="0" width="400">
                                    <tr>
                                        <td style="color:Black; font-family:arial; font-weight:Bold;"><?=$txt_folders_name?></td>
                                        <td style="color:Black; font-family:arial; font-weight:normal;"><input type="textbox" name="fold_name" value="<?=$foldername?>" /></td>
                                    </tr>
                                    <tr>
                                        <td style="color:Black; font-family:arial; font-weight:Bold;"><?=$txt_folder_path?></td>
                                        <td style="color:Black; font-family:arial; font-weight:normal;"><input type="textbox" name="fold_path" value="<?=$foldpath?>" /></td>
                                    </tr>
                                    <tr>
                                        <td></td>
                                        <td></td>
                                    </tr>
                                    <tr>
                                        <td colspan="2"></td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>
            </td>
        </tr>
        <tr>
            <td><?php
            include "../site_footer.php";
            ?></td>
        </tr>
    </table>
 <body>
 </body>
</html>

... 你能告诉我这个问题吗? 为什么当act = add 值中的变量=&#34;&#34;在输入中是未定义的?....如何在编辑和添加中定义它们... 在添加中我需要它们空...并且在编辑中它很有效....

1 个答案:

答案 0 :(得分:0)

可能是......

if($act=="edit" || $act=="add")

:)

相关问题