I created this table that part of it takes input from the user and save it in the database..
I'm trying to make the data put by the user in the tags remain shown. Basically the input form becoming both input/output source. Any help on how to do so?
switch ($selected){
case 'University':
$stmt = $conn->prepare("SELECT employees.afnumber,employees.name,employees.actualpost,university.brevet FROM employees,university WHERE employees.status='Employed' AND employees.afnumber=university.afnumber ORDER BY employees.afnumber DESC LIMIT :start,:end");
$stmt->bindParam(':start', $pages->limit_start, PDO::PARAM_INT);
$stmt->bindParam(':end', $pages->limit_end, PDO::PARAM_INT);
$stmt->execute();
$result = $stmt->fetchAll();
$selectedtable = "<form method='post' action=''>\n";
$selectedtable .= "<table class='sortable'>\n<tr><th>Description</th><th>A</th><th>B</th><th>C</th><th>D</th></tr>\n";
foreach($result as $row) {
$selectedtable .= "<tr><th>Brevet</th><td><input type='text' name='Brevet1' style=' padding: 10px; margin-top:1px; border: solid 2px #c9c9c9; width:50px; height:2px;'></td><td>".$row[0]."</td><td>".$row[2]."</td><td>".$row[3]."</td></tr>
<tr><th>Baccalaureat/BT</th><td><input type='text' name='Baccalaureatbt' style=' padding: 10px; font-size:16px; margin-top:1px; border: solid 2px #c9c9c9; width:50px; height:2px;'></td><td>".$row[1]."</td><td>$row[2]</td><td>$row[3]</td></tr>
<tr><th>License/TS</th><td><input type='text' name='Licensets' style=' padding: 10px; margin-top:1px; border: solid 2px #c9c9c9; width:50px; height:2px;'></td><td>".$row[1]."</td><td>".$row[2]."</td><td>$row[3]</td></tr>
<tr><th>M1</th><td><input type='text' name='M1' style=' padding: 10px; margin-top:1px; border: solid 2px #c9c9c9; width:50px; height:2px;'></td><td>".$row[1]."</td><td>".$row[2]."</td><td>".$row[3]."</td></tr>
<tr><th>Master's Degree</th><td><input type='text' name='Mastersdegree' style=' padding: 10px; margin-top:1px; border: solid 2px #c9c9c9; width:50px; height:2px;'></td><td>".$row[1]."</td><td>".$row[2]."</td><td>".$row[3]."</td></tr>
<tr><th>PHD</th><td><input type='text' name='Phd' style=' padding: 10px; margin-top:1px; border: solid 2px #c9c9c9; width:50px; height:2px;'></td><td>".$row[1]."</td><td>".$row[2]."</td><td>".$row[3]."</td></tr>";
}
$selectedtable .= "</table>\n";
$selectedtable .= "<input type='submit' name='submit' value='Submit' style='width:80px; height:30px; text-align:center; padding:0px;'>\n";
$selectedtable .= "</form>\n";
if(isset($_POST['submit']))
{ $brevet1 = $_POST['Brevet1'];
$baccalaureatbt = $_POST['Baccalaureatbt'];
$licensets = $_POST['Licensets'];
$m1 = $_POST['M1'];
$mastersdegree = $_POST['Mastersdegree'];
$phd = $_POST['Phd'];
$sql1="SELECT Brevet1,Baccalaureatbt,Licensets,M1,Mastersdegree,Phd FROM university";
if ($result=mysqli_query($con,$sql1))
{
$rowcount=mysqli_num_rows($result);
}
if($rowcount==0)
{
$sql="INSERT INTO university(Brevet1,Baccalaureatbt,Licensets,M1,Mastersdegree,Phd) VALUES('$brevet1','$baccalaureatbt','$licensets','$m1','$mastersdegree','$phd')";
$result = mysql_query($sql);
}
else
{
$sql2 = "UPDATE university SET Brevet1 = '$brevet1' , Baccalaureatbt = '$baccalaureatbt', Licensets = '$licensets', M1 = '$m1', Mastersdegree = '$mastersdegree', Phd = '$phd'";
$result2 = mysql_query($sql2);
}
}
break;
You can set a value to each input like this :
<input type='text' name='Brevet1' value="<?php echo $_POST['brevet_1']; ?>">
With a ternary condition :
echo (!empty($_POST['brevet_1']) ? $_POST['brevet_1'] : '');
EDIT
Fetch the data from database and set the value of input just like above
This is what I've always done in these kind of situations. Suppose your page name is mypage.php. Now, you open mypage.php with an id (like mypage.php?id=1, and you can get the id as $_GET['id']). This id would be the auto_increment value of the table you need to insert / update.
Now, on mypage.php, write this code :-
<form action="someEndFile.php" method="post">
<?php echo $command; ?>
<?php if($command == 1)
{
$userData = fetch via $_GET['id'];
?>
Your input Tags Here
Submit Button Here
<input type='text' name='somename' value='<?php echo $userdata->valueFromTheDatabase; ?>'>
<?php
}
else
{
?>
<input type='text' name='somename'>
<?php
}
?>
</form>
In the if(data_exists) block, check if any record in the table exists with the id id (which you received as $_GET['id']). If the record exists, it will go inside the if block and the command value would be 1, that means update.
If the ID didn't existed, it would go to else and the value would be 2, which means insert new.
Now, in your form, echo $command and put all the fields. Here check the value of $command and echo the value inside the input tags accordingly.
Now on the someEndFile.php file, have a code like this :-
<?php
$command = isset($_POST['command']) ? $_POST['command'] : '';
switch($command)
{
case 1:
//update case
write your update query here;
break;
case 2:
//insert case
write your insert query here;
break;
}
?>
You can now execute your needed query. This is what I always do in these type of situations.
Here's an example where the input form data is displayed when the form is submitted. As a bonus, it also shows some basic PHP form validation as well:
w3schools Example of showing the form entry on the same page as entered
echo out the variables for the values entered on the page. You can place the echo statements as needed, within tags formatting as you like.
Example:
if your form contains:
Name: <input type="text" name="name">
Then display the tag containing 'name' anywhere on the page like this:
<?php
//check if name has changed:
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
$name = test_input($_POST["name"]);
}
?>
<?php
//echo the new field entry
echo $name;
?>
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
I have created a form whose method is "POST" and action is "#", indicating to send the data to the same page.
Now after submitting the form,
A second form appears below which fetches data(according to the selection on first form) from database and gives the user a control to edit the record.
EVERYTHING IS WORKING GOOD AND WELL
The only problem is "*Second form submit button doesn't show up"
My Code of that particular page:(editcategory.php)
<?php
require_once("admin_panel.php");
?>
<!DOCTYPE html>
<head>
<title>Users</title>
<link rel="stylesheet" href="css/footer.css">
<style>
.bodystart{
margin-top:2%;
margin-left:25%;
}
h1{
font-size:xx-large;
}
table {
border-collapse: separate;
border-spacing:5px 5px;
width: auto;
color: #588c7e;
font-family:"Lucida Console", "Courier New", monospace;
font-size: 20px;
text-align: left;
}
th {
background-color: #588c7e;
color: white;
}
option:nth-child(even) {
background-color: #f2f2f2
}
.submitnewcat{
margin-top:3%;
color:#ffffff;
padding:5px;
border-radius:10 px;
background-color:#4CAF50;
cursor:pointer;
}
form{
margin-top:5%;
}
input,select{
border-style:inset;
border-left:6px solid green;
background-color:#ced6e0;
padding: 12px 15px;
border-radius:5px;
}
.catidcont{
background-color:#c7ecee;
cursor:default;
}
label{
padding:12px 15px;
font-size:larger;
background-color:#130f40;
color:#ffffff;
border-radius:5px;
border:2px solid red;
}
</style>
</head>
<body>
<div class="bodystart">
<h1><i>Edit Category</i></h1>
<form method="POST" action="#">
<label>Select Category</label>
<?php
$sql = "SELECT * FROM category";
$result = mysqli_query($db_conn,$sql);
echo "<select name='catset' required>";
echo "<option value=''>Select</option>";
while ($row = $result->fetch_assoc()) {
echo "<option value='" . $row['id'] . "'>" . $row['name'] . "</option>";
}
echo "</select>";
?>
<button class="submitnewcat" name="submit3" type="submit" value="Submit">Fetch Details</button>
</form>
<?php
if(isset($_POST["submit3"])==true){
function validate($data){
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
$x=(int)$_POST['catset'];
$sql = "SELECT * FROM category a WHERE a.id=$x";
$result = $db_conn->query($sql);
if ($result->num_rows > 0) {
$row = $result->fetch_assoc();
echo "<form method='POST' action='updatecategory.php'";
echo "<input type='hidden' readonly>";
echo "<label>Category ID</label>";
echo "<input type='number' name='catid' value=$x readonly style='cursor:no-drop;'><br><br><br>";
echo "<label>New Category Name</label>";
echo "<input type='text' name='newcatname' required placeholder='".$row['name']."'>";
echo "<label>Status</label>";
echo "<select name='newstat' required>";
if($row["status"]==1){
$catstat="Active";
echo "<option value='".$row['status']."' selected>$catstat</option>";
echo "<option value='2'>Disabled</option>";
}
else{
$catstat="Disabled";
echo "<option value='1'>Active</option>";
echo "<option value='".$row['status']."' selected>$catstat</option>";
}
echo "<button class='submigtnewcat' name='submit4' type='submit' value='Submit'>Fetch Details</button>";
echo "</form>";
}
} ?>
</div>
</body>
<?php
require_once("include/footer.php");?>
</html>
Snippet of my page
there is bug you have not close the tag of select so button is not displaying .
i hope you have got your answer .
echo "<select name='newstat' required>";
if($row["status"]==1){
$catstat="Active";
echo "<option value='".$row['status']."' selected>$catstat</option>";
echo "<option value='2'>Disabled</option>";
}
else{
$catstat="Disabled";
echo "<option value='1'>Active</option>";
echo "<option value='".$row['status']."' selected>$catstat</option>";
}
echo "</select>";
I am new on implementing Ajax on PHP so I need a big help! anyways my problem is I have a 5 column names on my table_menu
table_menu:
menu_id
menu_foodname
menu_price
menu_quantity
menu_image
and inside those column names it has 6 datas.
And I will gonna fetch those datas on my webpage(users.php)
<?php
// users.php
// fetching data
include 'config/initialize.php';
$sql = "SELECT * FROM table_menu";
$res = mysqli_query($con, $sql);
if($res)
{
echo "<table><tr>";
while($row = mysqli_fetch_array($res))
{
echo "<td>";
echo "<div class='horizontalAlign'>";
echo "<form class='form-item' method='post'>";
echo "<img class='img-circle' src='menuImage/".$row['menu_image']."' style='height: 150px; width: 200px;'>";
echo "<input type='hidden' name='menuimage' class='menuimage' value='".$row['menu_image']."'>";
echo "<input type='text' name='menufoodname' class='menufoodname' value='".$row['menu_foodname']."' style='border:none; margin-top: 10px; margin-left: 30px; font-size: 20px;' readonly>";
echo "<div style='font-size: 20px; margin-left: 40px;'>Price:</div> <input type='text' class='menuprice' name='menuprice' value='".$row['menu_price']."' style='border:none; margin-left: 100px; margin-top: -28px; position: absolute; font-size: 20px;' readonly>";
echo "<div style='font-size: 20px;'>Quantity:</div> <input type='number' class='menuquantity' name='menuquantity' style='margin-top: -26px; position: absolute; margin-left: 90px; text-align: center;' value='".$row['menu_quantity']."' min='0' max='100'>";
echo "<br>";
echo "<input type='button' value='Submit order' class='btnaddorder btn btn-lg btn-info' class='btn btn-info'>";
echo "</form>";
echo "</div>";
echo "</td>";
$i++;
if($i == 3)
{
echo "</tr><tr>";
}
} // end of while
echo "</tr></table>";
} // end of variable $i
?> <!-- // end of fetching data -->
and I want the page to be not refresh while the user orders... so I add this ajax script on the bottom of users.php
<script type="text/javascript">
$(document).ready(function() {
$(".btnaddorder").click(function() {
var menuimage = $(".menuimage").val();
var menufoodname = $(".menufoodname").val();
var menuprice = $(".menuprice").val();
var menuquantity = $(".menuquantity").val();
// Returns successful data submission message when the entered information is stored in database.
$.post("addorders.php", {
menuimage1: menuimage,
menufoodname1: menufoodname,
menuprice1: menuprice,
menuquantity1: menuquantity,
}, function(data) {
});
});
});
</script>
Now the problem is when I am clicking the first button on the fetched datas the first one only got inserted and if I am add the second item even the third until fifth item it only display one data on the database which is the first data, why?
heres my addorders.php
<?php
include 'config/initialize.php';
include 'credentials/credentialsForUsers.php';
$menuimage = $_POST['menuimage1'];
$menufoodname = $_POST['menufoodname1'];
$menuprice = $_POST['menuprice1'];
$menuquantity = $_POST['menuquantity1'];
$sql = "INSERT INTO table_orders VALUES('','$username','$email','$menuimage','$menufoodname','$menuprice','$menuquantity')";
$result = mysqli_query($con, $sql);
?>
thank you & sorry for my bad english. hope you understand my problem
To clarify which fields you want to submit you can do the following:
$(".btnaddorder").click(function() {
// here you find closest form tag to the pressed button
var form = $(this).closest('form');
// replace all you values with simple .serialize() function
// this function will use all non-disable fields from the form
$.post("addorders.php", form.serialize(), function(data) { });
});
On the serverside your $_POST will have the same keys as fields on your form.
I have a php array that includes inputs for posting. It uses a counter for each array record, and this counter is applied to the name of the input to be used in performing some actions with the post - this is working great.
The issue is that I would like to keep the users' existing inputs and re-populate the input fields in the array if their post doesn't pass validation.
I have done this before with static fields, simply storing the post variable and echoing it in the "value" --- but I can't figure out how to do this when working with an array. Anyone have any ideas?
$counter = 0;
echo "<form method='post'>";
echo "<table class='mainlist' width='680'>";
while ($row = mysqli_fetch_array($result)) {
echo "<tr height='60'>";
echo "<td class='mainlist'><input type=text name=options[$counter] autocomplete=off onclick='this.select()' class='txt'></td>";
echo "</tr>";
$counter = $counter + 1;
}
echo "</table>";
Full code per request:
<?php
if($_SERVER["REQUEST_METHOD"] == "POST")
{
$userid = $_SESSION['login_user'];
$companyid = $_POST['companyid'];
$options = $_POST['options'];
$counter = $_POST['hiddencounter'];
$runningtotal=0;
$totaloptions = array_sum($options);
$result = mysqli_query($connection, "SELECT options_balance FROM user_options_balance WHERE user_id = '".$userid."'");
for ($i=0; $i<$counter; $i++)
{
if(empty($options[$i]))
{ /* IF NO INPUT ON OPTIONS */
/* DO NOTHING */
}
else
{
$checknewcompanies = mysqli_query($connection, "SELECT company_id FROM user_company_total_invested WHERE user_id = '".$userid."' and company_id = '" .$companyid[$i]."'");
if($checknewcompanies->num_rows == 1)
{ // do nothing
}
else
{
$runningtotal = $runningtotal + 1;
}
} /* END OF ELSE IF NOT EMPTY OPTIONS */
} /* END OF FOR LOOP */
$checkcurrentcompanies = mysqli_query($connection, "SELECT company_id FROM user_company_total_invested WHERE user_id = '".$userid."'");
$countcompanies = $checkcurrentcompanies->num_rows;
$countcheck = $runningtotal + $countcompanies;
if($countcheck <= 4)
{
while($row = mysqli_fetch_array($result))
{
$balance = $row['options_balance'];
}
if ($totaloptions>$balance)
{
$notenoughoptions= "<div style='background-color:#FF0000; border-radius: 15px; padding: 10px; color: #FFFFFF; font-size: 12px;'>Oops! You don't have enough options! Try investing less!</div>";
}
else
{
// loop through array
for ($i=0; $i<$counter; $i++)
{
if(empty($options[$i])){ /* IF NO INPUT ON OPTIONS */
/* DO NOTHING */
}
else {
if(!ctype_digit($options[$i]) or !is_numeric($options[$i])){
$charactercheck= "<div style='background-color:#FF0000; border-radius: 15px; padding: 10px; color: #FFFFFF; font-size: 12px;'>Oops! Please enter only positive numbers to invest!</div>";
}
else {
$checkcompanies = mysqli_query($connection, "SELECT company_id FROM company_main WHERE company_id = '".$companyid[$i]."'");
if($checkcompanies->num_rows != 1)
{
$companynotexist= "<div style='background-color:#FF0000; border-radius: 15px; padding: 10px; color: #FFFFFF; font-size: 12px;'>Oops! That company doesn't exist!</div>";
}
else
{
// loop through array
for ($i=0; $i<$counter; $i++)
{
if(empty($options[$i]))
{ /* IF NO INPUT ON OPTIONS */
/* DO NOTHING */
}
else
{
$query = "INSERT INTO user_company_invested(user_id, company_id, user_company_options_invested)
VALUES($userid,$companyid[$i],$options[$i])";
mysqli_query($connection, $query);
} /* END OF ELSE IF NOT EMPTY OPTIONS */
} /* END OF FOR LOOP */
$balancecheck = mysqli_query($connection, "SELECT options_balance FROM user_options_balance WHERE user_id = '".$userid."'");
while($row = mysqli_fetch_array($balancecheck))
{
$balance2 = $row['options_balance'];
}
if($balance2 > 0)
{
header('Location: user_invest.php');
}
else
{
header('Location: user_market.php');
}
} // end company check
} //end character check
} //end empty option check
} //end loop
} /* END OF NOT ENOUGH OPTIONS CHECK */
}
else
{
$toomanycompanies = "<div style='background-color:#FF0000; border-radius: 15px; padding: 10px; color: #FFFFFF; font-size: 12px;'>Oops! You can invest in a maximum of 4 companies per week. Please choose fewer companies, or invest more in some of your existing companies!</div>";
/* echo "Maximum number of companies you can invest in is 4";
echo "<br />";
echo "Companies you already are invested in: ".$countcompanies;
echo "<br />";
echo "New companies you are trying to invest in: ".$runningtotal;
echo "<br />";
echo "Total: ".$countcheck;*/
}
} /* END OF ISSET CHECK */
else
{
}
?>
<?php
$result = mysqli_query($connection,"SELECT * from company_main");
$counter=0;
echo "<form method='post'>";
echo "<table class='mainlist' width='680'>";
while($row = mysqli_fetch_array($result))
{
echo "<tr height='60'>";
echo "<td class='mainlist' width=140 align='center'>" . "<img src='".$row['company_logo']."' width='40'/>" . "</td>";
echo "<td class='mainlist' align='left' width=390 style='font-size: 15px;'>" . $row['company_name'] . "</td>";
echo "<input type=hidden name=companyid[$counter] value=" . $row['company_id'] . " />";
echo "<td class='mainlist'><input value='{$_POST['options[$counter]']}' type=text name=options[$counter] autocomplete=off onclick='this.select()' class='txt' style=' background-color: #FCFCFC;
border: solid 1px #CCCCCC;
font-size: 12px;
padding: 5px;
height: 20px;
text-align: right;'></td>";
echo "</tr>";
$counter=$counter+1;
}
echo "</table>";
echo "<input type='hidden' name='hiddencounter' value='$counter'>";
echo "
<table>
<tr>
<td width='630' height='50'></td>
<td align='right' width='60' style='color: #848580; font-size: 20px;'>Total: </td>
<td align='right' width='40' style='color: #94D90B; font-size: 20px; font-weight: bold; padding-right:20px;'><span id='sum'>0</span></td><td width='10'></td>
</tr><tr height='20px'></tr><tr>
<td width='570' align='center' style='color: #94D90B; font-size: 12px;'>";?>
<?php echo $notenoughoptions; ?>
<?php echo $charactercheck; ?>
<?php echo $toomanycompanies; ?>
<?php echo "
</td>
<td colspan='2' width='100' align='right'><input name='userinvestoptionsdynamic' type='submit' value='Invest!'></td><td width='10'></td>
</tr>
<tr height='20px'></tr>
</table>";
echo "</form>";
?>
The correct syntax is:
echo "{$arrayname($keyname)}";
So for example echo('value=' . $_POST['options'][$counter]); becomes:
echo "value={$_POST['options'][$counter]}";
I am trying to turn my database results (users) into clickable links that will then display more information on the select user. Right now I am using $_GET, but the userID will be displayed in the address bar. Is there a way I can POST it instead?
Currently, I have:
//fetch and display the results in table
while ($row = mysqli_fetch_array($result, MYSQL_ASSOC)){
$name = $row["name"];
$id = $row["id"];
//prepare user for GET statement
echo ' <div>'.$row['name'].'</div> ';}
this displays: www.mylink.php?=id"12345"
I don't want to display the ID. So is the best approach to correct this this? Thanks
You have to create a form and a script to post your data. Something like this:
<?php
while ($row = mysqli_fetch_array($result, MYSQL_ASSOC)){
$name = $row["name"];
$id = $row["id"];
//prepare user for GET statement
echo "<div><a href=\"#\" onclick='javascript:postIt(".htmlspecialchars($row['id']).");'>".$row['name']."</a></div> ";
}
?>
<script>
function postIt(value){
document.forms[0].id.value = value;
document.forms[0].submit();
}
</script>
<form name="blah" action="mylink.php" method="post">
<input type="hidden" name="id">
</form>
You could replace all your hyperlinks with little forms:
<form action='mylink.php' method=post>
<input type=hidden value='$id'>
<input class='post_link' type=submit value='$name'>
</form>
CSS would help you to restyle buttons like links:
.post_link {
background-color: transparent;
border: none;
border-bottom: solid 1px blue;
color: blue;
display: inline;
height: ...;
etc
}
Open new tab will not work again, and you will see nothing is status bar on hover.
Currently I have a script that displays the data which is editable and can update the database. I have tried to enter row counts and nothing seem to work. I really like the script to make 3 columns (10 rows per column), please help.
$sql = "SELECT id, pounds FROM price_list ORDER BY id";
$i = 0;
$result = mysql_query($sql);
echo "<form name='prices' method='post' action='updateA.php'>";
while($rows = mysql_fetch_array($result))
{
echo "<body bgColor='#5F5F6B'>";
echo "<table><table border=2 cellspacing=0 cellpadding=1>";
echo "<input type='hidden' name='id[$i]' value='{$rows['id']}' >";
echo "<td><font color='#FFFFFF'><font size='2'>DAYS {$rows['id']}: </font><font size='2'><font color='#000000'>PRICE:<input type='text' size='1' name='pounds[$i]' value='{$rows['pounds']}' ></tr>";
++$i;
}
echo "</table>";
echo "<input type='submit' value='Update Prices Band A' />";
echo "</form>";
?>
The above is the original code.
I don't really know what you're trying to do, but this code will generate a list of all the entries in the database with the ability to change them. Note that you'll have to remake your update_a.php file:
<style>
body {
background:#5F5F6B;
color:#fff;
}
</style>
<?php
$result = mysql_query("SELECT id, pounds FROM price_list ORDER BY id");
if (!$sql || mysql_num_rows($result)==0)
echo "Price list is empty";
else {
echo '<form name="prices" method="GET" action="update_a.php">'; // Change your filename!
$i = 0;
while ($rows = mysql_fetch_array($result)) {
echo 'Day '.$rows['id'].' costs ';
echo '<input type="text" name="'.$rows['id'].'" value="'.$rows['pounds'].'"/> pounds'
echo '<br/>'
$i++;
}
echo '<input type="submit" value="Update Prices Band A"/>';
echo "</form>";
}
?>
First of all many thanks to Leonard Pauli, the code worked perfectly in displaying the data but, it wouldn't update the database using my update.php. Below is the revised code and screenshot of what I was trying to archive.
Screenshot of single lined data displayed in 3 columns
<style>
body {
background:#5F5F6B;
color:#fff;
width:800px;
height:550px;
border:2px solid #bbb;
padding:20px;
float:center;
}
input[type="text"] {
width: 30px;
}
.table {
width:180px;
margin:1px;
border:2px solid #bbb;
padding:10px;
float:left;
}
.header {
width:595px;
margin:1px;
border:2px solid #bbb;
padding:10px;
float:left;
}
</style>
<div class="header"><b>Price List for dates from <font color ="yellow"><?php echo "$SPA"; ?> to <?php echo "$EPA"; ?></font></div>
<?php
$dataprice = $_POST['database'];
$datesrange = $_POST['id'];
$result = mysql_query("SELECT id, pounds FROM $dataprice ORDER BY id");
echo '<form name="prices" method="POST" action="update.php">';
$i = 0;
while ($rows = mysql_fetch_array($result)) {
echo '<div class="table">Day <font color="yellow">'.$rows['id'].' </font> costs ';
echo "<input type='hidden' name='id[$i]' value='{$rows['id']}' >";
echo "<input type='text' name='pounds[$i]' value='{$rows['pounds']}' > Pounds";
echo '<br/></div>';
$i++;
}
echo "<input type='hidden' name='databases' value='$dataprice'>";
echo '<center><input type="submit" value="Update Prices"/>';
echo '<center><font color="yellow"><br><br><br>IF UPDATING PRICE BAND D, ONLY ENTER THE VALUE OF WHICH
PRICES YOU WANT TO INCREASE BY, <br>EXAMPLE: 7 DAYS, IF CURRENT PRICE IS 30, IF YOU WANT TO
CHARGE 34, ONLY ENTER 4 AND LEAVE EVERYTHING ELSE SET TO 0</b></center>';
echo "</form>";
?>
A bit of an idiot really, completely forgot about CSS styling.