473,385 Members | 1,587 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

update mysql database with lots of varabiles in the query

tolkienarda
316 100+
i need to update a database table using variables in unusual places here are the update statements
Expand|Select|Wrap|Line Numbers
  1. mysql_query("UPDATE 'grades' SET '$class' = '$grade' WHERE student='$student'");
  2. mysql_query("UPDATE 'assignments' SET '$class' = '$grade' WHERE student='$student'");
  3. mysql_query("UPDATE 'comments' SET '$class' = '$grade' WHERE student='$student'");
  4.  
now i was just showed by ron how to recive post stuff and that is where the variables come from so i am not even sure if i am getting the variables from the other page. i did try to display all of those variables but with my php skills the echo options might have their own problems so here is the rest of the code

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  5. <title>Untitled Document</title>
  6. <?
  7.  
  8. session_start(); // Use session variable on this page. This function must put on the top of page.
  9. if(!session_is_registered("teacher")){ // if session variable "username" does not exist.
  10. header("location:login.php"); // Re-direct to index.php
  11. }
  12.  
  13. ?>
  14. <?
  15. // Connect database.
  16. $host="localhost"; // Host name.
  17. $db_user="rcadmin"; // MySQL username.
  18. $db_password="nsds2004"; // MySQL password.
  19. $database="RCA"; // Database name.
  20. $RCA = mysql_pconnect($host, $db_user, $db_password) or trigger_error(mysql_error(),E_USER_ERROR);
  21.  mysql_select_db($database, $RCA);
  22.  $login=$_POST('login');
  23.  $class=$_POST('job_select');
  24.  $grade=$_POST('job_select');
  25.  $assignment=$_POST('job_select');
  26.  $comments=$_POST('job_select');
  27. //this section updates the database
  28. $grade = "grade";
  29. $assignments = "assignments";
  30. $comments = "comments";
  31. $student = "student";
  32. $class = "class";
  33. if (isset($_POST['grade']))
  34.   $grade = strip_tags($_POST['grade']);
  35. if (isset($_POST['assigments']))
  36.   $assignments = strip_tags($_POST['assignments']);
  37. if (isset($_POST['comments']))
  38.   $comments = strip_tags($_POST['comments']);
  39. if (isset($_POST['student']))
  40.   $student = strip_tags($_POST['student']);
  41. if (isset($_POST['classs']))
  42.   $class = strip_tags($_POST['classs']);
  43.  
  44.  
  45. mysql_query("UPDATE 'grades' SET $class = '$grade' WHERE student='$student'");
  46. mysql_query("UPDATE assignments SET '$class' = '$grade' WHERE student='$student'");
  47. mysql_query("UPDATE comments SET $class = '$grade' WHERE student='$student'");
  48. ?>
  49.  </head>
  50.  
  51. <body>
  52. <?
  53.     echo $grade, "<br />";
  54.     echo $assignments , "<br />";
  55.     echo $comments , "<br />";
  56.     echo $student , "<br />";
  57.     echo $class , "<br />";
  58.  
  59. ?>
  60. </body>
  61. </html>
  62.  
Jan 17 '07 #1
1 1973
tolkienarda
316 100+
never mind i am stupid
Jan 18 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Mark | last post by:
A beginner in this area, I have been able to read a record from a MySQL database and populate an HTML form (wow!). Now, my goal is to allow the user to edit the contents of the form and then...
1
by: Bob Kaku | last post by:
I'm trying to retrieve a text value from a MySQL database, put it into an updateable form, allow edits, and send back the edited text back into the MySQL database. I've been able to successfully...
4
by: alex | last post by:
Hi. I am making a page that lots of data on the first page that I want links displayed in a random order. If lots of people are looking at it, would I be better using a page that uses arrays and...
7
by: sime | last post by:
Hi, I have a blob field in a mysql database table. I want to copy a blob from one record to another. I am having trouble transferring the data via a php variable. Maybe I need to addslashes or...
4
by: whitemoss | last post by:
Hi, I've made some changes to my coding..but unfortunately, there were errors when compiling it..dunno how to solve it..hope anyone can help me...the errors: client.c: In function senddata:...
7
by: Daz | last post by:
Hi. I am trying to select data from two separate MySQL tables, where I cannot use join, but when I put the two select queries into a single query, I get an error telling me to check my syntax. Both...
3
by: eholz1 | last post by:
Hello PHP programmers. I had a brilliant idea on one of my pages that selects some data from my mysql database. I first set the page up to display some info and an image, just one item, with a...
13
by: Ciaran | last post by:
Hi All, Is it faster to have mySql look up as much data as possible in one complex query or to have php do all the complex processing and submit lots of simple queries to the mysql database? ...
11
by: stantron | last post by:
Setup: I only have one database with one table in it. The first page has a form that adds a record (w/ 6 fields in it) to the mySQL database's lone table via PHP. This works fine. I also have a PHP...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.