-3
我有兩個php.First文件的文件是賣家狀態報告。如果我點擊任何記錄,然後在新窗口中打開一個新選項卡(表單)。我已經使用了窗口。在js文件中打開。 現在在第二種形式中我有一個html form.I想根據id來填寫所有字段。我不熟悉如何在這種情況下綁定數據。如何使用PHP綁定HTML表單的數據
<?php
if
(mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"myquery");
if (isset($_POST['from']) && isset($_POST['from']))
{
$a=$_POST['from'];
$b=$_POST['to'];
$result = mysqli_query($con,"myquery'");
}
else {
$result = mysqli_query($con,"myquery");
}
echo "<table id='example' class='display' border='1px' cellspacing='0' width='100%'>
<thead style='background:cadetblue'>
<tr class='rowname'>
<th>Name</th>
<th>email</th>
<th>contact_no</th>
<th>state</th>
<th>city</th>
<th>TargetCity</th>
<th>ProjectName</th>
<th>Price</th>
<th>Size</th>
<th>PropertyDescription</th>
<th>PaymentPlanName</th>
<th>SaleTimeHorizon</th>
<th>PaytmentCompleted_Percentage</th>
<th>CreatedOn</th>
</tr>
</thead>";
echo"<tfoot style='display: table-header-group;'>
<tr>
<th>Name</th>
<th>email</th>
<th>contact_no</th>
<th>state</th>
<th>city</th>
<th>TargetCity</th>
<th>ProjectName</th>
<th>Price</th>
<th>Size</th>
<th>PropertyDescription</th>
<th>PaymentPlanName</th>
<th>SaleTimeHorizon</th>
<th>PaytmentCompleted_Percentage</th>
<th>CreatedOn</th>
</tr>
</tfoot>";
echo "<tbody>";
while($row = mysqli_fetch_array($result)) {
echo "<tr id='".$row['id']."'>";
echo "<td>" . $row['Name'] . "</td>";
echo "<td>" . $row['email'] . "</td>";
echo "<td>" . $row['contact_no'] . "</td>";
echo "<td>" . $row['state'] . "</td>";
echo "<td>" . $row['city'] . "</td>";
echo "<td>" . $row['TargetCity'] . "</td>";
echo "<td>" . $row['ProjectName'] . "</td>";
echo "<td>" . $row['Price'] . "</td>";
echo "<td>" . $row['Size'] . "</td>";
echo "<td>" . $row['PropertyDescription'] . "</td>";
echo "<td>" . $row['PaymentPlanName'] . "</td>";
echo "<td>" . $row['SaleTimeHorizon'] . "</td>";
echo "<td>" . $row['PaytmentCompleted_Percentage'] . "</td>";
echo "<td>" . $row['CreatedOn'] . "</td>";
echo "</tr>";
}
echo '<a href="download.php"><img src="images/Excel-Logo.jpg">
</a>';
echo"</tbody>";
echo "</table>";
mysqli_close($con);
?>
第二個文件是window.open的
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Buyer Form</title>
<link rel="stylesheet" type="text/css" href="CSS/master.css" />
<link rel="stylesheet" type="text/css" href="CSS/profilepage.css">
<link rel="stylesheet" type="text/css" href="CSS/bootstrap.css">
<link rel="stylesheet" type="text/css" href="CSS/jquery.datetimepicker.css">
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery.datetimepicker.js"></script>
<script type="text/javascript" src="js/datetime.js"></script>
</head>
<body>
<header class="full grey-bg btn-gryShdw pageHeader pos-r" id="header">
<div class="mr-r-15 mr-1-15" style="border-bottom:1px solid #ECECEC">
<div class="w100">
<div class="profilePic">
<img src="images/gravatar.jpg">
</div>
<div class="profileInfo w90" style="background-color:#1286f5">
<div class="f1 pos-r">
<div class="name ng-binding fl">Mayank</div>
<ul id="actions">
<li id="service" class="w30 txt-ac">Service</li>
<li id="status" class="w30 txt-ac">Status<br>Open</br></li>
<li id="user" class="w40 txt-ac">User Created On
<div class="date1">12 August</div></li>
</ul>
</div>
</div>
</div>
</div>
</header>
<div id="main" class="fl" style="width:100%">
<div id="content" class="pad5 fl mr-t5 " style="margin-bottom:25px;word-wrap:break-word ;width:20%;">
<form class="pad-l5 mr-t10 ">
<div id="name">Name</div>
<input type="text"/>
<br>
<br>
<div>Email</div>
<input type="text"/>
<br>
<br>
<div>Contact Number</div>
<input type="text"/>
<br>
<br>
<div>City</div>
<input type="text"/>
<br>
<br>
</form></div>
<div id="maindropdown" class="mr-t5 fl pad5" style="width:40%">
<div id="dropstatus" class="mr-t5 fl pad5">
<span>Status</span><br>
<select>
<option value="Gurgaon">Open</option>
<option value="Noida">Pending For Request</option>
<option value="Gurgaon">Close</option>
</select>
</div>
<div id="dropdownsub" class="mr-t5 fl pad5">
<span>SubStatus</span><br>
<select style="width:255px">
<option value="Not Known">Not Known</option>
<option value="Understood">Understood</option>
</select>
</div>
<div id="txtarea" class="mr-t10 pad-t50">Description/Notes<br>
<textarea rows="8" cols="50" style="width:100%"></textarea>
</div>
</div>
<div id="nextaction" class="mr-t6 fl pad5" style="width:35%">Next Action<br>
<div id=nextactiontxt class="mr-t5 fl pad5">
<textarea rows="3" cols="55"></textarea>
</div>
<div class="mr-t6 fl pad5 mr-t30">Next Action Date<br>
<input id="datetimepicker" type="text">
</div>
<div class="mr-t6 fl pad5 mr-t30">
<span>Next Action Responsible</span><br>
<select style="width:170px">
<option value="name1">Rohit Rahav</option>
<option value="name2">Vivek Aggarwal</option>
<option value="name3">Hitesh Singla</option>
<option value="name4">Soni</option>
<option value="name1">Mayank Vashist</option>
</select>
</div>
</div>
</div>
</body>
</html>
<?php
$mysqli=new mysqli("localhost","root","","realitycheck");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
if (!($stmt = $mysqli->prepare("select id,CONCAT_WS(' ', u.firstname,u.lastname) AS Name
from p_sellservices p left join users u
on p.UserId=u.id left join rc_project pt on p.ProjectId=pt.ProjectId left join p_paymentplan pp on
p.PaymentPlanId=pp.PaymentPlanId left join rc_location lc on p.LocationId=lc.LocationId"))) {
echo "Prepare failed: (" . $mysqli->errno . ") " . $mysqli->error;
}
if (!$stmt->execute()) {
echo "Execute failed: (" . $mysqli->errno . ") " . $mysqli->error;
}
$out_id = NULL;
$out_Name = NULL;
if (!$stmt->bind_result($out_id, $out_Name)) {
echo "Binding output parameters failed: (" . $stmt->errno . ") " . $stmt->error;
}
while ($row=mysqli_fetch_array($stmt)) {
echo'<input type="text" id="name">';
}
?>
腳本是在這裏
$(document).ready(function() {
$('#example').dataTable({
"order": [[ 3, "desc" ]],
"pageLength": 100
});
var table = $('#example').DataTable();
$("#example tfoot th").each(function (i) {
var select = $('<select><option value=""></option></select>')
.appendTo($(this).empty())
.on('change', function() {
var val = $(this).val();
table.column(i)
.search(val ? '^'+$(this).val()+'$' : val, true, false)
.draw();
});
table.column(i).data().unique().sort().each(function (d, j) {
select.append('<option value="'+d+'">'+d+'</option>')
});
});
$(document).ready(function() {
$('#example').dataTable();
$('#example tbody tr').on('click', function() {
var id = $(this).attr("id");
window.open("new.php?uid="+id);
//alert('You clicked on '+name+'\'s row');
});
});
});
,你寫的新窗口腳本? – 2014-09-04 11:26:25