my program is generating buttons from a mysql database.When one of the button is pressed, it would uplod the current time and the gps coordinate.
Sadly, it only works if the same button is pressed twice, but its not an option, because the button has to dissappear.
I would like to have some help in coding how to make that possible the user only need to press the button once for the correct upload.Thanks in advance
Here is the full code of my my file:
<?php session_start(); ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>title</title>
</head>
<?php
$maidatum=date("Ymj");
echo "<script>getLocation();</script>";
//Az adatbázishoz való csatlakozás
$conn = mysql_connect("localhost","root","asd");
if(!($conn))die("Nincs conn a kiszolgálóval!".mysql_error());
$adatbazisneve="schtrans";
mysql_select_db($adatbazisneve,$conn);
mysql_query("set names 'utf8'");
mysql_query("set character set 'utf8'");
//Combobox
$sql = "SELECT Jaratszam,Vezeto FROM user";
$rs = mysql_query($sql) or die(mysql_error());
echo "<form action=\"\" method=\"post\">";
echo<<<nev
<select name='Lista'>
nev;
while($row = mysql_fetch_array($rs)){
echo "<option value='".$row["Jaratszam"]."'>".$row["Vezeto"]."</option>";
}mysql_free_result($rs);
echo "</select>";
///Combox vége
echo<<<lekerd
<form action="" method="post">
<input type="submit" name="bekuldes" value="Lekérdez" />
</form>
</form>
lekerd;
echo<<<gps
<form action="" method="post">
<input type="hidden" name= "longitude" id="longitude">
<input type= "hidden" name ="latitude" id="latitude">
</form>
gps;
if(isset($_POST["bekuldes"]))
{
$jaratszam = $_POST['Lista'];
$_SESSION['jaratsz']=$jaratszam;
$lekerdez_parancs="SELECT * FROM cim_$maidatum WHERE jarat=$jaratszam;";
$lekerdez=mysql_query($lekerdez_parancs, $conn);
echo "<table border=\"1\">";
echo "<td>Utánvétel</td> <td>Megrendelés összege</td> <td>ISZ</td> <td>Város</td> <td>Utca</td> <td>Megjegyzés</td> <td>Csomagok</td> <td>Raklaphely</td> <td>Súly</td><td>Térfogat</td><td>Latitude</td><td>Longitude</td><td>Ido</td>";
$g=1; //cimszámláló
while ($adatok=mysql_fetch_array($lekerdez)) {
echo "<tr>";
$_SESSION['adatok0'][$g]=$adatok[0];
echo "<td>$adatok[2]</td> <td>$adatok[3]</td> <td>$adatok[4]</td> <td>$adatok[5]</td> <td>$adatok[6]</td> <td>$adatok[7]</td> <td>$adatok[8]</td> <td>$adatok[9]</td> <td>$adatok[10]</td><td>$adatok[11]</td><td>$adatok[13]</td><td>$adatok[14]</td>";
if ($adatok[12]==null) {
echo<<<gomb
<form action="" method="post">
<td>
<input type="hidden" name= "longitude" id="longitude$g">
<input type= "hidden" name ="latitude" id="latitude$g">
<input type="submit" name="ido" value="$g" /></td>
</form>
gomb;
}
else {echo "<td>$adatok[12]</td>";}
$g++;
}
echo "</table>";
}
if(isset($_POST["ido"])) {
$hanyadik=$_POST["ido"];
$longitudee="longitude$hanyadik";
$latitudee="latitude$hanyadik";
?>
<script>
var x=document.getElementById("log");
function getLocation()
{
if (navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(showPosition);
}
else{x.innerHTML="GPS szolgáltatás nem müködik ezen a böngészon, kérlek értesítsd a rendszergazdát!";}
}
function showPosition(position)
{
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
document.getElementById("<?php echo $longitudee;?>").value = longitude;
document.getElementById("<?php echo $latitudee;?>").value = latitude;
}
</script>
<?php
echo "<script>getLocation();</script>";
$latitude=$_POST["latitude"];
$longitude=$_POST["longitude"];
print_r($_POST);
$currentime=date("H:i:s");
$acim=$_SESSION['adatok0'][$hanyadik];
$idofeltolt_parancs="UPDATE cim_$maidatum SET ido='$currentime',lat='$latitude',longi='$longitude' WHERE cimid='$acim';";
$feltoltes=mysql_query($idofeltolt_parancs, $conn) or die(mysql_error());
//tryy
$jaratszam=$_SESSION['jaratsz'];
$lekerdez_parancs="SELECT * FROM cim_$maidatum WHERE jarat=$jaratszam;";
$lekerdez=mysql_query($lekerdez_parancs, $conn);
mysql_query("set names 'utf8'");
mysql_query("set character set 'utf8'");
echo "<table border=\"1\">";
echo "<td>Utánvétel</td> <td>Megrendelés összege</td> <td>ISZ</td> <td>Város</td> <td>Utca</td> <td>Megjegyzés</td> <td>Csomagok</td> <td>Raklaphely</td> <td>Súly</td><td>Térfogat</td><td>Latitude</td><td>Longitude</td><td>Ido</td>";
$g=1; //cimszámláló
while ($adatok=mysql_fetch_array($lekerdez)) {
echo "<tr>";
$_SESSION['adatok0'][$g]=$adatok[0];
echo "<td>$adatok[2]</td> <td>$adatok[3]</td> <td>$adatok[4]</td> <td>$adatok[5]</td> <td>$adatok[6]</td> <td>$adatok[7]</td> <td>$adatok[8]</td> <td>$adatok[9]</td> <td>$adatok[10]</td><td>$adatok[11]</td><td>$adatok[13]</td><td>$adatok[14]</td>";
if ($adatok[12]==null) {
echo<<<gomb
<form action="" method="post">
<td>
<input type="hidden" name= "longitude" id="longitude$g">
<input type= "hidden" name ="latitude" id="latitude$g">
<input type="submit" name="ido" value="$g" /></td>
</form>
gomb;
}
else {echo "<td>$adatok[12]</td>";}
$g++;
}
echo "</table>";
}
mysql_close($conn);
?>
</html>