Jump to content

UPDATE query ..Urgent


ihatephp

Recommended Posts

This is evaluation.php

I want to do an evaluation of my project mates.

So, in the homepage,

 

Example,

Name1 : evaluate

so after evaluating this name1,

the status of name1 will be changed to

Name1:DONE

 

 

Currently,my codes dosent allow tht status to update to DONE

Sorry if there is any noob mistakes in my codes as i really do not understand php much.

Hope i can get help fast as project dateline is nearing..

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Evaluation</title>
<style type="text/css">

.style1 {color: #FFFFFF}
.style1 {font-size: 9px}
.style2 {font-size: 10px}
.style3 {font-size: 10; }
.style8 {font-size: 12px}
.style9 {
font-size: 14px;
font-weight: bold;
}
.style10 {font-size: 12px; color: #FFFFFF; }
.style11 {
font-size: 16px;
font-weight: bold;
}
</style>
</head>


<body class="style3">

<form action="p_evaluation.php " method="POST" class="style1" onSubmit="return valbutton(this);">
<name ='evaluate'>


<table width="938" height="397" border="0">
  <tr>
    <td width="520" class="style3"><u><span class="style11">Team Evaluation</span></u>
      <p class="style9"> name 1
      <table width="395" border = "1">
        <tr>
          <th width="253" bgcolor="#000000">Question</th>
          <th width="21">SD</th>
          <th width="20">D</th>
          <th width="21">N</th>
          <th width="20">A</th>
          <th width="20">SA</th>
        </tr>
      </table>
      <table border = "1">
        <tr>
          <th width="254"><span class="style8">Did he/she complete the work?</span></th>
          <th width="20"><label>
            <input name="radiobutton" type="radio" value="radiobutton" />
          </label></th>
          <th width="20"><input type="radio" name="id"/></th>
          <th width="20"><input type="radio" name="id"/></th>
          <th width="20"><input type="radio" name="id"/></th>
          <th width="21"><input type="radio" name="id"/></th>
        </tr>
      </table>
      <table border = "1">
        <tr>
          <th width="254"><span class="style8">Did she work well?</span></th>
	  
          <th width="21"><input type="radio" name="id1"/></th>
          <th width="20"><input type="radio" name="id1"/>          </th>
          <th width="20"><input type="radio" name="id1"/></th>
          <th width="20"><input type="radio" name="id1"/></th>
          <th width="21"><input type="radio" name="id1"/></th>
        </tr>
        <p> </p>
      </table>
      <p class="style9">name 2
      <table width="395" border = "1">
        <tr>
          <th width="253" bgcolor="#000000">Question</th>
          <th width="21">SD</th>
          <th width="20">D</th>
          <th width="21">N</th>
          <th width="20">A</th>
          <th width="20">SA</th>
        </tr>
      </table>
      <table border = "1">
        <tr>
          <th width="254"><span class="style8">Did she complete the work?</span></th>
          <th width="20"><input type="radio" name="SD"/></th>
          <th width="20"><input type="radio" name="SD"/></th>
          <th width="20"><input type="radio" name="SD"/></th>
          <th width="20"><input type="radio" name="SD"/></th>
          <th width="21"><input type="radio" name="SD"/></th>
        </tr>
      </table>
      <table border = "1">
        <tr>
          <th width="254"><span class="style8">Did she work well?</span></th>
          <th width="21"><input type="radio" name="D"/></th>
          <th width="20"><input type="radio" name="D"/>          </th>
          <th width="20"><input type="radio" name="D"/></th>
          <th width="20"><input type="radio" name="D"/></th>
          <th width="21"><input type="radio" name="D"/></th>
        </tr>
        <p> </p>
      </table>
      <p class="style9">name 3
      <table width="395" border = "1">
        <tr>
          <th width="253" bgcolor="#000000">Question</th>
          <th width="21">SD</th>
          <th width="20">D</th>
          <th width="21">N</th>
          <th width="20">A</th>
          <th width="20">SA</th>
        </tr>
      </table>
      <table border = "1">
        <tr>
          <th width="254" class="style10">Did she comlete the work?</th>
          <th width="20"><input type="radio" name="N"/></th>
          <th width="20"><input type="radio" name="N" /></th>
          <th width="20"><input type="radio" name="N" /></th>
          <th width="20"><input type="radio" name="N"/></th>
          <th width="21"><input type="radio" name="N"/></th>
        </tr>
      </table>
      <table border = "1">
        <tr>
          <th width="254"><span class="style8">Did she work well?</span></th>
          <th width="21"><input type="radio"name="A" /></th>
          <th width="20"><input type="radio"name="A" />          </th>
          <th width="20"><input type="radio"name="A"/></th>
          <th width="20"><input type="radio"name="A"/></th>
          <th width="21"><input type="radio"name="A"/></th>
        </tr>
        <p> </p>
      </table>

    <p></p></td>
    <td width="402"><p class="style9"><u>my evaluation</u></p>
    <p class="style9">my name
    <table width="395" border = "1">
      <tr>
        <th width="253" bgcolor="#000000"><span class="style2 ">Question</span></th>
        <th width="21">SD</th>
        <th width="20">D</th>
        <th width="21">N</th>
        <th width="20">A</th>
        <th width="20">SA</th>
      </tr>
    </table>
    <table border = "1">
      <tr>
        <th width="254"><span class="style8">Did I complete the work?</span></th>
        <th width="20"><input type="radio" name="SA" /></th>
        <th width="20"><input type="radio" name="SA"/></th>
        <th width="20"><input type="radio" name="SA"/></th>
        <th width="20"><input type="radio" name="SA"/></th>
        <th width="21"><input type="radio" name="SA"/></th>
      </tr>
    </table>
    <table border = "1">
      <tr>
        <th width="254"><span class="style8">Did i work well?</span></th>
        <th width="21"><input type="radio" name="self" /></th>
        <th width="20"><input type="radio" name="self"/>        </th>
        <th width="20"><input type="radio" name="self" /></th>
        <th width="20"><input type="radio" name="self"/></th>
        <th width="21"><input type="radio" name="self"/></th>
      </tr>
      <p> </p>
    </table>
    <p> </p>
    <p> </p>
    <p> </p>
    <p> </p>
    <p> </p>
    <p> </p>
    <p> </p>
    <p> </p>
    <p>  
<p><INPUT type="submit" value="submit" onClick="return confirm('Submit evaluation?')">  
<input type="reset" name="reset" value="Clear" />
</form>

</p>
</td>
    <p class="style3">
  </tr>
      
  </form> 
      
  </table>
      
  
    </p>

 

 

This is p_evaluation.php

 

<?php
session_start();
?>

<?php

include 'config.php';
include 'opendb.php';
?> 

<?php
//include database configuration and connect
include 'config.php';
include 'opendb.php';

function updateDetails()
{
$id = $_SESSION['id'];
$id1 = $_POST['id1'];
$SD = $_POST['SD'];
$D = $_POST['D'];
$N = $_POST['N'];
$A =$_POST['A'];
$SA =$_POST['SA'];
$self =$_POST['self'];

$query="INSERT INTO question (id,id1,SD,D,N,A,SA,self) VALUES ('$id','$id1','$SD','$D','$N','$A','$SA','$self')";
mysql_query($query) or die(mysql_error());

$query = "UPDATE question SET id='$id',id1= '$id1', SD= '$SD',D= '$D',N= '$SN',SA= '$SA',SA= '$SA',self= '$self' ";
 	mysql_query($query) or die("Unable to execute query");



echo "Evaluation Done.<br>";
include 'closedb.php';
}
?>
   

Link to comment
Share on other sites

You've defined a function, but havent executed it. Either remove the "function updateDetails()" part(and the opening and closing curly braces) or just do

 

updateDetails();

 

after the closing curly brace.

 

I changed it to updateDetails(); already and got this error

Fatal error: Call to undefined function updateDetails() on line 23

 

Link to comment
Share on other sites

what he means is.. you defined a function, in order to execute the function you need to call it. All a function is needed for is for code reuse, say you want a function that grabs the name of the user, its much easier to make a function for this and call the function instead of type all the code to grab the persons name, get it? So what you did is create a function, but you never called it.

 

So either call the function, like this

function_name_here();

 

Or just remove the line that says, hey this is a function, and it should work.

Link to comment
Share on other sites

what he means is.. you defined a function, in order to execute the function you need to call it. All a function is needed for is for code reuse, say you want a function that grabs the name of the user, its much easier to make a function for this and call the function instead of type all the code to grab the persons name, get it? So what you did is create a function, but you never called it.

 

ok,i kinda get you..

so how should i go about calling the function?

Link to comment
Share on other sites

what he means is.. you defined a function, in order to execute the function you need to call it. All a function is needed for is for code reuse, say you want a function that grabs the name of the user, its much easier to make a function for this and call the function instead of type all the code to grab the persons name, get it? So what you did is create a function, but you never called it.

 

ok,i kinda get you..

so how should i go about calling the function?

 

so what I said didn't make sense? Are you new to php?

Link to comment
Share on other sites

what he means is.. you defined a function, in order to execute the function you need to call it. All a function is needed for is for code reuse, say you want a function that grabs the name of the user, its much easier to make a function for this and call the function instead of type all the code to grab the persons name, get it? So what you did is create a function, but you never called it.

 

ok,i kinda get you..

so how should i go about calling the function?

 

so what I said didn't make sense? Are you new to php?

 

ya new to php,very weak basics...sry

but need to get it done fast due to dateline..

Link to comment
Share on other sites

what he means is.. you defined a function, in order to execute the function you need to call it. All a function is needed for is for code reuse, say you want a function that grabs the name of the user, its much easier to make a function for this and call the function instead of type all the code to grab the persons name, get it? So what you did is create a function, but you never called it.

 

ok,i kinda get you..

so how should i go about calling the function?

 

so what I said didn't make sense? Are you new to php?

 

 

ya new to php,very weak basics...sry

but need to get it done fast due to dateline..

 

 

 

ok so basically you have functions, which make it easier to process code(without having to retype the code if you use it on more than one page). Just defining a function in itself does nothing. You have to execute it. Like you may have FF, but you can't browse the web unless you open it up. So if you create a function and tell what it does, that's awesome. Thing is, you have to execute it for it to do anything.

 

In your original code, you have some code, then you have a function defined(everything between the curly braces). And then after that you have the end of the file. It won't execute that function unless... AFTER(i'm not sure if it matters if it's before or after the function, it matters in C, thats all I know) the function is define, you execute it. So once you make function(), you have to go to the place you want to execute it and go

 

function();

 

otherwise, you can write as many functions you want in any page but they won't do a single thing until they're executed.

 

So go to your original code(what you first posted). and AFTER the closing curly brace of the function, type this on the following line, exactly:

updateDetails();

 

and it should do what you need(provided the function doesn't have errors in it)

 

 

QUICK EDIT: you need to do addslashes() on all your $_POST variables. Just inserting them as is will cause an error to occur if you insert something with a single quote.

Link to comment
Share on other sites

<?php
function updateDetails(){

$id = $_SESSION['id'];
$id1 = $_POST['id1'];
$SD = $_POST['SD'];
$D = $_POST['D'];
$N = $_POST['N'];
$A =$_POST['A'];
$SA =$_POST['SA'];
$self =$_POST['self'];

$query="INSERT INTO question (id,id1,SD,D,N,A,SA,self) VALUES ('$id','$id1','$SD','$D','$N','$A','$SA','$self')";
mysql_query($query) or die(mysql_error());

$query = "UPDATE question SET id='$id',id1= '$id1', SD= '$SD',D= '$D',N= '$SN',SA= '$SA',SA= '$SA',self= '$self' ";
 	mysql_query($query) or die("Unable to execute query");

}
updateDetails();

echo "Evaluation Done.<br>";
include 'closedb.php';

?>

 

I've edited it but the status still dosent change to DONE.

I added this at homepage.php.

removing the btm below still dosent work...

$submitted = true;
if ($submitted){
print "Done! ";
}
else{
echo "error";
}
[code]

[/code]

Link to comment
Share on other sites

Which value are you trying to change to done? Do you mean a value inserted into the database? Or just the words "done" printed on the screen?

 

 

EDIT. I see where your mistake might be. Your first query is inserting a row into the database. But your second query is assigning the current values to every row in the database. You need to have it like "UPDATE table set blahblahblah WHERE something='$id' " or whatever. you have to have a WHERE in an UPDATE or else it'll apply the values to everything.

 

And if that still doesnt set whatever you want to done, then you need to halt the script before it gets to the query, and echo out all the values you're trying to insert into a row.

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.