Mysql database updates but my table in php html won't update even if I refresh
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I have code that search for my field name(familycode) then displays a table. I have the code enclosed in the table to update table and database.
My issue - after updating - My display information does't update and won't refresh or ever show correct data from mysql database. Database is updated.
I am new and this is first post. I tried many many different ways no luck. I would appreciate some thoughts!! Thank you!
my code for main page d7.php
<?php
// connection
$dbcon= NEW Mysqli("localhost", "root", "", "xxx");
if (!$dbcon) {
echo " ----------Error connecting to database--------------";
}
else {
echo " ----------Connected to Database Successfully----------- <br>" ;
}
include 'updatedata.php';
?>
<html>
<head>
<title> View_Update Family</title>
<link rel="stylesheet" type="text/css" href="d7css.css">
</head>
<body>
<form action=d7.php method=post>
<input type="text" name="valueToSearchfamily" placeholder="Family To
Search"><br><br>
<input type="submit" name="searchfamily" value="Search Family"><br>
<br>
</form>
<?php
if(isset($_POST['searchfamily']))
{
$valueToSearchfamily=$_POST['valueToSearchfamily'];
// search in all table columns
$select = "SELECT * FROM families WHERE Familycode LIKE
'%".$valueToSearchfamily."%' ";
$mydata=mysqli_query($dbcon, $select);
}
else {
$notselect = "SELECT * FROM families ORDER BY Familycode ";
$mydata=mysqli_query($dbcon, $notselect);
}
echo "<table class='updatetable' >";
echo "<tr>
<th>Id</th>
<th>Familycode</th>
<th>Name</th>
<th>Street</th>
<th>City</th>
<th>State</th>
<th>Zip</th>
</tr>";
while($record = mysqli_fetch_array($mydata)){
echo "<form action=updatedata.php method=post>";
echo "<tr>";
echo "<td>" . "<input type=text name=aid value=" . $record['Aid'] .
" </td>";
echo "<td>" . "<input type=text name=familycode value=" .
$record['Familycode'] . " </td>";
echo "<td>" . "<input type=text name=name_mailing value=" .
$record['Name_mailing'] . " </td>";
echo "<td>" . "<input type=text name=street_mailing value=" .
$record['Street_mailing'] . " </td>";
echo "<td>" . "<input type=text name=city_mailing value=" .
$record['City_mailing'] . " </td>";
echo "<td>" . "<input type=text name=st_mailing value=" .
$record['St_mailing'] . " </td>";
echo "<td>" . "<input type=text name=zip_mailing value=" .
$record['Zip_mailing'] . " </td>";
echo "<td>" . "<input type=hidden name=hidden value=" .
$record['Aid'] . " </td>";
echo "<td>" . "<input type=submit name=update value=update" . "
</td>";
echo "</form>";
};
?>
</body>
</html>
my other file as I tried separating them is updatedata.php
<?php
// connection
$dbcon= NEW Mysqli("localhost", "root", "", "xxx");
if (!$dbcon) {
echo " ----------Error connecting to database--------------";
}
else {
echo " ----------Connected to Database Successfully----------- <br>" ;
}
// ==========================================================
if(isset($_POST['update'])) {
$updatequery="UPDATE families SET Aid='$_POST[aid]',
Familycode='$_POST[familycode]', Name_mailing='$_POST[name_mailing]',
Street_mailing='$_POST[street_mailing]',
City_mailing='$_POST[city_mailing]', St_mailing='$_POST[st_mailing]',
Zip_mailing='$_POST[zip_mailing]' WHERE Aid='$_POST[hidden]'";
mysqli_query($dbcon, $updatequery);
header("location: index_dir.php");
};
?>
php database
add a comment |
I have code that search for my field name(familycode) then displays a table. I have the code enclosed in the table to update table and database.
My issue - after updating - My display information does't update and won't refresh or ever show correct data from mysql database. Database is updated.
I am new and this is first post. I tried many many different ways no luck. I would appreciate some thoughts!! Thank you!
my code for main page d7.php
<?php
// connection
$dbcon= NEW Mysqli("localhost", "root", "", "xxx");
if (!$dbcon) {
echo " ----------Error connecting to database--------------";
}
else {
echo " ----------Connected to Database Successfully----------- <br>" ;
}
include 'updatedata.php';
?>
<html>
<head>
<title> View_Update Family</title>
<link rel="stylesheet" type="text/css" href="d7css.css">
</head>
<body>
<form action=d7.php method=post>
<input type="text" name="valueToSearchfamily" placeholder="Family To
Search"><br><br>
<input type="submit" name="searchfamily" value="Search Family"><br>
<br>
</form>
<?php
if(isset($_POST['searchfamily']))
{
$valueToSearchfamily=$_POST['valueToSearchfamily'];
// search in all table columns
$select = "SELECT * FROM families WHERE Familycode LIKE
'%".$valueToSearchfamily."%' ";
$mydata=mysqli_query($dbcon, $select);
}
else {
$notselect = "SELECT * FROM families ORDER BY Familycode ";
$mydata=mysqli_query($dbcon, $notselect);
}
echo "<table class='updatetable' >";
echo "<tr>
<th>Id</th>
<th>Familycode</th>
<th>Name</th>
<th>Street</th>
<th>City</th>
<th>State</th>
<th>Zip</th>
</tr>";
while($record = mysqli_fetch_array($mydata)){
echo "<form action=updatedata.php method=post>";
echo "<tr>";
echo "<td>" . "<input type=text name=aid value=" . $record['Aid'] .
" </td>";
echo "<td>" . "<input type=text name=familycode value=" .
$record['Familycode'] . " </td>";
echo "<td>" . "<input type=text name=name_mailing value=" .
$record['Name_mailing'] . " </td>";
echo "<td>" . "<input type=text name=street_mailing value=" .
$record['Street_mailing'] . " </td>";
echo "<td>" . "<input type=text name=city_mailing value=" .
$record['City_mailing'] . " </td>";
echo "<td>" . "<input type=text name=st_mailing value=" .
$record['St_mailing'] . " </td>";
echo "<td>" . "<input type=text name=zip_mailing value=" .
$record['Zip_mailing'] . " </td>";
echo "<td>" . "<input type=hidden name=hidden value=" .
$record['Aid'] . " </td>";
echo "<td>" . "<input type=submit name=update value=update" . "
</td>";
echo "</form>";
};
?>
</body>
</html>
my other file as I tried separating them is updatedata.php
<?php
// connection
$dbcon= NEW Mysqli("localhost", "root", "", "xxx");
if (!$dbcon) {
echo " ----------Error connecting to database--------------";
}
else {
echo " ----------Connected to Database Successfully----------- <br>" ;
}
// ==========================================================
if(isset($_POST['update'])) {
$updatequery="UPDATE families SET Aid='$_POST[aid]',
Familycode='$_POST[familycode]', Name_mailing='$_POST[name_mailing]',
Street_mailing='$_POST[street_mailing]',
City_mailing='$_POST[city_mailing]', St_mailing='$_POST[st_mailing]',
Zip_mailing='$_POST[zip_mailing]' WHERE Aid='$_POST[hidden]'";
mysqli_query($dbcon, $updatequery);
header("location: index_dir.php");
};
?>
php database
add a comment |
I have code that search for my field name(familycode) then displays a table. I have the code enclosed in the table to update table and database.
My issue - after updating - My display information does't update and won't refresh or ever show correct data from mysql database. Database is updated.
I am new and this is first post. I tried many many different ways no luck. I would appreciate some thoughts!! Thank you!
my code for main page d7.php
<?php
// connection
$dbcon= NEW Mysqli("localhost", "root", "", "xxx");
if (!$dbcon) {
echo " ----------Error connecting to database--------------";
}
else {
echo " ----------Connected to Database Successfully----------- <br>" ;
}
include 'updatedata.php';
?>
<html>
<head>
<title> View_Update Family</title>
<link rel="stylesheet" type="text/css" href="d7css.css">
</head>
<body>
<form action=d7.php method=post>
<input type="text" name="valueToSearchfamily" placeholder="Family To
Search"><br><br>
<input type="submit" name="searchfamily" value="Search Family"><br>
<br>
</form>
<?php
if(isset($_POST['searchfamily']))
{
$valueToSearchfamily=$_POST['valueToSearchfamily'];
// search in all table columns
$select = "SELECT * FROM families WHERE Familycode LIKE
'%".$valueToSearchfamily."%' ";
$mydata=mysqli_query($dbcon, $select);
}
else {
$notselect = "SELECT * FROM families ORDER BY Familycode ";
$mydata=mysqli_query($dbcon, $notselect);
}
echo "<table class='updatetable' >";
echo "<tr>
<th>Id</th>
<th>Familycode</th>
<th>Name</th>
<th>Street</th>
<th>City</th>
<th>State</th>
<th>Zip</th>
</tr>";
while($record = mysqli_fetch_array($mydata)){
echo "<form action=updatedata.php method=post>";
echo "<tr>";
echo "<td>" . "<input type=text name=aid value=" . $record['Aid'] .
" </td>";
echo "<td>" . "<input type=text name=familycode value=" .
$record['Familycode'] . " </td>";
echo "<td>" . "<input type=text name=name_mailing value=" .
$record['Name_mailing'] . " </td>";
echo "<td>" . "<input type=text name=street_mailing value=" .
$record['Street_mailing'] . " </td>";
echo "<td>" . "<input type=text name=city_mailing value=" .
$record['City_mailing'] . " </td>";
echo "<td>" . "<input type=text name=st_mailing value=" .
$record['St_mailing'] . " </td>";
echo "<td>" . "<input type=text name=zip_mailing value=" .
$record['Zip_mailing'] . " </td>";
echo "<td>" . "<input type=hidden name=hidden value=" .
$record['Aid'] . " </td>";
echo "<td>" . "<input type=submit name=update value=update" . "
</td>";
echo "</form>";
};
?>
</body>
</html>
my other file as I tried separating them is updatedata.php
<?php
// connection
$dbcon= NEW Mysqli("localhost", "root", "", "xxx");
if (!$dbcon) {
echo " ----------Error connecting to database--------------";
}
else {
echo " ----------Connected to Database Successfully----------- <br>" ;
}
// ==========================================================
if(isset($_POST['update'])) {
$updatequery="UPDATE families SET Aid='$_POST[aid]',
Familycode='$_POST[familycode]', Name_mailing='$_POST[name_mailing]',
Street_mailing='$_POST[street_mailing]',
City_mailing='$_POST[city_mailing]', St_mailing='$_POST[st_mailing]',
Zip_mailing='$_POST[zip_mailing]' WHERE Aid='$_POST[hidden]'";
mysqli_query($dbcon, $updatequery);
header("location: index_dir.php");
};
?>
php database
I have code that search for my field name(familycode) then displays a table. I have the code enclosed in the table to update table and database.
My issue - after updating - My display information does't update and won't refresh or ever show correct data from mysql database. Database is updated.
I am new and this is first post. I tried many many different ways no luck. I would appreciate some thoughts!! Thank you!
my code for main page d7.php
<?php
// connection
$dbcon= NEW Mysqli("localhost", "root", "", "xxx");
if (!$dbcon) {
echo " ----------Error connecting to database--------------";
}
else {
echo " ----------Connected to Database Successfully----------- <br>" ;
}
include 'updatedata.php';
?>
<html>
<head>
<title> View_Update Family</title>
<link rel="stylesheet" type="text/css" href="d7css.css">
</head>
<body>
<form action=d7.php method=post>
<input type="text" name="valueToSearchfamily" placeholder="Family To
Search"><br><br>
<input type="submit" name="searchfamily" value="Search Family"><br>
<br>
</form>
<?php
if(isset($_POST['searchfamily']))
{
$valueToSearchfamily=$_POST['valueToSearchfamily'];
// search in all table columns
$select = "SELECT * FROM families WHERE Familycode LIKE
'%".$valueToSearchfamily."%' ";
$mydata=mysqli_query($dbcon, $select);
}
else {
$notselect = "SELECT * FROM families ORDER BY Familycode ";
$mydata=mysqli_query($dbcon, $notselect);
}
echo "<table class='updatetable' >";
echo "<tr>
<th>Id</th>
<th>Familycode</th>
<th>Name</th>
<th>Street</th>
<th>City</th>
<th>State</th>
<th>Zip</th>
</tr>";
while($record = mysqli_fetch_array($mydata)){
echo "<form action=updatedata.php method=post>";
echo "<tr>";
echo "<td>" . "<input type=text name=aid value=" . $record['Aid'] .
" </td>";
echo "<td>" . "<input type=text name=familycode value=" .
$record['Familycode'] . " </td>";
echo "<td>" . "<input type=text name=name_mailing value=" .
$record['Name_mailing'] . " </td>";
echo "<td>" . "<input type=text name=street_mailing value=" .
$record['Street_mailing'] . " </td>";
echo "<td>" . "<input type=text name=city_mailing value=" .
$record['City_mailing'] . " </td>";
echo "<td>" . "<input type=text name=st_mailing value=" .
$record['St_mailing'] . " </td>";
echo "<td>" . "<input type=text name=zip_mailing value=" .
$record['Zip_mailing'] . " </td>";
echo "<td>" . "<input type=hidden name=hidden value=" .
$record['Aid'] . " </td>";
echo "<td>" . "<input type=submit name=update value=update" . "
</td>";
echo "</form>";
};
?>
</body>
</html>
my other file as I tried separating them is updatedata.php
<?php
// connection
$dbcon= NEW Mysqli("localhost", "root", "", "xxx");
if (!$dbcon) {
echo " ----------Error connecting to database--------------";
}
else {
echo " ----------Connected to Database Successfully----------- <br>" ;
}
// ==========================================================
if(isset($_POST['update'])) {
$updatequery="UPDATE families SET Aid='$_POST[aid]',
Familycode='$_POST[familycode]', Name_mailing='$_POST[name_mailing]',
Street_mailing='$_POST[street_mailing]',
City_mailing='$_POST[city_mailing]', St_mailing='$_POST[st_mailing]',
Zip_mailing='$_POST[zip_mailing]' WHERE Aid='$_POST[hidden]'";
mysqli_query($dbcon, $updatequery);
header("location: index_dir.php");
};
?>
php database
php database
asked Nov 17 '18 at 4:39
Don TDon T
82
82
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Welcome Don T to stackoverflow! It seems like your echoing onto the page in an instance, recall that when you Echo something out, it doesn't change when it changes inside your database because you aren't making the call again, its on the same page. To fix this, you need to use Javascript + Ajax, I recommend picking up jQuery and harnessing its basics for POST'ing and GET'ing data from a PHP page.
Here is the link for jQuery Ajax: http://api.jquery.com/jquery.ajax/
Simple example using jQuery ajax:
$.ajax({
url: 'PHP SCRIPT PAGE URL',
method: 'POST', // Your sending data, use POST
data: 'Your Data!', // This can be also be a form object
success: function(response) { // Response is your PHP scripts answer to this request.
console.log(response); // You may Echo or use JSON format as a response.
} // If you use JSON, add dataType: 'JSON' in the ajax call to the left.
})
Remember if this answer has helped you resolve your issue, select it as the Answer!
Thanks!
1
GrandIQ -Thank you for pointing me in the right direction!!! I believe I am getting there. Thanks
– Don T
Nov 17 '18 at 19:22
My pleasure to help!
– GrandIQ
Nov 18 '18 at 1:43
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53348268%2fmysql-database-updates-but-my-table-in-php-html-wont-update-even-if-i-refresh%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Welcome Don T to stackoverflow! It seems like your echoing onto the page in an instance, recall that when you Echo something out, it doesn't change when it changes inside your database because you aren't making the call again, its on the same page. To fix this, you need to use Javascript + Ajax, I recommend picking up jQuery and harnessing its basics for POST'ing and GET'ing data from a PHP page.
Here is the link for jQuery Ajax: http://api.jquery.com/jquery.ajax/
Simple example using jQuery ajax:
$.ajax({
url: 'PHP SCRIPT PAGE URL',
method: 'POST', // Your sending data, use POST
data: 'Your Data!', // This can be also be a form object
success: function(response) { // Response is your PHP scripts answer to this request.
console.log(response); // You may Echo or use JSON format as a response.
} // If you use JSON, add dataType: 'JSON' in the ajax call to the left.
})
Remember if this answer has helped you resolve your issue, select it as the Answer!
Thanks!
1
GrandIQ -Thank you for pointing me in the right direction!!! I believe I am getting there. Thanks
– Don T
Nov 17 '18 at 19:22
My pleasure to help!
– GrandIQ
Nov 18 '18 at 1:43
add a comment |
Welcome Don T to stackoverflow! It seems like your echoing onto the page in an instance, recall that when you Echo something out, it doesn't change when it changes inside your database because you aren't making the call again, its on the same page. To fix this, you need to use Javascript + Ajax, I recommend picking up jQuery and harnessing its basics for POST'ing and GET'ing data from a PHP page.
Here is the link for jQuery Ajax: http://api.jquery.com/jquery.ajax/
Simple example using jQuery ajax:
$.ajax({
url: 'PHP SCRIPT PAGE URL',
method: 'POST', // Your sending data, use POST
data: 'Your Data!', // This can be also be a form object
success: function(response) { // Response is your PHP scripts answer to this request.
console.log(response); // You may Echo or use JSON format as a response.
} // If you use JSON, add dataType: 'JSON' in the ajax call to the left.
})
Remember if this answer has helped you resolve your issue, select it as the Answer!
Thanks!
1
GrandIQ -Thank you for pointing me in the right direction!!! I believe I am getting there. Thanks
– Don T
Nov 17 '18 at 19:22
My pleasure to help!
– GrandIQ
Nov 18 '18 at 1:43
add a comment |
Welcome Don T to stackoverflow! It seems like your echoing onto the page in an instance, recall that when you Echo something out, it doesn't change when it changes inside your database because you aren't making the call again, its on the same page. To fix this, you need to use Javascript + Ajax, I recommend picking up jQuery and harnessing its basics for POST'ing and GET'ing data from a PHP page.
Here is the link for jQuery Ajax: http://api.jquery.com/jquery.ajax/
Simple example using jQuery ajax:
$.ajax({
url: 'PHP SCRIPT PAGE URL',
method: 'POST', // Your sending data, use POST
data: 'Your Data!', // This can be also be a form object
success: function(response) { // Response is your PHP scripts answer to this request.
console.log(response); // You may Echo or use JSON format as a response.
} // If you use JSON, add dataType: 'JSON' in the ajax call to the left.
})
Remember if this answer has helped you resolve your issue, select it as the Answer!
Thanks!
Welcome Don T to stackoverflow! It seems like your echoing onto the page in an instance, recall that when you Echo something out, it doesn't change when it changes inside your database because you aren't making the call again, its on the same page. To fix this, you need to use Javascript + Ajax, I recommend picking up jQuery and harnessing its basics for POST'ing and GET'ing data from a PHP page.
Here is the link for jQuery Ajax: http://api.jquery.com/jquery.ajax/
Simple example using jQuery ajax:
$.ajax({
url: 'PHP SCRIPT PAGE URL',
method: 'POST', // Your sending data, use POST
data: 'Your Data!', // This can be also be a form object
success: function(response) { // Response is your PHP scripts answer to this request.
console.log(response); // You may Echo or use JSON format as a response.
} // If you use JSON, add dataType: 'JSON' in the ajax call to the left.
})
Remember if this answer has helped you resolve your issue, select it as the Answer!
Thanks!
edited Nov 17 '18 at 5:31
answered Nov 17 '18 at 5:26
GrandIQGrandIQ
541311
541311
1
GrandIQ -Thank you for pointing me in the right direction!!! I believe I am getting there. Thanks
– Don T
Nov 17 '18 at 19:22
My pleasure to help!
– GrandIQ
Nov 18 '18 at 1:43
add a comment |
1
GrandIQ -Thank you for pointing me in the right direction!!! I believe I am getting there. Thanks
– Don T
Nov 17 '18 at 19:22
My pleasure to help!
– GrandIQ
Nov 18 '18 at 1:43
1
1
GrandIQ -Thank you for pointing me in the right direction!!! I believe I am getting there. Thanks
– Don T
Nov 17 '18 at 19:22
GrandIQ -Thank you for pointing me in the right direction!!! I believe I am getting there. Thanks
– Don T
Nov 17 '18 at 19:22
My pleasure to help!
– GrandIQ
Nov 18 '18 at 1:43
My pleasure to help!
– GrandIQ
Nov 18 '18 at 1:43
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53348268%2fmysql-database-updates-but-my-table-in-php-html-wont-update-even-if-i-refresh%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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