473,587 Members | 2,487 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

update mysql database with lots of varabiles in the query

tolkienarda
316 Contributor
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 1987
tolkienarda
316 Contributor
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
10548
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 update the record in MySQL. The problem is, as soon as the "Update" button (type="submit") is pressed, all of the data disappear from the form. How...
1
5273
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 retrieve the text and put it into the editable form, using htmlspecialchars function. But, I can't find a way of accepting the edited text and...
4
1798
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 shuffle(), or would I be ok to use mysql. If there are over a hundred visitors a day, would mysql be making the site slow? I don't know much about...
7
11453
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 convert to Hex or something. I've tried a few things but can't quite get it. Here is simplified code. mysql_select_db($dbname, $connection);
4
3161
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: client.c:147: error: incompatible implicit declaration of function UpdateStatus client.c:37: error: previous implicit declaration of UpdateStatus was...
7
2718
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 of the queries work fine when I use them to query the MySQL server directly. My guess is that the MySQL extension only expects a single resource...
3
2668
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 row of data, etc. then I thought it would be nice to do a select, and perhaps an update (the title of the image) on the same page.
13
3411
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? Cheers, Ciarán
11
4273
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 table that displays all records in my database on this same page. This too works fine. I have my table set up so that there is a 7th field, called...
0
7920
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7849
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8347
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7973
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5718
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5394
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3844
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2358
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.