How to update Table onclick button in php page












1














In track.php Page once we click on "Submit" button [1st row], I want to Update "ecomexpress_awb table -> orderid column" with value 123456789....



Track.php page [ Based on Orders Table ]:



enter image description here



Below is Table Orders :



enter image description here



Below is Table ecomexpress_awb



enter image description here



Track.php



<?php

$con = mysqli_connect("localhost","root","","do_management4");

$result = mysqli_query($con,"SELECT * FROM orders");

echo "<table border='1'>
<tr>
<th>order</th>
<th>payment</th>
<th>generate</th>
<th>tracking id</th>
</tr>";

while($row = mysqli_fetch_array($result))
{
$id = $row['id'];
echo "<tr>";
echo "<td>" . $row['order_id'] . "</td>";
echo "<td>" . $row['payment_type'] . "</td>";

echo "<td>";
if (empty($row['awb'])) {
echo "<form method='post' action='call.php'>";
echo "<input type ='hidden' name='id' value='$id'>
<input type='submit'>
</form>";
}
echo "</td>";
echo "<td>" . $row['awb'] . "</td>";

echo "</tr>";
}
echo "</table>";

mysqli_close($con);

?>


Call.php



<?php

$con = mysqli_connect("localhost","root","","do_management4");

$result = mysqli_query($con,"SELECT * FROM ecomexpress_awb");

$awb_id='';
$awb_id = $_POST['awb_id'];

$sql = $con->query("update ecomexpress_awb set orderid = '' WHERE awb_id ='$awb_id'");

mysqli_close($con);

?>









share|improve this question






















  • I am failing to understand what you are trying to ask :/
    – B001ᛦ
    Nov 21 at 10:36










  • @B001ᛦ Thanks for reply , if i click on button in php page [this php page is based on table 1 ] , it should copy the values from table 1 to table 2....
    – vickey colors
    Nov 21 at 10:38












  • What issues/errors are you facing?
    – B001ᛦ
    Nov 21 at 10:39










  • @B001ᛦ i am not getting any idea what query i need to use after searching in google for hours......
    – vickey colors
    Nov 21 at 10:39










  • If I understand you correctly you need "SELECT..." to load the data and "INSERT..." to save the data.. and "UPDATE..." to update the existing data which was inserted before
    – B001ᛦ
    Nov 21 at 10:41
















1














In track.php Page once we click on "Submit" button [1st row], I want to Update "ecomexpress_awb table -> orderid column" with value 123456789....



Track.php page [ Based on Orders Table ]:



enter image description here



Below is Table Orders :



enter image description here



Below is Table ecomexpress_awb



enter image description here



Track.php



<?php

$con = mysqli_connect("localhost","root","","do_management4");

$result = mysqli_query($con,"SELECT * FROM orders");

echo "<table border='1'>
<tr>
<th>order</th>
<th>payment</th>
<th>generate</th>
<th>tracking id</th>
</tr>";

while($row = mysqli_fetch_array($result))
{
$id = $row['id'];
echo "<tr>";
echo "<td>" . $row['order_id'] . "</td>";
echo "<td>" . $row['payment_type'] . "</td>";

echo "<td>";
if (empty($row['awb'])) {
echo "<form method='post' action='call.php'>";
echo "<input type ='hidden' name='id' value='$id'>
<input type='submit'>
</form>";
}
echo "</td>";
echo "<td>" . $row['awb'] . "</td>";

echo "</tr>";
}
echo "</table>";

mysqli_close($con);

?>


Call.php



<?php

$con = mysqli_connect("localhost","root","","do_management4");

$result = mysqli_query($con,"SELECT * FROM ecomexpress_awb");

$awb_id='';
$awb_id = $_POST['awb_id'];

$sql = $con->query("update ecomexpress_awb set orderid = '' WHERE awb_id ='$awb_id'");

mysqli_close($con);

?>









share|improve this question






















  • I am failing to understand what you are trying to ask :/
    – B001ᛦ
    Nov 21 at 10:36










  • @B001ᛦ Thanks for reply , if i click on button in php page [this php page is based on table 1 ] , it should copy the values from table 1 to table 2....
    – vickey colors
    Nov 21 at 10:38












  • What issues/errors are you facing?
    – B001ᛦ
    Nov 21 at 10:39










  • @B001ᛦ i am not getting any idea what query i need to use after searching in google for hours......
    – vickey colors
    Nov 21 at 10:39










  • If I understand you correctly you need "SELECT..." to load the data and "INSERT..." to save the data.. and "UPDATE..." to update the existing data which was inserted before
    – B001ᛦ
    Nov 21 at 10:41














1












1








1


0





In track.php Page once we click on "Submit" button [1st row], I want to Update "ecomexpress_awb table -> orderid column" with value 123456789....



Track.php page [ Based on Orders Table ]:



enter image description here



Below is Table Orders :



enter image description here



Below is Table ecomexpress_awb



enter image description here



Track.php



<?php

$con = mysqli_connect("localhost","root","","do_management4");

$result = mysqli_query($con,"SELECT * FROM orders");

echo "<table border='1'>
<tr>
<th>order</th>
<th>payment</th>
<th>generate</th>
<th>tracking id</th>
</tr>";

while($row = mysqli_fetch_array($result))
{
$id = $row['id'];
echo "<tr>";
echo "<td>" . $row['order_id'] . "</td>";
echo "<td>" . $row['payment_type'] . "</td>";

echo "<td>";
if (empty($row['awb'])) {
echo "<form method='post' action='call.php'>";
echo "<input type ='hidden' name='id' value='$id'>
<input type='submit'>
</form>";
}
echo "</td>";
echo "<td>" . $row['awb'] . "</td>";

echo "</tr>";
}
echo "</table>";

mysqli_close($con);

?>


Call.php



<?php

$con = mysqli_connect("localhost","root","","do_management4");

$result = mysqli_query($con,"SELECT * FROM ecomexpress_awb");

$awb_id='';
$awb_id = $_POST['awb_id'];

$sql = $con->query("update ecomexpress_awb set orderid = '' WHERE awb_id ='$awb_id'");

mysqli_close($con);

?>









share|improve this question













In track.php Page once we click on "Submit" button [1st row], I want to Update "ecomexpress_awb table -> orderid column" with value 123456789....



Track.php page [ Based on Orders Table ]:



enter image description here



Below is Table Orders :



enter image description here



Below is Table ecomexpress_awb



enter image description here



Track.php



<?php

$con = mysqli_connect("localhost","root","","do_management4");

$result = mysqli_query($con,"SELECT * FROM orders");

echo "<table border='1'>
<tr>
<th>order</th>
<th>payment</th>
<th>generate</th>
<th>tracking id</th>
</tr>";

while($row = mysqli_fetch_array($result))
{
$id = $row['id'];
echo "<tr>";
echo "<td>" . $row['order_id'] . "</td>";
echo "<td>" . $row['payment_type'] . "</td>";

echo "<td>";
if (empty($row['awb'])) {
echo "<form method='post' action='call.php'>";
echo "<input type ='hidden' name='id' value='$id'>
<input type='submit'>
</form>";
}
echo "</td>";
echo "<td>" . $row['awb'] . "</td>";

echo "</tr>";
}
echo "</table>";

mysqli_close($con);

?>


Call.php



<?php

$con = mysqli_connect("localhost","root","","do_management4");

$result = mysqli_query($con,"SELECT * FROM ecomexpress_awb");

$awb_id='';
$awb_id = $_POST['awb_id'];

$sql = $con->query("update ecomexpress_awb set orderid = '' WHERE awb_id ='$awb_id'");

mysqli_close($con);

?>






php






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 21 at 10:27









vickey colors

263113




263113












  • I am failing to understand what you are trying to ask :/
    – B001ᛦ
    Nov 21 at 10:36










  • @B001ᛦ Thanks for reply , if i click on button in php page [this php page is based on table 1 ] , it should copy the values from table 1 to table 2....
    – vickey colors
    Nov 21 at 10:38












  • What issues/errors are you facing?
    – B001ᛦ
    Nov 21 at 10:39










  • @B001ᛦ i am not getting any idea what query i need to use after searching in google for hours......
    – vickey colors
    Nov 21 at 10:39










  • If I understand you correctly you need "SELECT..." to load the data and "INSERT..." to save the data.. and "UPDATE..." to update the existing data which was inserted before
    – B001ᛦ
    Nov 21 at 10:41


















  • I am failing to understand what you are trying to ask :/
    – B001ᛦ
    Nov 21 at 10:36










  • @B001ᛦ Thanks for reply , if i click on button in php page [this php page is based on table 1 ] , it should copy the values from table 1 to table 2....
    – vickey colors
    Nov 21 at 10:38












  • What issues/errors are you facing?
    – B001ᛦ
    Nov 21 at 10:39










  • @B001ᛦ i am not getting any idea what query i need to use after searching in google for hours......
    – vickey colors
    Nov 21 at 10:39










  • If I understand you correctly you need "SELECT..." to load the data and "INSERT..." to save the data.. and "UPDATE..." to update the existing data which was inserted before
    – B001ᛦ
    Nov 21 at 10:41
















I am failing to understand what you are trying to ask :/
– B001ᛦ
Nov 21 at 10:36




I am failing to understand what you are trying to ask :/
– B001ᛦ
Nov 21 at 10:36












@B001ᛦ Thanks for reply , if i click on button in php page [this php page is based on table 1 ] , it should copy the values from table 1 to table 2....
– vickey colors
Nov 21 at 10:38






@B001ᛦ Thanks for reply , if i click on button in php page [this php page is based on table 1 ] , it should copy the values from table 1 to table 2....
– vickey colors
Nov 21 at 10:38














What issues/errors are you facing?
– B001ᛦ
Nov 21 at 10:39




What issues/errors are you facing?
– B001ᛦ
Nov 21 at 10:39












@B001ᛦ i am not getting any idea what query i need to use after searching in google for hours......
– vickey colors
Nov 21 at 10:39




@B001ᛦ i am not getting any idea what query i need to use after searching in google for hours......
– vickey colors
Nov 21 at 10:39












If I understand you correctly you need "SELECT..." to load the data and "INSERT..." to save the data.. and "UPDATE..." to update the existing data which was inserted before
– B001ᛦ
Nov 21 at 10:41




If I understand you correctly you need "SELECT..." to load the data and "INSERT..." to save the data.. and "UPDATE..." to update the existing data which was inserted before
– B001ᛦ
Nov 21 at 10:41












2 Answers
2






active

oldest

votes


















1














Check this code, This may help you
You should insert awb when insert record in orders table if you have awb then you can update like this



Track.php



<?php

$con = mysqli_connect("localhost","root","","do_management4");

$result = mysqli_query($con,"SELECT * FROM orders");

echo "<table border='1'>
<tr>
<th>order</th>
<th>payment</th>
<th>generate</th>
<th>tracking id</th>
</tr>";

while($row = mysqli_fetch_array($result))
{
$id = $row['id'];
echo "<tr>";
echo "<td>" . $row['order_id'] . "</td>";
echo "<td>" . $row['payment_type'] . "</td>";

echo "<td>";
if (empty($row['awb'])) {
echo "<form method='post' action='call.php'>";
echo "<input type ='hidden' name='id' value='$id'>
<input type ='hidden' name='order_id' value='".$row['order_id']."'>
<input type ='hidden' name='awb' value='".$row['awb']."'>
<input type='submit'>
</form>";
}
echo "</td>";
echo "<td>" . $row['awb'] . "</td>";

echo "</tr>";
}
echo "</table>";

mysqli_close($con);

?>


Call.php



<?php

$con = mysqli_connect("localhost","root","","do_management4");

$result = mysqli_query($con,"SELECT * FROM ecomexpress_awb");

$awb_id='';
$awb_id = $_POST['awb_id'];

$sql = $con->query("update ecomexpress_awb set orderid = '".$order_id."' WHERE awb_id ='$awb_id'");

mysqli_close($con);


//Added code
$order_id='';
if(isset($_POST['order_id']) && $_POST['order_id']!=''){
$order_id = $_POST['order_id'];
$awb= $_POST['awb'];
$sql = $con->query("update ecomexpress_awb set orderid = '".$order_id."' WHERE awb ='".$awb."'");
mysqli_close($con);
}
//End added code

?>





share|improve this answer























  • Thanks for reply, sorry , not updating.....
    – vickey colors
    Nov 21 at 11:19










  • both tables are not related to each other, is it required to related them with foreighn key ?
    – vickey colors
    Nov 21 at 11:21










  • i think you posted track.php code two times in answer, please check and update......
    – vickey colors
    Nov 21 at 11:24










  • As I am seeing you have two tables and both table have column awb so whenever you insert record in orders table then you have to insert awb in orders table, then you can update your ecomexpress_awb table order_id where this awb column match in ecomexpress_awb table
    – F5 Buddy
    Nov 21 at 11:29










  • Sure, i will update as you suggest, please give me updated code for this....
    – vickey colors
    Nov 21 at 11:31





















1














Add one more field in your your button form in Track.php :



echo "<form method='post' action='call.php'>";
echo "<input type ='hidden' name='id' value='$id'>
<input type ='hidden' name='order_id' value='".$row['order_id']."'>
<input type ='hidden' name='awb' value='".$row['awb']."'>
<input type='submit'>
</form>";


and then update your update query in call.php :



if(isset($_POST['order_id'], $_POST['awb'])
&& !empty($_POST['order_id'])
&& !empty($_POST['awb'])){
$con = mysqli_connect("localhost","root","","do_management4");
$awb = $_POST['awb'];
$order_id = $_POST['order_id'];
$sql = $con->query("update ecomexpress_awb set orderid = '".$order_id."' WHERE awb ='".$awb."'");
mysqli_close($con);
}





share|improve this answer























  • Thanks, i will check it now....
    – vickey colors
    Nov 21 at 12:28










  • Why awb column is blank in your orders table? It should have some value.
    – Shail Paras
    Nov 21 at 12:34










  • once i inserted other values in order table, than only i need to insert awb column value......
    – vickey colors
    Nov 21 at 12:36










  • so at the time of inserting row in order table, i din't have awb column values, so i kept it blank......
    – vickey colors
    Nov 21 at 12:36










  • Ok. If you are doing the both insert at the same time, you need to update awb column in Orders table also just after you add data in awb table.
    – Shail Paras
    Nov 21 at 12:43













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53410035%2fhow-to-update-table-onclick-button-in-php-page%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














Check this code, This may help you
You should insert awb when insert record in orders table if you have awb then you can update like this



Track.php



<?php

$con = mysqli_connect("localhost","root","","do_management4");

$result = mysqli_query($con,"SELECT * FROM orders");

echo "<table border='1'>
<tr>
<th>order</th>
<th>payment</th>
<th>generate</th>
<th>tracking id</th>
</tr>";

while($row = mysqli_fetch_array($result))
{
$id = $row['id'];
echo "<tr>";
echo "<td>" . $row['order_id'] . "</td>";
echo "<td>" . $row['payment_type'] . "</td>";

echo "<td>";
if (empty($row['awb'])) {
echo "<form method='post' action='call.php'>";
echo "<input type ='hidden' name='id' value='$id'>
<input type ='hidden' name='order_id' value='".$row['order_id']."'>
<input type ='hidden' name='awb' value='".$row['awb']."'>
<input type='submit'>
</form>";
}
echo "</td>";
echo "<td>" . $row['awb'] . "</td>";

echo "</tr>";
}
echo "</table>";

mysqli_close($con);

?>


Call.php



<?php

$con = mysqli_connect("localhost","root","","do_management4");

$result = mysqli_query($con,"SELECT * FROM ecomexpress_awb");

$awb_id='';
$awb_id = $_POST['awb_id'];

$sql = $con->query("update ecomexpress_awb set orderid = '".$order_id."' WHERE awb_id ='$awb_id'");

mysqli_close($con);


//Added code
$order_id='';
if(isset($_POST['order_id']) && $_POST['order_id']!=''){
$order_id = $_POST['order_id'];
$awb= $_POST['awb'];
$sql = $con->query("update ecomexpress_awb set orderid = '".$order_id."' WHERE awb ='".$awb."'");
mysqli_close($con);
}
//End added code

?>





share|improve this answer























  • Thanks for reply, sorry , not updating.....
    – vickey colors
    Nov 21 at 11:19










  • both tables are not related to each other, is it required to related them with foreighn key ?
    – vickey colors
    Nov 21 at 11:21










  • i think you posted track.php code two times in answer, please check and update......
    – vickey colors
    Nov 21 at 11:24










  • As I am seeing you have two tables and both table have column awb so whenever you insert record in orders table then you have to insert awb in orders table, then you can update your ecomexpress_awb table order_id where this awb column match in ecomexpress_awb table
    – F5 Buddy
    Nov 21 at 11:29










  • Sure, i will update as you suggest, please give me updated code for this....
    – vickey colors
    Nov 21 at 11:31


















1














Check this code, This may help you
You should insert awb when insert record in orders table if you have awb then you can update like this



Track.php



<?php

$con = mysqli_connect("localhost","root","","do_management4");

$result = mysqli_query($con,"SELECT * FROM orders");

echo "<table border='1'>
<tr>
<th>order</th>
<th>payment</th>
<th>generate</th>
<th>tracking id</th>
</tr>";

while($row = mysqli_fetch_array($result))
{
$id = $row['id'];
echo "<tr>";
echo "<td>" . $row['order_id'] . "</td>";
echo "<td>" . $row['payment_type'] . "</td>";

echo "<td>";
if (empty($row['awb'])) {
echo "<form method='post' action='call.php'>";
echo "<input type ='hidden' name='id' value='$id'>
<input type ='hidden' name='order_id' value='".$row['order_id']."'>
<input type ='hidden' name='awb' value='".$row['awb']."'>
<input type='submit'>
</form>";
}
echo "</td>";
echo "<td>" . $row['awb'] . "</td>";

echo "</tr>";
}
echo "</table>";

mysqli_close($con);

?>


Call.php



<?php

$con = mysqli_connect("localhost","root","","do_management4");

$result = mysqli_query($con,"SELECT * FROM ecomexpress_awb");

$awb_id='';
$awb_id = $_POST['awb_id'];

$sql = $con->query("update ecomexpress_awb set orderid = '".$order_id."' WHERE awb_id ='$awb_id'");

mysqli_close($con);


//Added code
$order_id='';
if(isset($_POST['order_id']) && $_POST['order_id']!=''){
$order_id = $_POST['order_id'];
$awb= $_POST['awb'];
$sql = $con->query("update ecomexpress_awb set orderid = '".$order_id."' WHERE awb ='".$awb."'");
mysqli_close($con);
}
//End added code

?>





share|improve this answer























  • Thanks for reply, sorry , not updating.....
    – vickey colors
    Nov 21 at 11:19










  • both tables are not related to each other, is it required to related them with foreighn key ?
    – vickey colors
    Nov 21 at 11:21










  • i think you posted track.php code two times in answer, please check and update......
    – vickey colors
    Nov 21 at 11:24










  • As I am seeing you have two tables and both table have column awb so whenever you insert record in orders table then you have to insert awb in orders table, then you can update your ecomexpress_awb table order_id where this awb column match in ecomexpress_awb table
    – F5 Buddy
    Nov 21 at 11:29










  • Sure, i will update as you suggest, please give me updated code for this....
    – vickey colors
    Nov 21 at 11:31
















1












1








1






Check this code, This may help you
You should insert awb when insert record in orders table if you have awb then you can update like this



Track.php



<?php

$con = mysqli_connect("localhost","root","","do_management4");

$result = mysqli_query($con,"SELECT * FROM orders");

echo "<table border='1'>
<tr>
<th>order</th>
<th>payment</th>
<th>generate</th>
<th>tracking id</th>
</tr>";

while($row = mysqli_fetch_array($result))
{
$id = $row['id'];
echo "<tr>";
echo "<td>" . $row['order_id'] . "</td>";
echo "<td>" . $row['payment_type'] . "</td>";

echo "<td>";
if (empty($row['awb'])) {
echo "<form method='post' action='call.php'>";
echo "<input type ='hidden' name='id' value='$id'>
<input type ='hidden' name='order_id' value='".$row['order_id']."'>
<input type ='hidden' name='awb' value='".$row['awb']."'>
<input type='submit'>
</form>";
}
echo "</td>";
echo "<td>" . $row['awb'] . "</td>";

echo "</tr>";
}
echo "</table>";

mysqli_close($con);

?>


Call.php



<?php

$con = mysqli_connect("localhost","root","","do_management4");

$result = mysqli_query($con,"SELECT * FROM ecomexpress_awb");

$awb_id='';
$awb_id = $_POST['awb_id'];

$sql = $con->query("update ecomexpress_awb set orderid = '".$order_id."' WHERE awb_id ='$awb_id'");

mysqli_close($con);


//Added code
$order_id='';
if(isset($_POST['order_id']) && $_POST['order_id']!=''){
$order_id = $_POST['order_id'];
$awb= $_POST['awb'];
$sql = $con->query("update ecomexpress_awb set orderid = '".$order_id."' WHERE awb ='".$awb."'");
mysqli_close($con);
}
//End added code

?>





share|improve this answer














Check this code, This may help you
You should insert awb when insert record in orders table if you have awb then you can update like this



Track.php



<?php

$con = mysqli_connect("localhost","root","","do_management4");

$result = mysqli_query($con,"SELECT * FROM orders");

echo "<table border='1'>
<tr>
<th>order</th>
<th>payment</th>
<th>generate</th>
<th>tracking id</th>
</tr>";

while($row = mysqli_fetch_array($result))
{
$id = $row['id'];
echo "<tr>";
echo "<td>" . $row['order_id'] . "</td>";
echo "<td>" . $row['payment_type'] . "</td>";

echo "<td>";
if (empty($row['awb'])) {
echo "<form method='post' action='call.php'>";
echo "<input type ='hidden' name='id' value='$id'>
<input type ='hidden' name='order_id' value='".$row['order_id']."'>
<input type ='hidden' name='awb' value='".$row['awb']."'>
<input type='submit'>
</form>";
}
echo "</td>";
echo "<td>" . $row['awb'] . "</td>";

echo "</tr>";
}
echo "</table>";

mysqli_close($con);

?>


Call.php



<?php

$con = mysqli_connect("localhost","root","","do_management4");

$result = mysqli_query($con,"SELECT * FROM ecomexpress_awb");

$awb_id='';
$awb_id = $_POST['awb_id'];

$sql = $con->query("update ecomexpress_awb set orderid = '".$order_id."' WHERE awb_id ='$awb_id'");

mysqli_close($con);


//Added code
$order_id='';
if(isset($_POST['order_id']) && $_POST['order_id']!=''){
$order_id = $_POST['order_id'];
$awb= $_POST['awb'];
$sql = $con->query("update ecomexpress_awb set orderid = '".$order_id."' WHERE awb ='".$awb."'");
mysqli_close($con);
}
//End added code

?>






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 21 at 15:25

























answered Nov 21 at 11:12









F5 Buddy

3304




3304












  • Thanks for reply, sorry , not updating.....
    – vickey colors
    Nov 21 at 11:19










  • both tables are not related to each other, is it required to related them with foreighn key ?
    – vickey colors
    Nov 21 at 11:21










  • i think you posted track.php code two times in answer, please check and update......
    – vickey colors
    Nov 21 at 11:24










  • As I am seeing you have two tables and both table have column awb so whenever you insert record in orders table then you have to insert awb in orders table, then you can update your ecomexpress_awb table order_id where this awb column match in ecomexpress_awb table
    – F5 Buddy
    Nov 21 at 11:29










  • Sure, i will update as you suggest, please give me updated code for this....
    – vickey colors
    Nov 21 at 11:31




















  • Thanks for reply, sorry , not updating.....
    – vickey colors
    Nov 21 at 11:19










  • both tables are not related to each other, is it required to related them with foreighn key ?
    – vickey colors
    Nov 21 at 11:21










  • i think you posted track.php code two times in answer, please check and update......
    – vickey colors
    Nov 21 at 11:24










  • As I am seeing you have two tables and both table have column awb so whenever you insert record in orders table then you have to insert awb in orders table, then you can update your ecomexpress_awb table order_id where this awb column match in ecomexpress_awb table
    – F5 Buddy
    Nov 21 at 11:29










  • Sure, i will update as you suggest, please give me updated code for this....
    – vickey colors
    Nov 21 at 11:31


















Thanks for reply, sorry , not updating.....
– vickey colors
Nov 21 at 11:19




Thanks for reply, sorry , not updating.....
– vickey colors
Nov 21 at 11:19












both tables are not related to each other, is it required to related them with foreighn key ?
– vickey colors
Nov 21 at 11:21




both tables are not related to each other, is it required to related them with foreighn key ?
– vickey colors
Nov 21 at 11:21












i think you posted track.php code two times in answer, please check and update......
– vickey colors
Nov 21 at 11:24




i think you posted track.php code two times in answer, please check and update......
– vickey colors
Nov 21 at 11:24












As I am seeing you have two tables and both table have column awb so whenever you insert record in orders table then you have to insert awb in orders table, then you can update your ecomexpress_awb table order_id where this awb column match in ecomexpress_awb table
– F5 Buddy
Nov 21 at 11:29




As I am seeing you have two tables and both table have column awb so whenever you insert record in orders table then you have to insert awb in orders table, then you can update your ecomexpress_awb table order_id where this awb column match in ecomexpress_awb table
– F5 Buddy
Nov 21 at 11:29












Sure, i will update as you suggest, please give me updated code for this....
– vickey colors
Nov 21 at 11:31






Sure, i will update as you suggest, please give me updated code for this....
– vickey colors
Nov 21 at 11:31















1














Add one more field in your your button form in Track.php :



echo "<form method='post' action='call.php'>";
echo "<input type ='hidden' name='id' value='$id'>
<input type ='hidden' name='order_id' value='".$row['order_id']."'>
<input type ='hidden' name='awb' value='".$row['awb']."'>
<input type='submit'>
</form>";


and then update your update query in call.php :



if(isset($_POST['order_id'], $_POST['awb'])
&& !empty($_POST['order_id'])
&& !empty($_POST['awb'])){
$con = mysqli_connect("localhost","root","","do_management4");
$awb = $_POST['awb'];
$order_id = $_POST['order_id'];
$sql = $con->query("update ecomexpress_awb set orderid = '".$order_id."' WHERE awb ='".$awb."'");
mysqli_close($con);
}





share|improve this answer























  • Thanks, i will check it now....
    – vickey colors
    Nov 21 at 12:28










  • Why awb column is blank in your orders table? It should have some value.
    – Shail Paras
    Nov 21 at 12:34










  • once i inserted other values in order table, than only i need to insert awb column value......
    – vickey colors
    Nov 21 at 12:36










  • so at the time of inserting row in order table, i din't have awb column values, so i kept it blank......
    – vickey colors
    Nov 21 at 12:36










  • Ok. If you are doing the both insert at the same time, you need to update awb column in Orders table also just after you add data in awb table.
    – Shail Paras
    Nov 21 at 12:43


















1














Add one more field in your your button form in Track.php :



echo "<form method='post' action='call.php'>";
echo "<input type ='hidden' name='id' value='$id'>
<input type ='hidden' name='order_id' value='".$row['order_id']."'>
<input type ='hidden' name='awb' value='".$row['awb']."'>
<input type='submit'>
</form>";


and then update your update query in call.php :



if(isset($_POST['order_id'], $_POST['awb'])
&& !empty($_POST['order_id'])
&& !empty($_POST['awb'])){
$con = mysqli_connect("localhost","root","","do_management4");
$awb = $_POST['awb'];
$order_id = $_POST['order_id'];
$sql = $con->query("update ecomexpress_awb set orderid = '".$order_id."' WHERE awb ='".$awb."'");
mysqli_close($con);
}





share|improve this answer























  • Thanks, i will check it now....
    – vickey colors
    Nov 21 at 12:28










  • Why awb column is blank in your orders table? It should have some value.
    – Shail Paras
    Nov 21 at 12:34










  • once i inserted other values in order table, than only i need to insert awb column value......
    – vickey colors
    Nov 21 at 12:36










  • so at the time of inserting row in order table, i din't have awb column values, so i kept it blank......
    – vickey colors
    Nov 21 at 12:36










  • Ok. If you are doing the both insert at the same time, you need to update awb column in Orders table also just after you add data in awb table.
    – Shail Paras
    Nov 21 at 12:43
















1












1








1






Add one more field in your your button form in Track.php :



echo "<form method='post' action='call.php'>";
echo "<input type ='hidden' name='id' value='$id'>
<input type ='hidden' name='order_id' value='".$row['order_id']."'>
<input type ='hidden' name='awb' value='".$row['awb']."'>
<input type='submit'>
</form>";


and then update your update query in call.php :



if(isset($_POST['order_id'], $_POST['awb'])
&& !empty($_POST['order_id'])
&& !empty($_POST['awb'])){
$con = mysqli_connect("localhost","root","","do_management4");
$awb = $_POST['awb'];
$order_id = $_POST['order_id'];
$sql = $con->query("update ecomexpress_awb set orderid = '".$order_id."' WHERE awb ='".$awb."'");
mysqli_close($con);
}





share|improve this answer














Add one more field in your your button form in Track.php :



echo "<form method='post' action='call.php'>";
echo "<input type ='hidden' name='id' value='$id'>
<input type ='hidden' name='order_id' value='".$row['order_id']."'>
<input type ='hidden' name='awb' value='".$row['awb']."'>
<input type='submit'>
</form>";


and then update your update query in call.php :



if(isset($_POST['order_id'], $_POST['awb'])
&& !empty($_POST['order_id'])
&& !empty($_POST['awb'])){
$con = mysqli_connect("localhost","root","","do_management4");
$awb = $_POST['awb'];
$order_id = $_POST['order_id'];
$sql = $con->query("update ecomexpress_awb set orderid = '".$order_id."' WHERE awb ='".$awb."'");
mysqli_close($con);
}






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 21 at 12:31

























answered Nov 21 at 12:24









Shail Paras

8521027




8521027












  • Thanks, i will check it now....
    – vickey colors
    Nov 21 at 12:28










  • Why awb column is blank in your orders table? It should have some value.
    – Shail Paras
    Nov 21 at 12:34










  • once i inserted other values in order table, than only i need to insert awb column value......
    – vickey colors
    Nov 21 at 12:36










  • so at the time of inserting row in order table, i din't have awb column values, so i kept it blank......
    – vickey colors
    Nov 21 at 12:36










  • Ok. If you are doing the both insert at the same time, you need to update awb column in Orders table also just after you add data in awb table.
    – Shail Paras
    Nov 21 at 12:43




















  • Thanks, i will check it now....
    – vickey colors
    Nov 21 at 12:28










  • Why awb column is blank in your orders table? It should have some value.
    – Shail Paras
    Nov 21 at 12:34










  • once i inserted other values in order table, than only i need to insert awb column value......
    – vickey colors
    Nov 21 at 12:36










  • so at the time of inserting row in order table, i din't have awb column values, so i kept it blank......
    – vickey colors
    Nov 21 at 12:36










  • Ok. If you are doing the both insert at the same time, you need to update awb column in Orders table also just after you add data in awb table.
    – Shail Paras
    Nov 21 at 12:43


















Thanks, i will check it now....
– vickey colors
Nov 21 at 12:28




Thanks, i will check it now....
– vickey colors
Nov 21 at 12:28












Why awb column is blank in your orders table? It should have some value.
– Shail Paras
Nov 21 at 12:34




Why awb column is blank in your orders table? It should have some value.
– Shail Paras
Nov 21 at 12:34












once i inserted other values in order table, than only i need to insert awb column value......
– vickey colors
Nov 21 at 12:36




once i inserted other values in order table, than only i need to insert awb column value......
– vickey colors
Nov 21 at 12:36












so at the time of inserting row in order table, i din't have awb column values, so i kept it blank......
– vickey colors
Nov 21 at 12:36




so at the time of inserting row in order table, i din't have awb column values, so i kept it blank......
– vickey colors
Nov 21 at 12:36












Ok. If you are doing the both insert at the same time, you need to update awb column in Orders table also just after you add data in awb table.
– Shail Paras
Nov 21 at 12:43






Ok. If you are doing the both insert at the same time, you need to update awb column in Orders table also just after you add data in awb table.
– Shail Paras
Nov 21 at 12:43




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53410035%2fhow-to-update-table-onclick-button-in-php-page%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

404 Error Contact Form 7 ajax form submitting

How to know if a Active Directory user can login interactively

TypeError: fit_transform() missing 1 required positional argument: 'X'