Php code that is like a public variable in java?


MYSQL DATA: table schedule

ID | Subject | Day | Slot
1  | Math    | MWF | 1
2  | Math    | MWF | 0
3  | PE      | TTH | 2
4  | Math    | Sat | 0

In the Data above I already get how to subtract the slot to 1 when I ADD Schedule to the student and now I already Confucius when I Delete the Schedule on the student the slot will also update to + 1 to specific subject. I just use the same variable that i use in ADD schedule and i just change the - sign to + sign to add, When I run my code my variable is undefined I use one page only.

Code for update the slot for add schedule then subtract the slot:

textslot = $_post['txtslot'];<br>
textwholenumber = $_post['wholenumber'];<br>
$sql = "UPDATE schedule ". "SET Slot = $textslot - $textwholenumber".  "WHERE Subject = '$textsubject' and Day = '$textday'";

Code for update the slot for delete schedule then add the slot:

$sql = "UPDATE schedule ". "SET Slot = $textslot + $textwholenumber".  "WHERE Subject = '$textsubject' and Day = '$textday'";

the$textslot and$textwholenumber in the delete code is undefined?




  1. You need to prefix variable name with the$ symbol to declare a variable, try this;

    $textslot = $_POST['txtslot'];
    $textwholenumber = $_POST['wholenumber'];
  2. The<br> elements are not valid PHP, end the PHP code with the closing?> or use theecho function to output these linebreaks. I suspect you don't need them at all, try removing them altogether.

  3. Read up on SQL Injection, your SQL statement is exposed to this. Try parametised queries to overcome this.

Hope it helps!

People are also looking for solutions to the problem: html - PHP Function multiple parameters


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.