SQL Update unable to work - php

I have a SQL update below and there's no error but it doesn't reflect any changes I have made to the database. I also paste here the 2 previous php which will lead to the update php. SQL query for UPDATE shows no error too.
Please let me know if i miss out anything.
Appreciate it very much.
table 1: nmc_cd
table 2: nmc_category
table 3: nmc_publisher
This is the php to display the list of CDs and the key here is the CDID which once selected will be sent to the next php.
include 'database_conn.php'; //make db connection
$sql = "SELECT nmc_cd.CDID, nmc_cd.CDTitle, nmc_cd.CDYear, nmc_cd.CDPrice, nmc_category.catDesc, nmc_cd.catID
FROM nmc_cd
LEFT JOIN nmc_category ON nmc_cd.catID=nmc_category.catID";
$queryresult = mysqli_query($conn, $sql)
or die (mysqli_error($conn));
echo'<table cellpadding="0" cellspacing="0" class="db-table" table align="center">';
echo"<tr><th>Music Title</th><th>Year</th><th>Price</th><th>Category</th></tr>";
while($row = mysqli_fetch_assoc($queryresult)) {
$iCDID = $row['CDID'];
$CDTitle = $row['CDTitle'];
$CDYear = $row['CDYear'];
$CDPrice = $row['CDPrice'];
$CDCat = $row['catDesc'];
$CDCatID = $row['catID'];
echo "<tr><td>";
echo "$CDTitle";
echo "</td><td>";
echo "<div align='center'>$CDYear</div>\n";
echo "</td><td>";
echo "<div align='center'>$CDPrice </div>\n";
echo "</td><td>";
echo "<div align='center'>$CDCat</div>\n";
echo "</TD></tr>";
}
echo "</table>";
mysqli_free_result($queryresult);
mysqli_close($conn);
?>
In this php it display the selected CD and editing is permitted
<?php
header('Content-type: text/html; charset=iso-8859-1'); //set the charset parameter
include 'database_conn.php'; //make db connection
$code = $_GET['itemCode']; //collect form data from user input
$sql = "SELECT nmc_cd.CDID, nmc_cd.CDTitle, nmc_cd.CDYear, nmc_cd.CDPrice, nmc_cd.catID, nmc_cd.pubID, nmc_category.catDesc, nmc_publisher.pubID, nmc_publisher.pubName
FROM nmc_cd
JOIN nmc_category on (nmc_cd.catID = nmc_category.catID)
JOIN nmc_publisher on (nmc_cd.pubID = nmc_publisher.pubID)
WHERE nmc_cd.CDID = '$code'"; //link user input with primary key
$queryresult = mysqli_query($conn, $sql)
or die (mysqli_error($conn));
$row = mysqli_fetch_assoc($queryresult); //function fetches result row
$iCDID = $row['CDID'];
$CDTitle = $row['CDTitle'];
$CDYear = $row['CDYear'];
$CDPrice = $row['CDPrice'];
$CDCat = $row['catDesc'];
$CDPub = $row['pubName'];
$CDpubID = $row['pubID'];
<form method="get" action="UpdateCD.php">
<div align="center">
<div>Title <input type = "text" name = "CDTitle" value = "<?php echo $CDTitle; ?>" /></div></br>
<div>Year <input type = "text" name = "CDYear" value = "<?php echo $CDYear; ?>" /></div></br>
<div>Price <input type = "text" name = "CDPrice" value = "<?php echo $CDPrice; ?>" /></div></br>
Category
<select name="CDCat">
<option value= " ">
<?php
include 'database_conn.php'; //make db connection
if (! ( is_object($conn ) && ( get_class( $conn ) == 'mysqli' ))) {
die("DB connection failure.");
}
$rsCDCat = mysqli_query($conn, "SELECT nmc_category.catDesc FROM nmc_category");
if ( !$rsCDCat ) {
die("No result from DB query."); //probably invalid SQL, table error
}
if ( $rsCDCat->num_rows < 1 ) {
die("No rows returned from DB query."); //query runs but nothing is found in DB to match
}
while($Catcatresult = mysqli_fetch_array($rsCDCat)){
$optioncat = "<option value='{$Catcatresult[0]}'";
if($Catcatresult[0] == $CDCat){
$optioncat .= " selected='selected'";
}
$optioncat .= ">{$Catcatresult[0]}</option>";
echo $optioncat;
}
?>
</select></br></br>
Publisher
<select name="CDPub">
<option value= " ">
<?php
include 'database_conn.php'; //make db connection
if (! ( is_object($conn ) && ( get_class( $conn ) == 'mysqli' ))) {
die("DB connection failure.");
}
$rsCDpub = mysqli_query($conn, "SELECT nmc_publisher.pubName FROM nmc_publisher");
if ( !$rsCDpub ) {
die("No result from DB query."); //probably invalid SQL, table error
}
if ( $rsCDpub->num_rows < 1 ) {
die("No rows returned from DB query."); //query runs but nothing is found in DB to match
}
while($Catpubresult = mysqli_fetch_array($rsCDpub)){
$option = "<option value='{$Catpubresult[0]}'";
if($Catpubresult[0] == $CDPub){
$option .= " selected='selected'";
}
$option .= ">{$Catpubresult[0]}</option>";
echo $option;
}
?></select></br></br>
<div><input type="submit" value="Update"></div>
</form>
In this update php, it gets the values from the previous php and update the table.
<?php
header('Content-type: text/html; charset=iso-8859-1');
include 'database_conn.php'; // make db connection
$pCDTitle = filter_has_var(INPUT_GET, 'CDTitle') ? $_GET['CDTitle']: null; // store all parameter in variable
$pCDPubName = filter_has_var(INPUT_GET, 'CDPub') ? $_GET['CDPub']: null;
$pCDYear = filter_has_var(INPUT_GET, 'CDYear') ? $_GET['CDYear']: null;
$pCDCategory = filter_has_var(INPUT_GET, 'CDCat') ? $_GET['CDCat']: null;
$pCDPrice = filter_has_var(INPUT_GET, 'CDPrice') ? $_GET['CDPrice']: null;
$pCDID = filter_has_var(INPUT_GET, 'CDID') ? $_GET['CDID']: null;
$pCDPubID = filter_has_var(INPUT_GET, 'pubID') ? $_GET['pubID']: null;
$sql = "UPDATE nmc_cd "
. "SET nmc_cd.CDTitle='$pCDTitle',nmc_cd.CDYear='$pCDYear',nmc_cd.CDPrice='$pCDPrice',nmc_cd.catID='$pCDCategory',nmc_cd.pubID='$pCDPubName'"
. "WHERE nmc_cd.CDID='$pCDID'";
if ($conn->query($sql) === TRUE) {
echo "<b><font face='verdana' font sise='3' color='red'>Record updated successfully</font></b>";
$sql = "SELECT * FROM nmc_cd "
. "JOIN nmc_category ON (nmc_cd.catID = nmc_category.catID)"
. "JOIN nmc_publisher ON (nmc_cd.pubID = nmc_publisher.pubID)"
. "WHERE nmc_cd.CDID = '$pCDID'"; //Query Database
$result = mysqli_query($conn, $sql);
$row = mysqli_fetch_assoc($result);
$CDID = $row['CDID'];
$CDTitle = $row['CDTitle'];
$CDYear = $row['CDYear'];
$CDPrice = $row['CDPrice'];
$catDesc = $row['CDCat'];
$pubName = $row['CDPub'];
$location = $row['location'];
echo "<table>";
echo "<tr><th>Title</th><th>Year</th><th>Price</th><th>Catergory</th><th>Publisher</th><th>Location</th></tr>";
echo "<tr><td>".$row["CDTitle"]."</td><td> ".$row["CDYear"]."</td><td> ".$row["CDPrice"]."</td><td> ".$row["CatCD"]."</td><td> ".$row["CatPub"]."</td><td> ".$row["location"]."</td></tr>"; //Display Data Table Data
echo "</table";
mysqli_close($conn);
} else {
echo "<b><font face='verdana' color='red'>Error updating record!!!</font></b>" . $conn->error;
}
?>

$sql = "UPDATE nmc_cd "
. "SET nmc_cd.CDTitle='$pCDTitle',nmc_cd.CDYear='$pCDYear',nmc_cd.CDPrice='$pCDPrice',nmc_cd.catID='$pCDCategory',nmc_cd.pubID='$pCDPubName'"
. "WHERE nmc_cd.CDID='$pCDID'";
Should be:
$sql = "UPDATE nmc_cd "
. "SET nmc_cd.CDTitle='$pCDTitle',nmc_cd.CDYear='$pCDYear',nmc_cd.CDPrice='$pCDPrice',nmc_cd.catID='$pCDCategory',nmc_cd.pubID='$pCDPubName' "
. "WHERE nmc_cd.CDID='$pCDID'";
i.e. You are missing a SPACE character before the WHERE Clause.
(Note the end of 2nd line)

Look in the MySql logs. Make sure bad queries are logged to the file and you should see the syntax error. The other thing you can do is dump out the $sql string and run that in MySQL. See if it runs successfully or not.

Related

SELECT 2 Identical databases to get 2 website orders on one list

I'm trying to connect two databases into a mysql query and it's also great!
After that, I try to find data on the order in the correct database to get meta_value from it.
But it mixes meta_value $ first name and sometimes duplicates them on the rows.
If I just conect 1 database, they will come out as they should
Anybody can see what goes wrong?
Url to example: https:// http://kundeservice.coalsmile.com/test4.php
<?php
$servername = "xxx";
$username = "xxx";
$password = "xxx";
$v1 = "coalsmil_wp282";
$v2 = "coalsmil_wp111";
$v3 = "coalsmil_wp72";
$v4 = "coalsmil_wp193";
$v5 = "coalsmil_wp555";
$v6 = "coalsmil_wp366";
$v7 = "coalsmil_wp74";
$v8 = "coalsmil_wp721";
$v9 = "coalsmil_wp924";
$v10 = "coalsmil_wp253";
// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
//Here I connect to both databases
$query103 = mysqli_query($conn, "SELECT * FROM `$v1`.`wpd2_posts`
where post_status='wc-processing' or post_status='wc-completed'
or post_status='wc-failed' UNION
SELECT * FROM `$v2`.`wpd2_posts`
where post_status='wc-processing' or post_status='wc-completed'
or post_status='wc-failed' order by post_date DESC ") or die(mysqli_error($conn));
?>
<br>
<h2>Database 3</h2>
<table style="width: 100%">
<tr>
<td>ID</td>
<td>??</td>
<td>??</td>
<td>??</td>
<td>??</td>
<td>??</td>
</tr>
<?php
while($row = mysqli_fetch_array($query103))
{
// Here I try to find what database the customer is on
$id2 = $row['ID'];
if($row['ID'] == ''){
echo "intet id";
}else {
$query = mysqli_query($conn, "SELECT * FROM `$v1`.`wpd2_posts` where ID = '$id2' ORDER BY id") or die(mysqli_error($conn));
if(mysqli_num_rows($query) == '') {
$query = mysqli_query($conn, "SELECT * FROM `$v2`.`wpd2_posts` where ID = '$id2' ORDER BY id") or die(mysqli_error($conn));
if(mysqli_num_rows($query) == '') {
}else{
$version = "coalsmil_wp111";
}
}else{
$version = "coalsmil_wp282";
}
}
echo "<tr>";
echo "<td>". $row['ID']."</td>";
echo "<td>". $row['post_date']."</td>";
echo "<td>". $row['post_status']."</td>";
//And here I try to get the data out
$querynavn = mysqli_query($conn, "SELECT meta_value FROM `$version`.`wpd2_postmeta` where meta_key='_shipping_first_name' and post_id='$id2' ") or die(mysqli_error($conn));
while($row2 = mysqli_fetch_array($querynavn))
{
$fornavn = urldecode($row2['meta_value']);
}
echo "<td>". $fornavn."</td>";
echo "<td>".$version."</td>";
echo "<td>6</td>";
echo "</tr>";
}
?>
</table>
If you're connections are on the same database server you can specify the schema (database name) to select things from both over one connection. You do this by using schema_name.table_name instead of just the table's name.
So like:
SELECT * FROM schema_name.wpd2_posts WHERE ...
In your case you could use UNION to put it all together:
SELECT * FROM `schema1.wpd2_posts`
where post_status='wc-processing' or post_status='wc-completed'
or post_status='wc-failed' UNION
SELECT * FROM `schema2.wpd2_posts`
where post_status='wc-processing' or post_status='wc-completed'
or post_status='wc-failed' order by post_date DESC LIMIT 10
On a side note you could make this query a bit more readable by using the IN() clause for your critera:
WHERE post_status IN('wc-processing', 'wc-completed','wc-failed')

updating my database values through php

Hi I am trying to do a Registration that the users will put their name password and their answers to some questions and then an admin will manually answer to it if it's accepted.I did the system that loads their name password and answers in the database,and I also ran the things that will show the answers to the admin,but I can't figure a way to change a value just for one user not for all of them,I will leave you my codes and everything over here.
Here is my admin.viewapplications.php code
(Here,it shows everything fine,but I can't figure a way that the button to act just for one id not for all)
<?php
//include(__DIR__ . "/signup.php");
include("../resources/config.php");
//$name = $_POST['Name'];
//$mg = $_POST['MG'];
//$pg = $_POST['PG'];
//$rk = $_POST['RK'];
$sql = "SELECT id, name, tutorial, MG, PG, RK FROM rp_users WHERE tutorial = 2";
//$tutorial = "SELECT tutorial FROM rp_users";
$result = mysql_query($sql);
//$result2 = mysql_query($tutorial);
//$value = mysql_fetch_object($result2)
/*if($result)
{
echo "Succes";
}
else
{
die(mysql_error());
}*/
//if($value > 1)
//
while($row = mysql_fetch_array($result))
{
//$tutorial = row["tutorial"];
//f($tutorial == 2)
//}
$id = $row["id"];
$name = $row["name"];
$mg = $row["MG"];
$pg = $row["PG"];
$rk = $row["RK"];
echo "ID: " . $id."<br> <br>";
echo "Nume: " . $name."<br> <br>";
echo "MG: " . $mg."<br> <br>";
echo "PG: " . $pg."<br> <br>";
echo "RK: " . $rk."<br> <br>";
echo '<form action="./?p=applicationaccept" method="POST">';
echo '<input type="submit" name="accept" value="Accepta">';
echo '</form><br>';
echo '<form action="./?p=applicationdeny" method="POST">';
echo '<input type="submit" name="deny" value="Respinge">';
echo '</form><br> <br> <br>';
}
//}
//
?>
And here is my applicationaccept.php
<?php
include("../admin/admin.viewapplications.php");
include("../resources/config.php");
$iduser = $id;
$sql = "UPDATE rp_users SET tutorial=0";
$result = mysql_query($sql);
if($result)
{
echo "Succes";
}
else
{
die(mysql_error());
}
/*while($row = mysql_fetch_array($result))
{
}*/
?>
I think what you want to do is a simple UPDATE to your MySQL database..
but make sure you format the PHP code you're using otherwise it'll give you an ERROR!
Also you have to use 'mysqli' now in PHP!
<?php
$someID = '1';
$sql = "UPDATE `rp_users` SET `tutorial`= '0' WHERE `id` = $someID";
$result = mysqli_query($link, $sql);
if($result)
{
echo "Success";
}
else
{
echo ("Error");
}
?>
BTW I forgot to mntion the '$link' is the connection to your database!
As of my understanding of your question if your form action is applicationaccept.php and you are trying to update for one user in applicationaccept.php file, try this:
<?php
include("../admin/admin.viewapplications.php");
include("../resources/config.php");
$iduser = $_POST["id"]; // pass id as parameter in form
$sql = "UPDATE rp_users SET tutorial=0";// change this line to following line
$sql = "UPDATE rp_users SET tutorial=0 where id=$iduser";
$result = mysql_query($sql);
if($result)
{
echo "Succes";
}
else
{
die(mysql_error());
}
?>
Be aware your code is vulnerable

How to bind select dropdownlist by selected value and other values from mysql in php

I have a project in php. When I bind select dropdown list with selected value as well as all others values inside the database the one value which is as selected will bind two times, one as first selected value and other as list values.
Below is my code.
$query1 = mysql_query("select * from pincode_master where pcode_id='1'");
while ($row1 = mysql_fetch_array($query1))
{
$city_id = $row1['city_id'];
$sql1="SELECT city_name from city_master where city_id='$city_id'";
$result1=mysql_query($sql1);
$row = mysql_fetch_row($result1);
#$city_name = $row[0];
$query11 = "select * from city_master";
$result11 = mysql_query($query11);
echo "<select name = 'cityname'>";
while (($row11 = mysql_fetch_row($result11)) != null)
{
echo "<option value = '{$row11['city_name']}'";
if ($city_name == $city_name)
echo "selected = 'selected'";
echo ">{$row11['city_name']}</option>";
}
echo "</select>";
}
You should write your query outside loop.
Write your code as below:-
// Check query error
$query1 = mysql_query( "select * from pincode_master where pcode_id='1'" ) or die( mysql_error());
// Check query error
$result11 = mysql_query( "select * from city_master" ) or die( mysql_error());
while ( $row1 = mysql_fetch_assoc( $query1 ) ) {
$city_id = $row1['city_id'];
echo "<select name = 'cityname'>";
while ($row11 = mysql_fetch_assoc( $result11 )) {
$selected = $row11['city_id'] == $city_id ? "selected = 'selected'" : '';
echo "<option value = '{$row11['city_name']}' $selected >". $row11['city_name'] ."</option>";
}
echo "</select>";
}
Hope it will help you :)
Please check this -
is that what you want ?
<select name="yourselection">
<option value="">--Select--</option>
<?php
$msql = mysql_query("SELECT * FROM tablename");
while($m_row = mysql_fetch_array($msql))
echo("<option value = '" . $m_row['table_column1'] . "'>" . $m_row['table_column2'] . "</option>");
?>
</select>
you will get more info here

How to display database value in form list

I've created drop down list with value name from the database. When I select the value from the drop down list, other data will appear in other textfield based on the database. The submit process was doing fine except when I check on the list. The drop down list value didn't appear in the list but other data did.
This is my adding form:
<tr><td width="116">Medicine name</td><td width="221">
<center>:
<select name="name" id="name" >
<option>--- Choose Medicine ---</option>
<?php
mysql_connect("localhost", "root", "");
mysql_select_db("arie");
$sql = mysql_query("SELECT * FROM tabelmedicine ORDER BY name ASC ");
if(mysql_num_rows($sql) != 0){
while($row = mysql_fetch_assoc($sql)){
$option_value = $row['priceperunit'] . ',' . $row['stock'];
echo '<option value="'.$option_value.'">'.$row['name'].'</option>';
}
}
?>
</select ></center>
This is a script to display other database value in other textfield when the drop down list is selected:
<script>
var select = document.getElementById('name');
var priceperunit = document.getElementById('priceperunit');
var stock = document.getElementById('stock');
select.onchange = function()
{
var priceperunit_stock = select.value.split(',');
priceperunit.value = priceperunit_stock[0];
stock.value = priceperunit_stock[1];
}
</script>
This is my inserted data into database process:
<?php
$host = "localhost";
$user = "root";
$pass = "";
$db = "arie";
$connect = mysql_connect($host, $user, $pass) or die ('Failed to connect! ');
mysql_select_db($db);
$name=$_POST['name'];
if ($name === "")
{
echo "Please fill all the data";
}
else
{
$query="INSERT INTO `tabelout`(`name`)
VALUES ('$name');";
$result = mysql_query($query) OR die (mysql_error());
echo "You have successfully added new medicine to the database.";
}
?>
This is my list page, where the name didn't show up:
<?php
$con=mysqli_connect("localhost","root","","arie");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM tabelout");
echo "<table border='1'>
<th>name</th>";
while($row = mysqli_fetch_array($result))
{
echo "<td><center>" . $row['name'] . "</center></td>";
}
echo "</table>";
mysqli_close($con);
?>
Make sure your database table has records, If it has records, then change the table structure, Add tr tags where required.
echo "<table border='1'>
<tr><th>name</th></tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr><td><center>" . $row['name'] . "</center></td></tr>";
}
echo "</table>";

How to add a value from a HTML form to a value in a database

I am trying to create a form to allow a user to update data from the form to the existing amount in the database. Here is what I have so far it appears to double the value. I was thinking I needed to pull the value from the database and then add the data from the form.
<?php
$username = "username";
$password = "password";
$hostname = "localhost";
//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
echo "<font face=tahoma color=#ff000><b>Connected to MySQL</b></font><br><br>";
//select a database to work with
$selected = mysql_select_db("pdogclan_points",$dbhandle)
or die("Did this change");
// Formulate Query
$_POST["filter"];
$memid = mysql_real_escape_string($_POST["Member_ID"]);
$query = sprintf("SELECT Member_ID, Bank, Reward_1, Reward_2, Reward_3 FROM Points_Rewards WHERE Member_ID = '$memid'") or die("Could Not Formulate the Query");
//execute the SQL query and return records
$result = mysql_query($query);
// Check result
// This shows the actual query sent to MySQL, and the error. Useful for debugging.
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
//fetch tha data from the database
while ($row = mysql_fetch_array($result))
echo "<table width=750 cellspacing=2 cellpadding=2 border=2>
<tr>
<td bgcolor=#000000 width=150><font face=tahoma color=white>ID: {$row['Member_ID']}</font></td>".
"<td width=150><font face=tahoma>Bank: {$row['Bank']}</td>".
"<td width=150><font face=tahoma>Reward 1: {$row['Reward_1']}</td>".
"<td width=150><font face=tahoma>Reward 2: {$row['Reward_2']}</td> ".
"<td width=150><font face=tahoma>Reward 3: {$row['Reward_3']}</td>
</tr>
</table><br></font>";//display the results
// Formulate Update Query
$_POST["submit"];
$memid = mysql_real_escape_string($_POST["Member_ID"]);
$query = sprintf("SELECT Member_ID, Bank, Reward_1, Reward_2, Reward_3 FROM Points_Rewards WHERE Member_ID = '$memid'") or die("Could Not Formulate the Query");
while ($row = mysql_fetch_array($result))
{
$bankdb = $row['Bank'];
$reward1db = $row['Reward_1'];
$reward2db = $row['Reward_2'];
$reward3db = $row['Reward_3'];
}
echo $bank;
echo $reward1;
echo $reward2;
echo $reward3;
$memid = mysql_real_escape_string($_POST["Member_ID"]);
$bank = $_POST['bank'];
$reward1 = $_POST['reward1'];
$reward2 = $_POST['reward2'];
$reward3 = $_POST['reward3'];
$query = "UPDATE Points_Rewards Set Bank = ('$bank' + '$bankdb'), Reward_1 = ('$reward1' + '$reward1'), Reward_2 = ('$reward2' + '$reward2'), Reward_3 = ('$reward3' + '$reward3') WHERE Member_ID = '$memid'";
$result = mysql_query($query) or die(mysql_error());
if(mysql_query($query)){
echo "updated";}
else{
echo "fail";}
//close the connection
mysql_close($dbhandle);
?>
Just create a form using basic HTML, store data you fetched from database in PHP variables, then display that data using PHP tags, like this:
<form action="..." method="post" >
<?php
$memid = mysql_real_escape_string($_POST["Member_ID"]);
$query = sprintf("SELECT Member_ID, Bank, Reward_1, Reward_2, Reward_3 FROM Points_Rewards WHERE Member_ID = '$memid'") or die("Could Not Formulate the Query");
while ($row = mysql_fetch_array($result))
{
?>
<input type="text" name="r1" value="<?php echo $row['Reward_1']; ?>" /> ;
<input type="text" name="r2" value="<?php echo $row['Reward_2']; ?>" /> ;
<input type="text" name="r3" value="<?php echo $row['Reward_3']; ?>" /> ;
...
<?php
}
?>
...
</form>
You can use operators on the tables values in your SQL - it would look something like this:
$query = "UPDATE Points_Rewards Set Bank = (Bank + '$bankdb'), Reward_1 = (Reward_1 + '$reward1'), Reward_2 = (Reward_2 + '$reward2'), Reward_3 = (Reward_3 + '$reward3') WHERE Member_ID = '$memid'";
This is the structure
// if a form is submitted
if(isset($_POST['submit'])) {
$memid = $_POST["Member_ID"];
//SELECT or INSERT or UPDATE your DATABASE. Yes use PDO and prepared statements.
$query = $dbh->prepare("SELECT Member_ID, Bank, Reward_1, Reward_2, Reward_3 FROM Points_Rewards WHERE Member_ID = '$memid'")
//don't forget to bind parameters
$sth->bindParam(':memid', $memid, PDO::PARAM_INT);
$sth->execute(...);
//the loop
while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
echo '';
}
//close the if statement
}
//write the form
<form method="post"/>
<input name="Member_ID" type="text" required/>
<input name="submit" type="submit" value="submit" />
</form>

Categories