Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,208,672 members, 8,003,342 topics. Date: Friday, 15 November 2024 at 11:43 AM |
Nairaland Forum / Science/Technology / Webmasters / Post your PHP Problems Here (64992 Views)
Thread For All Your Blogging Related Problems Here / Get And Request For Your Php Problems Here / Connecting To Your Gmail Account From Your Php Application. (2) (3) (4)
(1) (2) (3) (4) (5) (6) (7) (8) (9) (10) ... (20) (Reply) (Go Down)
Re: Post your PHP Problems Here by dcitizen1: 4:20pm On Oct 13, 2013 |
If the table contain the following subjects and grade by various student from science, commercial and art , how will i display the result of a student only dat offer science subject and grade. Hope u get me Example, Table contain the following field English: A1 Math Crk Accounting: Physics And i want to query result for a science student without including the subject for commercial and art student. How will i go by it? Pls, i need ur help |
Re: Post your PHP Problems Here by adewasco2k(m): 5:17pm On Oct 13, 2013 |
^when dealing with database, don't look at it like your normal spreadsheet. Try normalizing your tables. There are many ways you can achieve what you seek. You can have a table holding students details with a column which will signify if a student is a science student, commercial or art also a column for student_id So on your result table You should have all results in this format. Student_id, subjects, mark So if you a result of a science student, you should not be concern about art, because the student will only have results for subjects he is offering. So all you have to do is, SELECT subject, mark FROM results_table WHERE student_id=$x Now the variable $x hold the student Id from the student details table. So with such aproach I dnt see you having problems if a student is science student or not. You might even go further to have a table for subjects, so you have subject_id, subject_name. So on your result you have a foreign key subject_id. Which will be referencing the subject_id on the subject table. This looks simple to me, but still I dnt think you are giving key details of what you are doing and what you want to achieve |
Re: Post your PHP Problems Here by dcitizen1: 6:12pm On Oct 13, 2013 |
@ adewasco2k have u seen a waec broadsheet. It contains result of students dat offer science, commercial and art based subject togther. I need a clue on how to extract the result of each student without including other subject . It is not compulsory for all science student or commercial or art to offer the same subject. . I need a guide pls. i donot need separate table for science, commercial and art students result |
Re: Post your PHP Problems Here by adewasco2k(m): 9:05pm On Oct 13, 2013 |
d citizen: That is why I keep seeking more details, I think I understand what you want now. If I understand you well, you want if for example a science student is to check his result, only science subjects should appear irrespective if he sat for the paper? That's still simple enough, this are no maggic, you have to signify it. Somewhere on the table. As I suggested, you should have a table for subjects So you can have subject_table with columns, subject_id, subject_name, subject_category. So you can have for example: Subject_id | subject_name | subject_category. | 1 | physic | 1 | 2 | mathematics | 2 | 3 | commerce | 3 | 4 | government. | 4 | 5 | english | 2 | 6 | lit english | 4 | I am sorry I am on mobile can't say much but what I am trying to do it set all the subjects into different categories: general, like english and math, art subjects, commercial subjects, science subjects So when you want to query your database just use LEFT JOIN on the subject where subject.subject_category IN (2, 1 ) for a science student. Since 2 is for general subject and 1 for sciences. This is just an eye opener to how you can achieve that, please try to do something then post then we can help from there. |
Re: Post your PHP Problems Here by sunday478(m): 11:26pm On Oct 13, 2013 |
Re: Post your PHP Problems Here by dcitizen1: 7:33am On Oct 14, 2013 |
@ adewasco2k, How will i display the subjects and respective grade of each student. Let me give u a hint of the broadsheet Id name reg eng mth phy chem govt leng 1 ab 02 a1 b2 c4 b1 nil nil 2 kb 05 b2 c2 nil nil b3 nil 3 ch 07 a1 c1 nil nil b2 a1 I want the table of this result to be query using the reg to display as follow: Ab Eng: a1 Mth: b2 Phy: c4 Chem: b1 |
Re: Post your PHP Problems Here by adewasco2k(m): 7:52am On Oct 14, 2013 |
^now I know your problem, like I have said before, database is not like excel, you will not get good result from your present design. But if you insist to carry on with it then use, SELECT name, eng, math, etc. (List all subjects) FROM results WHERE reg=1 AND (eng, math, etc (list all subjects again)!=NULL mind you, you will get a column of name, eng, math ..... If you want to have it list you said having all the subjects in a column and not roll then your best bet is PiVOT but as I have said your approach is wrong. With what I did above you will still achieve your aim, after getting the result in that format, you will use php to arrange it like you want. If less work on my table today, will code it for you. Have a wonderful monday |
Re: Post your PHP Problems Here by Nobody: 11:47am On Oct 14, 2013 |
Elvisten10: A demo of this can be found on www.xmx me.com/search.php?string=bank . Remember to change the $url in search.php from www.xmx me.com to www.yourwebsite.com and the $webPage in search.php also from payment.php to the static page you want to search for example index.html. Thanks Bro.. I'll test run it when am on PC.. That's thoughtful of u.. |
Re: Post your PHP Problems Here by dcitizen1: 1:24pm On Oct 14, 2013 |
@ adewasco2k, Thank you so much but i will like u to send me a format for the table and php based on what i required to my email: francisakwari@hotmail.com. Thanks once again. I look forward to ur response. |
Re: Post your PHP Problems Here by Elvisten10(m): 4:55pm On Oct 14, 2013 |
d citizen:I think you should learn mysql or learn more on database, thats the best help you can get. Your view of a database is not just it, you might have some tough time working with adewasco2k solution. @adewasco2k, if possible post the code here, it will help others that might be interested in such now or in the future *grins*. |
Re: Post your PHP Problems Here by Elvisten10(m): 4:57pm On Oct 14, 2013 |
Djangocode:ok, inform me when you are done and maybe a link to the site. |
Re: Post your PHP Problems Here by Nobody: 6:00pm On Oct 14, 2013 |
Elvisten10: ok, inform me when you are done and maybe a link to the site. Am Running On Localhost though..(Wamp Things).. Will get back to u.. |
Re: Post your PHP Problems Here by adewasco2k(m): 11:46pm On Oct 14, 2013 |
^^I did it, major work was just on the database design, had to even to 'over normalization' to show him how it works working with such. I will share results tomorrow morning when connected via PC. |
Re: Post your PHP Problems Here by Elvisten10(m): 10:27am On Oct 15, 2013 |
Djangocode:ok |
Re: Post your PHP Problems Here by adewasco2k(m): 12:29pm On Oct 15, 2013 |
This is so long, i hope you get it, just trying to show you all you might need to know and i didnt do any php, just the database stuff, that is what you first need to get right. I will take it step by step. STEP 1 created a database "resultChecker" CREATE DATABASE resultChecker; STEP 2 creating tables in the database i. create table in the database 'categories' CREATE TABLE IF NOT EXISTS `categories` We need to add some dummy contents to work with: INSERT INTO `categories` ii. created table in database 'subjects'
add foreign keys, may be you should read about foreign keys ALTER TABLE `subjects` to add dummy content: INSERT INTO `subjects` (`stubjectID`, `name`, `cat_id`) iii.created a table in database 'students' CREATE TABLE IF NOT EXISTS `students` add foreign key: ALTER TABLE `students` add dummy content: INSERT INTO `students` (`studentID`, `sname`, `cat_id`, `reg_no`, `year`, `center`) iv. created a table called 'results' CREATE TABLE IF NOT EXISTS `results` add foreign key:
to add contents: INSERT INTO `results` (`student_id`, `subject_id`, `grade`) This shows the relationship between the tables: with all these all you need to do is query your tables to get all you want. example 1 to get the results of student with studentID of 2 which is 'Jane Django'
result: example 2 to get the result of a student with a name seun who is the art student here SELECT subjects.name, results.grade FROM subjects, results WHERE subjects.stubjectID=results.subject_id results: example 3 to get the details of a student like year of exam, exam center and registration number using his name to find it or his reg no SELECT * FROM students WHERE sname LIKE('%seun%') or SELECT * FROM students WHERE reg_no='4012387DF' results example 4: you can equally get the list of subjects that the student offers and the corresponding grades even if the student didnt write the exam. //for example if a science student didnt write chemistry exam the result will be like english | C6 here i have delete the physic result of the science student, see how i will query the table now using LEFT JOIN: SELECT subjects.name, results.grade FROM subjects result: so now you have your database all you have to do is add more details to the table as you wish i just did it simple to make it clearer. cheers 1 Like |
Re: Post your PHP Problems Here by adewasco2k(m): 12:45pm On Oct 15, 2013 |
^ anything that you dont understand just ask, will explain further my assumptions which may or may not be correct 1. science students offers chemistry and physic 2. art students offers government and literature in english 3. commercial students offers commerce and geography 4. english and mathematucs is a general subject |
Re: Post your PHP Problems Here by sunday478(m): 10:34am On Oct 16, 2013 |
adewasco2k: ^ anything that you dont understand just ask, will explain further^^ this question may reveal how mediocre I am but I want to know. At ur previos post of those code and pics, is it that u are using a software or is it the codes that that brought the Edit, copy ETC. I want to learn how to work with Dbase. |
Re: Post your PHP Problems Here by adewasco2k(m): 10:55am On Oct 16, 2013 |
sunday478: Just as I said, I did it on MySQL database alone, so that is just the interface of MySQL database. Install XAMPP it has MySQL, filezilla, apache and other cool stuffs. When working on such projects 70% of concentration should be on the database, if you get the database right then you can always manipulate it any how to send data to the view part of the project. Like in the above example I made all the guy need to do is put those data into an array then use foreach() function to display them |
Re: Post your PHP Problems Here by dcitizen1: 7:17pm On Oct 16, 2013 |
Thanks adewasco2k, I get ur hint dat u have given to me but i will try and learn more on mysql database. I need more help. I want you to guide me in creating a php code for a registration form dat extend to two page or more pages with next on each page and with submit button on last page. But i want the data to be submitted to a table in the data base register. Need ur insight pls. |
Re: Post your PHP Problems Here by adewasco2k(m): 9:15pm On Oct 16, 2013 |
d citizen: You don't need to worry too much on that just use jquery UI's Tab that will work the magic |
Re: Post your PHP Problems Here by Elvisten10(m): 9:25pm On Oct 16, 2013 |
d citizen:ok then, am not a html guy. |
Re: Post your PHP Problems Here by adewasco2k(m): 9:53pm On Oct 16, 2013 |
^@Elvis what I think is is try to achieve is let say page 1 carries name, age and date of birth page 2 carries class, height and page 3 carries parent's name, occupation then on page 3 you click submit and all data typed in on page 1,2,3 now stored on the database with a single SQL statement. That can be achieve like this, they are viewed as pages but actually they are not, the three categories of form will be in three different div's with next button on page1 and page2 and submit on page3 On first view div2 and div 3 are hidden only div 1 shown, when you click on next button on div 1, div 1 becomes hidden and div2 visible when you click on next button on div2 the final div3 shows and all others hidden now there is a submit button when clicked the POST/GET holds all typed data on div1,div2 and div3 so now you can submit it. |
Re: Post your PHP Problems Here by dcitizen1: 1:06am On Oct 17, 2013 |
@ adewasco2kYes, dat is exactly what i intend to achieve. I will like you to help me out |
Re: Post your PHP Problems Here by sunday478(m): 12:51pm On Oct 17, 2013 |
adewasco2k:my boss, btween Wam and XAMPP which should I downlaod. Because someone suggest wamp and u suggested xampp. |
Re: Post your PHP Problems Here by Nobody: 2:38pm On Oct 17, 2013 |
sunday478: my boss, btween Wam and XAMPP which should I downlaod. Because someone suggest wamp and u suggested xampp. U can use wamp or xampp.. They are all the same thing.. I use wamp.. When u download and install, Change ur browser homepage to http://localhost. When u start the wamp server, wait for the icon to turn green.. Then click on it and select "Start all Services".. After that, open yo browser and type localhost on the address bar if u have not set the homepage to localhost already.. Yo PhP files should be saved in the C - wamp - www folder.. Assuming u create a script like <?php $wand = Success; echo $wand; ?> Save this as wand.php or anything u like and copy the file to the www folder inside the wamp installation directory.. Then go to the browser and type http://localhost/wand.php and u'll see Success on the page.. Hope u Understand.. |
Re: Post your PHP Problems Here by sunday478(m): 3:57pm On Oct 17, 2013 |
^^Yeah, I understand. Just the wampXamp stuff now. Am yet to download it. |
Re: Post your PHP Problems Here by adewasco2k(m): 7:50pm On Oct 17, 2013 |
^you can go for any, they will all deliver what you want, I have both on my pc but I make use of xampp |
Re: Post your PHP Problems Here by sunday478(m): 2:18pm On Oct 18, 2013 |
adewasco2k: ^you can go for any, they will all deliver what you want, I have both on my pc but I make use of xamppok, thanks |
Re: Post your PHP Problems Here by bowofolu(m): 3:11pm On Oct 18, 2013 |
I have problems making upload scripts. Can you help me on that. I don't have a good knowledge of php. How do i learn php. |
Re: Post your PHP Problems Here by dexed(m): 6:44pm On Oct 18, 2013 |
d citizen:You need to create the following tables, 1. Students 2. Results The students table will contain these columns: id [ int(9) ] auto increment not null firstname [ varchar(30) ] not null lastname [ varchar(30) ] not null middlename [ varchar(30) ] school [ varchar(255) ] department [ enum('science','commercial','arts') ] *and any other necessary info(columns) regarding a student using ur app Results table: id [ int(9) ] auto increment not null studentid [ int(9) ] not null exam [ enum('gce','waec','sat','blablabla') default(waec) ] course [ varchar(30) ] year [ int(4) ] grade [ varchar(15) default(pending) ] You can query the tables like so: <?php //initialise n connect to your database or load db class //Supposing we have our name from a form sent by post $fname=$_POST['fname']; $lname=$_POST['lname']; //filter the variables to check if they r the xpected 4mat $stud_result_q="SELECT re.* FROM results re LEFT JOIN students st on re.studentid=st.id WHERE st.firstname='$fname' AND st.lastname='$lname'"; /*Run the query on ur database and use mysql_fetch_assoc or equiv db class method, you can use a while loop to process the results you can also refine the sql for year, passed courses, pending courses etc.*/ ?> |
(1) (2) (3) (4) (5) (6) (7) (8) (9) (10) ... (20) (Reply)
Top Google Searches By Nigerians 2015;Arsenal,Buhari,Diezani Arrest tops d list. / Mark Zuckerberg Eating Pounded Yam And Eforiro (Photo) / Setting Up Wamp Server To Run On Local Area Network
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 67 |