我有两个php文件。第一个文件是卖家状态报告。如果我点击任何记录,则在新窗口中打开一个新选项卡(表单)。我在js文件中使用了window.open。 现在以第二种形式我有一个html表单。我希望根据id填写所有字段。在这种情况下我不熟悉如何绑定数据。
<?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);
?>
第二个文件是
<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">';
}
?>
window.open的脚本在这里
$(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' );
} );
} );
} );
答案 0 :(得分:0)
首先,为什么你一次使用不同的jquery版本?由于功能从版本更改为版本,这可能会导致错误。
对于您的问题,您可以使用AJAX将您的请求发送到PHP文件并将结果发送到Javascript以动态填充HTML容器。