hey,
while working on my project, i encountered a problem .here's the description-
a teacher is required to insert marks of 15 students.( 15 is just the random no. , it can vary) . so a page is displayed with the roll no. and names with a text box in front of each in which marks have to be entered..a sort of table. and in the end teacher clicks submit.
now please anyone tell me how do get all the values on the php page and insert them in correct order in my database..?? it has to be done through array or some special function, if so , how? or anyone can suggest me a better way to insert the marks..??
arushibafna
0
Newbie Poster
Recommended Answers
Jump to PostDo you mean like this:
//data stored in $arr for ($i=0;isset($arr[$i]);$i++) { mysql_query('INSERT INTO `table` SET `column`="'.mysql_real_escape_string($arr[$i]).'"'); }
Hope it helps.
Jump to PostWell first I see a huge gaping security hole! Never, never use a variable for the table name (Unless the user has no control over this variable, meaning nowhere is it set from a
$_GET,
$_POST
, or$_REQUEST
value).
I would also escape all variables with …
Jump to PostAlso is there such function as mysqli_query(). Is it meant to be mysql_query() like the following?
$query="UPDATE ".$table." SET ".$sub_code."='".mysql_real_escape_string($marks)."' WHERE r.no='".mysql_real_escape_string($r_no)."' LIMIT 1"; mysql_query($query) or die(mysql_error());
Jump to PostYou need to connect to your MySql host first before making queries. Why not try:
mysql_query("root", "", "localhost"); $query="UPDATE ".$table." SET ".$sub_code."='".mysql_real_escape_string($dbc, $marks)."' WHERE no='".mysql_real_escape_string($dbc, $r_no)."' LIMIT 1"; mysql_query($dbc, $query) or die('error');
(The second argument of most MySQL functions is the connection variable which PHP adds or MySQL assumes …
All 14 Replies
cwarn23
387
Occupation: Genius
Team Colleague
Featured Poster
arushibafna
0
Newbie Poster
FlashCreations
20
Posting Whiz
cwarn23
387
Occupation: Genius
Team Colleague
Featured Poster
arushibafna
0
Newbie Poster
arushibafna
0
Newbie Poster
cwarn23
387
Occupation: Genius
Team Colleague
Featured Poster
arushibafna
0
Newbie Poster
arushibafna
0
Newbie Poster
cwarn23
387
Occupation: Genius
Team Colleague
Featured Poster
FlashCreations
20
Posting Whiz
cwarn23
387
Occupation: Genius
Team Colleague
Featured Poster
arushibafna
0
Newbie Poster
venkat0904
1
Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.