Jump to content

Update data issue


Guntek

Recommended Posts

Hello,

i am making a small script where a user is able to add some data into the database.  I have done already registration, add data etc. Everything works fine but the problem is when i try to update  data in database . Here you have piece of code. I hope someone will help me ...  ???

 

 




<?php
ob_start();
require "config_bet.php";




// *** DISPLAY USER STATS IF COOKIE SET *** //
// **Check if cookie is set 
if (isset($_COOKIE['bet_cookie']) AND $user_lvl >= 1)   
{
  echo "<b>[ <a href=".$pg_add.">Add Bet</a> | <a href=".$pg_adminuser.">Settings</a> | <a href=".$pg_stat.">Betting stat</a> | <a href=".$pg_main."set=delcookie>Logout</a> ]</b>";
}

echo"<br><br>";



// *** Check if cookie is set *** //
if (!isset($_COOKIE['bet_cookie']) OR $user_lvl < 1)
{   
alert("Not logged in.");
}
else 
{

// *** READ DETAILS *** //
$result = mysql_query("SELECT * FROM $tab_games WHERE DATE_SUB(CURDATE(),INTERVAL 0 DAY) <= datum ORDER BY datum DESC");
while ($data = mysql_fetch_array($result))
{

// ** FETCH FLAGA BUKMACHER ** //
$res_f1 = mysql_query("select * from $bukmacher_flagi WHERE bukmacher_id = '$data[bukmacher]' ");
$flag1_d = mysql_fetch_array($res_f1);

if($data[bukmacher] == 0 || !file_exists($flag1_d[img]) ) { $bukmacher = "img/dyscyplina/default.gif";  }  else { $bukmacher = $flag1_d[img]; }

// ** FETCH FLAGS DYSCYPLINA ** //
$res_f2 = mysql_query("select * from $dyscyplina_flagi WHERE dyscyplina_id = '$data[dyscyplina]' ");
$flag2_d = mysql_fetch_array($res_f2);

if($data[dyscyplina] == 0 || !file_exists($flag2_d[img]) ) { $dyscyplina = "img/dyscyplina/default.gif";  }  else { $dyscyplina = $flag2_d[img]; }


// ** FETCH FLAGS KRAJ** //
$res_f3 = mysql_query("select * from $kraj_flagi WHERE kraj_id = '$data[kraj]' ");
$flag3_d = mysql_fetch_array($res_f3);

if($data[kraj] == 0 || !file_exists($flag3_d[img]) ) { $kraj = "img/dyscyplina/default.gif";  }  else { $kraj = $flag3_d[img]; }


// ** FETCH FLAGS WYNIK** //
$res_f4 = mysql_query("select * from $wynik_img WHERE wynik_id = '$data[wynik]' ");
$flag4_d = mysql_fetch_array($res_f4);

if($data[wynik] == 0 || !file_exists($flag4_d[img]) ) { $wynik = "img/dyscyplina/default.gif";  }  else { $wynik = $flag4_d[img]; }
?>

<html>
<head>
      <title></title>
    </head>
<body>





<table align="center" width="650" cellpadding="0" cellspacing="0">
<tr> 
     <td align="center" width="20"><img src="<?php echo $dyscyplina ?>"</td> 
     <td align="left" width="200"><font face="verdana" size="1"><?php echo $data[team1]; ?> - <?php echo $data[team2]; ?></font></td>
 <td align="center" width="40"><img src="<?php echo $kraj ?>"</td> 
 <td align="center" width="40"><font face="verdana" size="1"><?php echo $data[typ]; ?></font></td>
     <td align="center" width="40"><font face="verdana" size="1"><?php echo $data[kurs]; ?></font></td>
     <td align="center" width="50"> <td><img src="<?php echo $bukmacher ?>"</td>
     <td align="center" width="50"><img src="<?php echo $wynik ?>"</td> 
     <td align="center"> <?php echo " <a href=bet_stat.php?akcja=edytuj&id=$data[g_id]>Edit</a> "?> </td>
     </tr>
   </table>
  

<?php


print "<br>";

print $_GET['akcja'];
print "<br>";
print $_GET['id'];


if ($_GET['akcja']=="edytuj")
{

$query2 = "select from $tab_games where g_id=".$_GET['id'];
$result2 = mysql_query($query2);  
$array=mysql_fetch_array($result2);

print "<form action=bet_stat.php?akcja=wyedytuj&id=".$_GET['id']." method=POST>";


print "<textarea cols=60 rows=10 name=koment>";
print $array['dyscyplina'];
print "</textarea>";

print "<textarea cols=60 rows=10 name=koment>";
print $array['team1'];
print "</textarea>";

print "<textarea cols=60 rows=10 name=koment>";
print $array['team2'];
print "</textarea>";

print "<textarea cols=60 rows=10 name=koment>";
print $array['kraj'];
print "</textarea>";


print "<textarea cols=60 rows=10 name=koment>";
print $array['typ'];
print "</textarea>";

print "<textarea cols=60 rows=10 name=koment>";
print $array['kurs'];
print "</textarea>";

print "<textarea cols=60 rows=10 name=koment>";
print $array['bukmacher'];
print "</textarea>";

print "<textarea cols=60 rows=10 name=koment>";
print $array['wynik'];
print "</textarea>";

print "<input type=submit value=edytuj>";
print "</form>";

}

elseif ($_GET['akcja']=="wyedytuj")
{

$query3="UPDATE $tab_games SET dyscyplina='".$_POST['dyscyplina']."',
team1='".$_POST['team1']."',
team2='".$_POST['team2']."',
kraj='".$_POST['kraj']."',
typ='".$_POST['typ']."',
kurs='".$_POST['kurs']."',
bukmacher='".$_POST['bukmacher']."',
wynik='".$_POST['wynik']."',


where g_id=".$_GET['id'];
$edyt=mysql_query($query3);

if ($edyt)
{
print "Update ok";
}

}
?>












   
   
   
   
   <?php
}
?>
</body>
<?php
}
?>

 

 

So i have the data i click at edit the the new form show up and i have the text fields. If i type something in the fields and click Edit the form  shows  up again and nothing happens :(

I am so confused with this issue i hope someone will help me or show me any good tutorial about editing records in mysql via forms

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.