2011-12-15 4 views
0

私がしようとしているのは、オーバーレイウィンドウ内でフォームを検証することです。フォームをポップインの中に入れるまでは、すべてうまく動作します。行IDの編集フォームとエコーを含む

私は、ポストインでフォームが検証されていない限り、dbase(ポピインの内側)に行を追加し、既存のレコードを編集しても問題ありません。

私は、ポップインの中にフォームを表示するためにインクルードを使用します。

質問は、どのようにPHPのインクルード内の行IDをエコーするのですか?

これはどういうことでしょうか?もちろん、それは動作しません。

正しい構文は何ですか、あるいは別の方法を試す必要がありますか?

のページの

完全なコードは次のとおりです。

<?php 
$con = mysql_connect("localhost", "root", "****"); 

if (!$con) {  

    die("Error: " . mysql_error()); 

} 
    mysql_select_db("test", $con); 

    $result = mysql_query("SELECT * FROM table_3"); 

?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html> 
<head> 
<script type="text/javascript" charset="utf-8" src="/tables/media/js/jquery.js"></script> 
<script type="text/javascript" charset="utf-8" src="/tables/media/js/jquery.dataTables.js"></script> 

     <style type="text/css"> 
      @import "/tables/media/css/demo_table_jui.css"; 


     </style> 
<script type="text/javascript" charset="utf-8"> 

      $(document).ready(function(){     
    $('#example').dataTable({      

     "sPaginationType":"full_numbers",      
     "aaSorting":[[0, "asc"]],      
     "bJQueryUI":true 

     });   

}); 


</script> 

</head> 
<body> 
<div> 
<p><a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'">Add new row</a>&nbsp;&nbsp;&nbsp;<a href="editmenu/export.php">Export table to xls</a>&nbsp;&nbsp;<a href = "javascript:void(0)" onclick = "document.getElementById('light3').style.display='block';document.getElementById('fade3').style.display='block'">Import csv </a></p> 
<div id="light" class="white_content">Add a single row to a database<a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'">Close</a> 
<?php include "insertform.html"; ?></div> 
     <div id="fade" class="black_overlay"></div> 

<div id="light3" class="white_content">Import data from csv file<a href = "javascript:void(0)" onclick = "document.getElementById('light3').style.display='none';document.getElementById('fade3').style.display='none'">Close</a> 
<?php include "editmenu/importcsv.php"; ?></div> 
     <div id="fade3" class="black_overlay"></div> 



<table cellpadding="0" cellspacing="0" border="0" class="display" id="example"> 
<thead> 
<tr> 
<th>Id</th> 
<th>Owner</th> 
<th>Computer Name</th> 
<th>Model</th> 
<th>Serial Number</th> 
<th>Machine Type</th> 
<th>CG-ITO</th> 
<th>Additional Info</th> 
<th>Edit</th> 
<th>Delete</th> 
</tr> 
</thead> 
<tbody> 
<?php      
while ($row = mysql_fetch_array($result)) {      
?> 
<tr> 
<td><?php echo $row['id']; ?></td> 
<td><?php echo $row['Owner']; ?></td> 
<td><?php echo $row['Computer_Name']; ?></td> 
<td><?php echo $row['Model']; ?></td> 
<td><?php echo $row['Serial_Number']; ?></td> 
<td><?php echo $row['Machine_Type']; ?></td> 
<td><?php echo $row['CG_ITO']; ?></td> 
<td><?php echo $row['Additional_Info']; ?></td> 
<td><a class="edit" href = "javascript:void(0)" onclick = "document.getElementById('light1').style.display='block';document.getElementById('fade1').style.display='block'">Edit</a></td> 
<td><a href = "javascript:void(0)" onclick = "document.getElementById('light2').style.display='block';document.getElementById('fade2').style.display='block'">Delete</a></td> 
</tr> 
<?php 
} 
;?> 
</tbody> 
</table> 
</div> 
<div id="light1" class="white_content">Edit single row<a href = "javascript:void(0)" onclick = "document.getElementById('light1').style.display='none';document.getElementById('fade1').style.display='none'">Close</a> 

<?php include "editform.php?id=" . $row['id']; ?></div> 
    <div id="fade1" class="black_overlay"></div> 

<div id="light2" class="white_content">Delete single row<a href = "javascript:void(0)" onclick = "document.getElementById('light2').style.display='none';document.getElementById('fade2').style.display='none'">Close</a> 
<?php include "deleteval.php"; ?></div> 
     <div id="fade2" class="black_overlay"></div> 
</body> 
</html> 
+0

はあなたには、いくつかのコードを私たちに提供することができますしてくださいというeditform.phpで$_GET['id']を使用することができます。

http://php.net/manual/en/wrappers.php

代わりに、あなたはこれを行うことができますか? – B4NZ41

答えて

-1

あなたは変数を使用して、ファイル名にそれを連結することができますので、それは、ただのPHPコードです:

<?php include "editform.php?id=" . $row['id']; ?> 
0

あなたがそのように使用することはできません。 .. include関数にはパスが必要ですが、URLラッパーを使用する必要がありますが、それはあまり役に立たないと思います。

$_GET['id'] = $row['id']; 
include "editform.php"; 

をそして今、あなたは

+0

ちょうどこれを試みたが、運がない。 – user1100099

関連する問題