Cześć wszystkim, chciałbym poprosić o dwie rady dotyczące naprawienia zachowań mojego kodu.
Mianowicie zaczynając od pierwszego problemu: Napisałem podstronę, która ma za zadanie edytować wprowadzona już "umowę" wybraną po przez przycisk edytuj w szczegółach umowy, wyświetla oczywiście wszystkie pozycje zgodnie z tym co przechowywane jest w bazie danych dla tej JEDNEJ umowy.
Problem zaczyna się teraz, kiedy już powiedzmy coś zmienię i kliknę przycisk zapisz zmiany, edytuje mi wszystkie umowy z całej bazy na ta jedna, która edytowałem.
Fragment kodu
<?php
session_start();
include("checklogin.php");
check_login();
include("dbconnection.php");
if(isset($_POST['update']))
{
$data_wyjazdu=$_POST['data_wyjazdu'];
$name=$_POST['imie'];
$kod=$_POST['kod'];
$miejscowosc=$_POST['miejscowosc'];
$ulica=$_POST['ulica'];
$telefon=$_POST['telefon'];
$kwota=$_POST['kwota'];
$porat=$_POST['porat'];
$mata=$_POST['mata'];
$pas=$_POST['pas'];
$system=$_POST['system'];
$wplata=$_POST['wplata'];
$wplata_rodzaj=$_POST['wplata_rodzaj'];
$practi=$_POST['practi'];
$forma=$_POST['forma'];
$gold=$_POST['gold'];
$stat=$_POST['stat'];
$silver=$_POST['silver'];
$tablet=$_POST['tablet'];
$lozko=$_POST['lozko'];
$rodzaj=$_POST['rodzaj'];
$nr_rachunku=$_POST['nr_rachunku'];
$prelegent=$_POST['prelegent'];
$multi=$_POST['multi'];
$turbo=$_POST['turbo'];
$asystent=$_POST['asystent'];
$wyciskarka=$_POST['wyciskarka'];
$kierowca=$_POST['kierowca'];
$query=$_POST['query'];
$ret=mysqli_query($con,"update prequest set
name='$name',
kod='$kod',
miejscowosc='$miejscowosc',
ulica='$ulica',
telefon='$telefon',
mata='$mata',
pas='$pas',
system='$system',
practi='$practi',
gold='$gold',
silver='$silver',
tablet='$tablet',
lozko='$lozko',
multi='$multi',
turbo='$turbo',
wyciskarka='$wyciskarka',
wplata_rodzaj='$wplata_rodzaj',
nr_rachunku='$nr_rachunku',
kwota='$kwota',
porat='$porat',
wplata='$wplata',
forma='$forma',
stat='$stat',
rodzaj='$rodzaj',
prelegent='$prelegent',
asystent='$asystent',
kierowca='$kierowca',
query='$query'");
}
if($ret)
{
echo "<script>alert('Data Updated');</script>";
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<meta charset="utf-8" />
<title>CRM | Dashboard </title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta content="" name="description" />
<meta content="" name="author" />
<link href="assets/plugins/pace/pace-theme-flash.css" rel="stylesheet" type="text/css" media="screen"/>
<link href="assets/plugins/boostrapv3/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
<link href="assets/plugins/boostrapv3/css/bootstrap-theme.min.css" rel="stylesheet" type="text/css"/>
<link href="assets/plugins/font-awesome/css/font-awesome.css" rel="stylesheet" type="text/css"/>
<link href="assets/css/animate.min.css" rel="stylesheet" type="text/css"/>
<link href="assets/plugins/jquery-scrollbar/jquery.scrollbar.css" rel="stylesheet" type="text/css"/>
<link href="assets/css/style.css" rel="stylesheet" type="text/css"/>
<link href="assets/css/responsive.css" rel="stylesheet" type="text/css"/>
<link href="assets/css/custom-icon-set.css" rel="stylesheet" type="text/css"/>
</head>
<body class="">
<?php include("header.php");?>
<div class="page-container row-fluid">
<?php include("leftbar.php");?>
<div class="clearfix"></div>
</div>
</div>
<a href="#" class="scrollup">Scroll</a>
<div class="footer-widget">
<div class="progress transparent progress-small no-radius no-margin">
<div data-percentage="79%" class="progress-bar progress-bar-success animate-progress-bar" ></div>
</div>
<div class="pull-right">
</div>
</div>
<div class="page-content">
<div id="portlet-config" class="modal hide">
<div class="modal-header">
<button data-dismiss="modal" class="close" type="button"></button>
<h3>Widget Settings</h3>
</div>
<div class="modal-body"> Widget settings form goes here </div>
</div>
<div class="clearfix"></div>
<div class="content">
<div class="page-title">
<h3><b>Edycja umowy</b></h3>
<?php $rt=mysqli_query($con,"select * from prequest where id='".$_GET['id']."'");
while($rw=mysqli_fetch_array($rt))
{ ?>
Tutaj link do całości kodu: https://pastebin.com/xb6Mm9jw
Drugi problem, również chodzi o edycje ale w tym przypadku nie zapisuję się dane kompletnie.
Po stronie użytkownika wygląda to tak:
Po wciśnięciu przycisku save nic się nie dzieję, ani nie oblicza kwoty do spłacenia, ani nie zapisuje danych na serwerze.
<?php
session_start();
include("dbconnection.php");
include("checklogin.php");
check_login();
if(isset($_POST['update']))
{
$jeden=$_POST['1'];
$dwa=$_POST['2'];
$trzy=$_POST['3'];
$cztery=$_POST['4'];
$piec=$_POST['5'];
$ret=mysqli_query
($con,"UPDATE
prequest
SET
`1 = '$jeden',
`2` = '$dwa',
`3` = '$trzy',
`4` = '$cztery',
`5` = '$piec'");
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<meta charset="utf-8" />
<title>Admin | Manage Quotes</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta content="" name="description" />
<meta content="" name="author" />
<link href="assets/plugins/bootstrap-select2/select2.css" rel="stylesheet" type="text/css" media="screen"/>
<link href="assets/plugins/jquery-datatable/css/jquery.dataTables.css" rel="stylesheet" type="text/css"/>
<link href="assets/plugins/datatables-responsive/css/datatables.responsive.css" rel="stylesheet" type="text/css" media="screen"/>
<link href="assets/plugins/boostrapv3/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
<link href="assets/plugins/boostrapv3/css/bootstrap-theme.min.css" rel="stylesheet" type="text/css"/>
<link href="assets/plugins/font-awesome/css/font-awesome.css" rel="stylesheet" type="text/css"/>
<link href="assets/css/animate.min.css" rel="stylesheet" type="text/css"/>
<link href="assets/plugins/jquery-scrollbar/jquery.scrollbar.css" rel="stylesheet" type="text/css"/>
<link href="assets/css/style.css" rel="stylesheet" type="text/css"/>
<link href="assets/css/responsive.css" rel="stylesheet" type="text/css"/>
<link href="assets/css/custom-icon-set.css" rel="stylesheet" type="text/css"/>
</head>
<body class="">
<?php include("header.php");?>
<div class="page-container row">
<?php include("leftbar.php");?>
<div class="clearfix"></div>
<!-- END SIDEBAR MENU -->
</div>
</div>
<div class="page-content">
<!-- BEGIN SAMPLE PORTLET CONFIGURATION MODAL FORM-->
<div id="portlet-config" class="modal hide">
<div class="modal-header">
<button data-dismiss="modal" class="close" type="button"></button>
<h3>Widget Settings</h3>
</div>
<div class="modal-body"> Widget settings form goes here </div>
</div>
<div class="clearfix"></div>
<div class="content">
<ul class="breadcrumb">
<li>
<p>Menu</p>
</li>
<li><a href="#" class="active">Raty Firmowe</a> </li>
</ul>
<div class="page-title">
<h3>Wszystkie Raty Firmowe</h3>
</div>
<div class="row-fluid">
<div class="span12">
<div class="grid simple ">
<div class="grid-title">
<h4>Umowy o statusie <b>Rata-Firmowa</b> <span class="semi-bold"></span></h4>
<div class="tools"> <a href="javascript:;" class="reload"></a> </div>
</div>
<div class="grid-body ">
<table class="table table-hover table-condensed" id="example">
<thead>
<tr>
<th style="width:1%">#</th>
<th style="width:10%">Imię Nazwisko</th>
<th style="width:5%">Kwota Całkowita</th>
<th style="width:5%">Wpłata własna</th>
<th style="width:4%">Rata nr 1</th>
<th style="width:4%">Rata nr 2</th>
<th style="width:4%">Rata nr 3</th>
<th style="width:4%">Rata nr 4</th>
<th style="width:4%">Rata nr 5</th>
<th style="width:10%">Pozostała kwota do spłaty</th>
<th style="width:10%">Uwagi</th>
</tr>
</thead>
<tbody>
<?php $ret=mysqli_query($con,"select * from prequest where stat = 'Raty Firmowe'");
$cnt=1;
while($row=mysqli_fetch_array($ret))
{
$kolor='black';
if($row['stat'] == 'Raty Firmowe'){$kolor='yellow';}
$xxx=$row['kwota'] - $row['wplata']-$row['1'] - $row['2']-$row['3'] - $row['4']-$row['5'];
?>
<tr style="background-color: <?php echo $kolor ?>">
<td class="v-align-middle"><?php echo $cnt;?></td>
<td class="v-align-middle"><?php echo $row['name'];?></td>
<td class="v-align-middle"><?php echo $row['kwota'];?></td>
<td class="v-align-middle"><?php echo $row['wplata'];?></td>
<td class="v-align-middle"><input type="int" name="1" id="1" size="2"value="<?php echo $row['1'];?>"></td>
<td class="v-align-middle"><input type="int" name="2" id="2" size="2" value="<?php echo $row['2'];?>"></td>
<td class="v-align-middle"><input type="int" name="3" id="3" size="2" value="<?php echo $row['3'];?>"></td>
<td class="v-align-middle"><input type="int" name="4" id="4" size="2" value="<?php echo $row['4'];?>"></td>
<td class="v-align-middle"><input type="int" name="5" id="5" size="2" value="<?php echo $row['5'];?>"></td>
<td class="v-align-middle"><?php echo $xxx?></td>
<td class="v-align-middle"><?php echo $row['uwaga_rata'];?></td>
<td>
<button type="submit" name="update" class="btn btn-primary">save</button></td>
</tr>
<?php $cnt=++$cnt; } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="addNewRow"></div>
</div>
</div>
<script src="assets/plugins/jquery-1.8.3.min.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-ui/jquery-ui-1.10.1.custom.min.js" type="text/javascript"></script>
<script src="assets/plugins/boostrapv3/js/bootstrap.min.js" type="text/javascript"></script>
<script src="assets/plugins/breakpoints.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-unveil/jquery.unveil.min.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-scrollbar/jquery.scrollbar.min.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-block-ui/jqueryblockui.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-numberAnimate/jquery.animateNumbers.js" type="text/javascript"></script>
<script src="assets/plugins/bootstrap-select2/select2.min.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-datatable/js/jquery.dataTables.min.js" type="text/javascript" ></script>
<script src="assets/plugins/jquery-datatable/extra/js/dataTables.tableTools.min.js" type="text/javascript" ></script>
<script type="text/javascript" src="assets/plugins/datatables-responsive/js/datatables.responsive.js"></script>
<script type="text/javascript" src="assets/plugins/datatables-responsive/js/lodash.min.js"></script>
<script src="assets/js/datatables.js" type="text/javascript"></script>
<script src="assets/js/core.js" type="text/javascript"></script>
<script src="assets/js/chat.js" type="text/javascript"></script>
<script src="assets/js/demo.js" type="text/javascript"></script>
</body>
</html>