<?php
session_start();
if(is_user_logged_in()) {
global $wpdb;
$id = get_current_user_id();
$recoveryID = null;
// $results = $wpdb->get_results('SELECT * FROM wp_recovery_details where not exists (select driverID ,recoveryID from wp_recovery_bids where driverID='$id')');
//
$results = $wpdb->get_results('SELECT * FROM wp_recovery_details');
//
// EXISTS (select driverID ,bidAmount from wp_recovery_bids)
// output data of each row
foreach ($results as $row) {
// $recoveryID = $row->recoveryID;
// $result = $wpdb->get_results('select * from wp_recovery_details where not exists(select driverID from wp_recovery_details where recoveryID ='$recoveryID' ');
// if(count($result) > 0){
// $numberPlate = str_replace(' ', '', $row -> custNoPlate);
//
$_SESSION['recoveryID'] = $row -> recoveryID;
$image = $row -> imageURL;
echo
"<table role='table'>
<thead>
<tr>
<th>Vehicle</th>
<th>Location</th>
<th>Destination</th>
<th>Estimated Time of Arrival</th>
<th>Your price</th>
</tr>
</thead>
<tr>
<th>
<form method='post' action =''>
<h1> ".$row -> recoveryID." </h1>
<img src='/{$image}'
width='150' height='70'/>
". $row -> custNoPlate."
<th>" .$row -> pickUp. "</th>
<th>" .$row -> destination. "</th>
<th><input type='time' name='eta'/></th>
<th><input type='text' name='price'/></th>
<th><input type='submit' name='submit'/></th>
</form>
</table>";
// }
};
if(isset($_POST['submit'])){
$table_name = $wpdb->prefix.'recovery_bids';
$bidAmount = $_POST['price'];
$estimatedTime = $_POST['eta'];
$bidID = rand(10,10000);
$driverID = get_current_user_id();
$recoveryID = $_SESSION['recoveryID'];
$wpdb->insert($table_name, array(
'bidID' => $bidID,
'bidAmount' => $bidAmount,
'estimatedTime'=> $estimatedTime,
'driverID' => $driverID,
'recoveryID' => $recoveryID ,
),
array(
'%s',
'%s',
'%s',
'%s',
'%s',
));
}
} else{
echo "Login to view this page";
}
?>
sql - Why is my insert row only inserting the final row from the loop into the database rather than just inserting one
与本文相关的文章
- javascript - Deleting specific array element from multidimensional array? - Stack Overflow
- javascript - Draw an arrow on HTML5 Canvas between two objects - Stack Overflow
- Load javascript sequentially from javascript code - Stack Overflow
- Detect if a block has been deleted
- c++ - How to Suppress gRPC Debug Context in Error Messages - Stack Overflow
- regex - Javascript remove all characters from string which are not numbers, letters and whitespace - Stack Overflow
- security - Wordpress Database - wp_usermeta and the correct number of session_tokens rows
- String.Format in Javascript? - Stack Overflow
- javascript - How do I format JSON code in Monaco Editor with API? - Stack Overflow
- Using dynamic SQL to turn key-value pairs into columns in nested records in BigQuery - Stack Overflow
- javascript - ANDROIDWEBVIEW-- Uncaught TypeError: Object [object Object] has no method 'changeActivity' at file:
- ecmascript 6 - Javascript: replace everything but numbers and allow only one dot - Stack Overflow
- javascript - React: open link in a new tab - Stack Overflow
- python - Kernel-stop error occurred during shap-value calculation - Stack Overflow
- javascript - jquery - show textbox when checkbox checked - Stack Overflow
- javascript - Custom HTML5 video player controls with AngularJS - Stack Overflow
- jquery - How to get whole number when dividing 2 numbers in JavaScript - Stack Overflow
- javascript - Leaflet: Add a link to the markers - Stack Overflow
- javascript - Getting bold math expression when converting MathJax to png via html2canvas - Stack Overflow
- javascript - Add element to multidimensional array - Stack Overflow
评论列表(0)
- 暂无评论