need a favor. I wanted to make the internal PHP script runs automatically on page load. I have problems related to passing the value of the Date and User input from the form to the internal PHP script. I have tried both $_POST
and $_GET
. Should I put the script in an external script? I dont really need codes, just tell me what should I look into. Thanks!
Entry Log/Edit
需要一个忙我想让内部PHP脚本在页面加载时自动运行。我遇到的问题涉及将Date和User输入的值从表单传递到内部PHP脚本。我已经尝试了$ _POST和$ _GET。我应该将脚本放在外部脚本中吗?我真的不需要代码,只要告诉我应该调查什么。谢谢!输入日志/编辑
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script type="text/javascript" type="text/javascript" src="js/simpledtpicker.js"></script>
</head>
<body style="text-align:center;">
<div class="wrapper">
<?php include('includes/header.php')?>
<h1 style="text-align:center;">Entry Log/Edit</h1>
<span>
<form action="#" method="GET">
<table style="width:100%;">
<tr>
<th style="text-align:left;">
Entries for:
<input type="text" name="dateOfEntry" class="dateOfEntry">
<script type="text/javascript">
$(function()
{
$('*[name=dateOfEntry]').appendDtpicker(
{
"dateOnly": true,
"dateFormat": "MM/DD/YYYY",
"autodateOnStart": true,
"closeOnSelected": true
});
});
</script>
</th>
<th style="text-align:right; padding-right: 0px;">
User:
<input type="text" name="user" value="Hrobi7198228" readonly="readonly" style="border:none; background-color:transparent"/>
</th>
<th width="5px;"><input type="submit" name="submit" value="Go"></th>
</tr>
</table>
</form>
</span>
<br>
<table class="entry" style="width: 100%;">
<thead>
<?php
include ('connServer.php');
$date = date('Y-m-d', strtotime(str_replace("-","/",$_GET['dateOfEntry'])));
$username = $_GET['user'];
$query = 'SELECT `ID`, `Date`, `Description`, `TypeOfDowntime`, `Machine#` FROM `machineissuesreport` WHERE `Date`="'.$date.'" AND `UpdatedBy` = "'.$username.'" ORDER BY `ID` DESC';
$conn = mysqli_query($connection, $query);
if ($conn)
{
echo '<tr>
<th width="5px">Edit</th>
<th width="5px">Delete</th>
<th>Date</th>
<th>Details</th>
<th width="100px" style="text-align:center;">Downtime Type</th>
<th width="20px" style="text-align:center;">Machine No.</th>
</tr>
</thead>
<tbody>';
while($row = mysqli_fetch_array($conn))
{
echo '<tr>';
echo '<td style="text-align: center" width="5px"><a href="editMachineIssue.php?id='.$row["ID"].'" class="edit">Edit</a></td>';
echo '<td style="text-align: center" width="5px"><a href="#" id="'.$row['ID'].'" class="delete">Delete</a></td>';
echo '<td style="display: none;"><input type="hidden" value='.$row['ID'].'></td>';
echo '<td width="5px" style="text-align: center; padding: 0px 5px;">'.$row['Date'].'</td>';
echo '<td style="text-align: left; padding: 0px 0px 0px 12px;">'.$row['Description'].'</td>';
echo '<td style="text-align: center;">'.$row['TypeOfDowntime'].'</td>';
echo '<td style="text-align: center;">'.$row['Machine#'].'</td>';
echo '</tr>';
}
}
?>
<script type="text/javascript">
$(document).ready(function()
{
$.ajax
({
type: 'POST',
data: {'run':run},
success: function(data)
{
}
});
$('.delete').click(function()
{
if(confirm("Are you sure you want to delete this row?"))
{
var del_id = $(this).attr('id');
var $ele = $(this).parent().parent();
$.ajax({
type: 'POST',
url: 'machineEntryLogEdit.php',
data: {'del_id' : del_id},
success: function(data)
{
$ele.fadeOut().remove();
},
error: function (xhr, status, error)
{
alert(this);
}
});
}
});
});
</script>
</tbody>
</table>
</div>
</body>
</html>
I am still progressing on it, but please help me find the correct terms to Google. I am fairly new to PHP and AJAX.
我仍然在努力,但请帮助我找到谷歌的正确条款。我是PHP和AJAX的新手。
1 个解决方案
#1
0
You can write below code in a js file and include the js file in your page.
您可以在js文件中编写以下代码,并在页面中包含js文件。
$(document).ready(function(){
$.ajax({ url: "file.php",
data: data1,
success: function(){
// Do whatever you want to do here.
}});
});
#1
0
You can write below code in a js file and include the js file in your page.
您可以在js文件中编写以下代码,并在页面中包含js文件。
$(document).ready(function(){
$.ajax({ url: "file.php",
data: data1,
success: function(){
// Do whatever you want to do here.
}});
});