2012-09-07 31 views
0

我有这样的代码:添加和编辑以相同的形式PHP

<?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 value =“”中的变量在输入中是未定义的?....以及如何在编辑中定义它们并在添加中... 在add中我需要它们为空..在。而且它的伟大工程的编辑....

+1

你只设置'$ foldername','$ foldpath'和'$ $ act ==“编辑”' – andrewsi

+0

omg:$ act = $ mysqli-> real_escape_string($ _ GET [“act”]); –

+0

@DelPedro我不明白你! – michael

回答

0

可能......

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

:)

相关问题