Jump to content

How to change data with update


demonforce

Recommended Posts

I am working currently on a scool project, where i can insert what i did on a day, its like a day status.

 

But i am doing it like each weak, and because i cant know what i am doing tomorrow, i need to change the data. its like this:

 

 

The adding form

<body bgcolor="#666666">
<form action="http://84.24.104.239/uren/verzondenadduren.php" method="post">
<table width="212" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="68" class="style3">ID</td>
    <td width="144"><div align="center"></div></td>
  </tr>
  <tr>
    <td valign="top" class="style3">Week NR </td>
    <td>      <label>
        <select name="weeknr" id="weeknr" size="1" id="weeknr">
      <option>1</option>
      <option>2</option>
      <option>3</option>
      <option>4</option>
      <option>5</option>
      <option>6</option>
      <option>7</option>
      <option>8</option>
      <option>9</option>
      <option>10</option>
      <option>11</option>
      <option>12</option>
      <option>13</option>
      <option>14</option>
      <option>15</option>
      <option>16</option>
      <option>17</option>
      <option>18</option>
      <option>19</option>
      <option>20</option>
      <option>21</option>
      <option>22</option>
      <option>23</option>
      <option>24</option>
      <option>25</option>
      <option>26</option>
      <option>27</option>
      <option>28</option>
      <option>29</option>
      <option>30</option>
      <option>31</option>
      <option>32</option>
      <option>33</option>
      <option>34</option>
      <option selected="selected">35</option>
      <option>36</option>
      <option>37</option>
      <option>38</option>
      <option>39</option>
      <option>40</option>
      <option>41</option>
      <option>42</option>
      <option>43</option>
      <option>44</option>
      <option>45</option>
      <option>46</option>
      <option>47</option>
      <option>48</option>
      <option>49</option>
      <option>50</option>
      <option>51</option>
      <option>52</option>
      </select>
      </label></td>
  </tr>
  <tr>
    <td valign="top" class="style3">Datum1</td>
    <td><input name="datum1" type="text" id="datum1" maxlength="9999" /></td>
  </tr>
  <tr>
    <td valign="top" class="style3">Bericht1</td>
    <td><textarea name="bericht1" cols="21" rows="10" id="bericht1"></textarea></td>
  </tr>
  <tr>
    <td valign="top" class="style3">Uren1</td>
    <td><input name="uren1" type="text" id="uren1" maxlength="9999" /></td>
  </tr>
  <tr>
    <td valign="top" class="style3">Datum2</td>
    <td><input name="datum2" type="text" id="datum2" maxlength="9999" /></td>
  </tr>
  <tr>
    <td valign="top" class="style3">Bericht2</td>
    <td><textarea name="bericht2" cols="21" rows="10" id="bericht2"></textarea></td>
  </tr>
  <tr>
    <td valign="top" class="style3">Uren2</td>
    <td><input name="uren2" type="text" id="uren2" maxlength="9999" /></td>
  </tr>
  <tr>
    <td valign="top" class="style3">Datum3</td>
    <td><input name="datum3" type="text" id="datum3" maxlength="9999" /></td>
  </tr>
  <tr>
    <td valign="top" class="style3">Bericht2</td>
    <td><textarea name="bericht3" cols="21" rows="10" id="bericht3"></textarea></td>
  </tr>
  <tr>
    <td valign="top" class="style3">Uren3</td>
    <td><input name="uren3" type="text" id="uren3" maxlength="9999" /></td>
  </tr>
  
  <tr>
    <td class="style3"><input type="submit" name="Submit" value="Inzenden" /></td>
    <td><div align="center">
      <input type="reset" name="reset" value="Resetten" />
    </div></td>
  </tr>
</table>
</body>
</html>

 

The send form

<html>
<head>
<title>*</title>
</head>
<body bgcolor="771111">
<?php
$weeknr = $_POST["weeknr"];
$datum1 = $_POST["datum1"];
$bericht1 = $_POST["bericht1"];
$uren1 = $_POST["uren1"];
$datum2 = $_POST["datum2"];
$bericht2 = $_POST["bericht2"];
$uren2 = $_POST["uren2"];
$datum3 = $_POST["datum3"];
$bericht3 = $_POST["bericht3"];
$uren3 = $_POST["uren3"];
?>

<?php

require('mysql.connect.php');

mysql_query("INSERT INTO uren VALUES('','$weeknr','$datum1','$bericht1','$uren1','$datum2','$bericht2','$uren2','$datum3','$bericht3','$uren3')") or die(mysql_error());
echo "<font size='6'>hij staat erin.</font>";
echo "<meta http-equiv='REFRESH' content='10;URL=index.php'>";
?>
</body>
</html>

 

index

<html xmlns="http://www.w3.org/1999/xhtml">



<!-- MENU STYLE -->
<link href="menustyle.css" rel="stylesheet" type="text/css" />
<!-- MENU STYLE -->

<!-- MENU SCRIPT -->
</style>
<script type="text/javascript">
function switchMenu(obj) {
var el = document.getElementById(obj);
if ( el.style.display != "none" ) {
	el.style.display = 'none';
}
else {
	el.style.display = '';
}
}
</script>
<!-- MENU SCRIPT -->

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body background="images/bg/bg.jpg">
<table width="940" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td background="Images/Border/upleft.jpg"> </td>
    <td height="20" colspan="3" background="Images/Border/up.jpg"> </td>
    <td background="Images/Border/upright.jpg"> </td>
  </tr>
  <tr>
    <td width="20" background="Images/Border/left.jpg"> </td>
    <td colspan="3" bgcolor="#999999"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="900" height="150">
      <param name="movie" value="images/Bovenkant/banner.swf" />
      <param name="quality" value="high" />
      <embed src="images/Bovenkant/banner.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="900" height="150"></embed>
    </object></td>
    <td width="20" background="Images/Border/right.jpg"> </td>
  </tr>
  
  <tr>
    <td width="20" background="Images/Border/leftmid.jpg"> </td>
    <td colspan="3" rowspan="2" background="Images/Border/mid.jpg"><img src="Images/Misc/empty.png" width="50" height="1" /><img src="Images/Menu/home.png" width="77" height="21" /><img src="Images/Misc/empty.png" width="50" height="1" /><img src="Images/Menu/oftheshelve.png" width="179" height="21" /><img src="Images/Misc/empty.png" width="50" height="1" /><img src="Images/Menu/costumtemplates.png" width="244" height="21" /><img src="Images/Misc/empty.png" width="50" height="1" /><img src="Images/Menu/contact.png" width="104" height="21" /><img src="Images/Misc/empty.png" width="50" height="1" /></td>
    <td width="20" background="Images/Border/rightmid.jpg"> </td>
  </tr>
  <tr>
    <td width="20" rowspan="2" background="Images/Border/left.jpg"> </td>
    <td width="20" rowspan="2" background="Images/Border/right.jpg"> </td>
  </tr>
  <tr>
    <td width="158" bgcolor="#999999" valign="top">
    <BR>





    </td>
    <td width="585" bgcolor="#CCCCCC" valign="top"><p> </p>
      <p> </p>
      <p><strong>mijn uren</strong><br />
        <br />
<?php
require('mysql.connect.php');




$query = mysql_query("SELECT * FROM uren ORDER BY weeknr DESC LIMIT 3");
while($fetch = mysql_fetch_assoc($query))
{

$totaal = $fetch['uren1'] + $fetch['uren2'] + $fetch['uren3'];

	echo $uren1;
	echo "<div class='wrapper'><a OnClick=\"switchMenu('id".$fetch['id']."');\">".$fetch['weeknr']."</a> <br></div>";
	echo '<div class="test" id="id'.$fetch['id'].'" style="display: none;">

'.$fetch['datum1'].'
<br>
'.$fetch['bericht1'].'
<br>
<br>
'.$fetch['datum2'].'
<br>
'.$fetch['bericht2'].'
<br>
<br>
'.$fetch['datum3'].'
<br>
'.$fetch['bericht3'].'
<br>
<br>
<b>Uren</b><br>
'.$fetch['datum1'].' '.$fetch['uren1'].'<br>
'.$fetch['datum2'].' '.$fetch['uren2'].'<br>
'.$fetch['datum3'].' '.$fetch['uren3'].'<br>
<b>totaal</b> '.$totaal.'
</div>';
}


?>
<br />
<br />
</p></td>
    <td width="157" bgcolor="#999999" valign="top">
    
wheheheheh</td>
  </tr>
  <tr>
    <td width="20" background="Images/Border/downleft.jpg"> </td>
    <td colspan="3" background="Images/Border/down.jpg"> </td>
    <td width="20" background="Images/Border/downright.jpg"> </td>
  </tr>
</table>
</body>
</html>

 

 

now i want an page, where i can see what data is allready added, from a specific week. so if i click on week 22, it shows the adding form, with the data i have added on that week, so i can edit it, and i can update the database with the new information.

 

I have tryd allot of options, but i just cant get it right

Link to comment
Share on other sites

best way is to have a table with one field in it to say which week you're in. Then find out what: ((the current date - (the current year -1))/ 7) is and check that entry against the field of what week you have updated.

 

If the field number is higher than the result of your equation, update, otherwise insert.

 

Hope that helps.

 

Furthermore, rather than manually writing all those options I normally do this:

$i=1;
while($i<=52){
echo'
<option value="'.$i.'">'.$i.'</option>
';
$i++;
}

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.