Retrive a Student record From mysql

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hemin
Forum Newbie
Posts: 3
Joined: Wed Nov 16, 2005 4:38 am
Contact:

Retrive a Student record From mysql

Post by hemin »

hi all there;
any body can help me with this problem ,
i have atable of students degree (marks) which is thousands of records ;

the structure of the table Students_copy;

CREATE DATABASE hn;
USE hn;
--
-- Table structure for table `hn`.`students_copy`
--
CREATE TABLE `students_copy` ( `examid` text,
`student_name` varchar(255) character set utf8 collate utf8_unicode_ci default NULL,
`kurdish` varchar(10) default NULL,
`arabic` varchar(10) default NULL,
`english` varchar(10) default NULL,
`sociality` varchar(10) default NULL,
`mathmatic` varchar(10) default NULL,
`biology` varchar(10) default NULL,
`chemistry` varchar(10) default NULL,
`physics` varchar(10) default NULL,
`sum` varchar(10) default NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='InnoDB free: 4096 kB; InnoDB free: 10240 kB';
--

--
INSERT INTO `students_copy` (`examid`,`student_name`,`kurdish`,`arabic`,`engli sh`,`sociality`,`mathmatic`,`biology`,`chemistry`, `physics`,`sum`) VALUES
('3726','ÆÇÑÇã ÓÚÏì Úáì','66','50','50','71','54','56','37','31','415' ),
('3727','ÆÇÑÇã Úáì ÇÍãÏ','65','62','54','67','60','84','64','77','533 '),
('3728','ÆÇÑÇã ÝÊÇÍ ÞÇÏÑ','63','58','50','61','31','61','38','54','416 '),
('3729','ÆÇÑì ÕÇÈÑ ÚÒíÒ','50','38','29','57','19','29','10','51','283 '),
('3730','ÆÇÓÄ ËæÔæ ßÑíã','63','54','50','71','50','64','54','56','462 '),
('3731','ÆæãíÏ ÍÓä ßÑíã','56','50','27','55','50','54','29','51','372 '),
('3732','ÆæãíÏ ãÌíÏ ÚãÑ','67','66','58','61','73','75','50','56','506' ),
('3733','ÆæãíÏ ãÍãÏ ÇÈÑÇåíã','64','57','51','65','51','62','30','53',' 433'),
('3734','ÇÍãÏ ÆÇÏã ÇÍãÏ','56','66','34','60','56','72','59','54','457 '),
('3735','ÇÍãÏÎÇä ÚæáÇÎÇä','61','50','32','71','50','60','50','63',' 437'),
('3736','ÇÍãÏ ÕÇÈÑ ÑÓæá','63','50','37','56','33','74','52','64','429 ');
.
.
.
etc....

which has thousands of records but i didnt put all of them because this post will be full of names but here is some sample of it .




and i want to make a page to search a student record just when he inputs his examid html form .
and i maked an html form see it which is named search_students.html ;

<html>
<head>
<title>search for a student</title>
</head>
<body>
<h2>Search for a student degree</h2>
<br>
<form action="students_copy.php" method="post">
Please enter the ID of the Student Exam :
<br>
<input examid="examid" type=text>
<br>
<input type=submit value="search">
</form>
</body>
</html>


and i maked a php script to retrive the table which is named
students_copy.php you can see it;

<?php
$db=mysql_connect("myhost_name","myuser_name","my_ pw");
mysql_select_db("hn",$db);
$query="select * from students_copy where examid like '%".$examid."%'";
$result=mysql_query($query);
while ($record=mysql_fetch_assoc($result)){
while (list($fieldname,$fieldvalue)=each($record)){
echo $fieldname.":<b>".$fieldvalue."</b><br>";
}
echo "<BR>";
}
?>


and this script not work and outputed to me ;
Notice: Undefined variable: examid in C:\Program Files\Apache Group\Apache2\htdocs\hemin\students_copy.php on line 4
and
all the databases content with this error


can any one help me to give approprite script to retrive one record that validate with the input examid and out put only the record that inputed in html form to just this student.


thanks for your help.....
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Code: Select all

<input examid="examid" type=text>
That should actually be

Code: Select all

<input name="examid" type=text>
and rather than trying to access it with $examid which requires register_globals to bo on (which is bad, very bad! ;)) you should be accessing it from $_POST['examid'].
hemin
Forum Newbie
Posts: 3
Joined: Wed Nov 16, 2005 4:38 am
Contact:

Retrive a Student record From mysql

Post by hemin »

hi;
i had changed this one and its still the same problem ...
can you give me more advance sugesstion to make that with $_POST['examid'] because im new to the php ...
thanks.
Post Reply