| | |
result of 1 query parametre to other..
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Dec 2008
Posts: 12
Reputation:
Solved Threads: 0
Happy new year to everyone..
in my sql db there r 2 tables. mathimata and apousies
from table -apousies- i "select" some data (the amount of absences) for a particular person (student) for every class he attended.
i want for every class of the above result to search in table -mathimata- and to find the board_of_absences of that classes (the field orio_apousiwn)
code
...
The script is working. the data shows results except the first line of results that only board_of_absences ( orio_apousiwn) is empty
one result:
Semester:A, class: Γλώσσα, absences: 23, board_of_absences:
Semester:A, class: Φυσική, absences: 12, board_of_absences: 22
Semester:A, class: Χρήση Η/Υ, absences: 4, board_of_absences: 16
the 2 and 3 line are ok in 1 there is no value in board_of_absences: but it should be........
i can not understand why.....
can u help me?????
in my sql db there r 2 tables. mathimata and apousies
from table -apousies- i "select" some data (the amount of absences) for a particular person (student) for every class he attended.
i want for every class of the above result to search in table -mathimata- and to find the board_of_absences of that classes (the field orio_apousiwn)
code
...
php Syntax (Toggle Plain Text)
$qry="SELECT semester, math, apousies FROM apousies WHERE member='$all' order by semester"; // i get semester, class and absences for a particular student $result=mysql_query($qry); if($result) { while($grammh = mysql_fetch_array($result)) { $result2=mysql_query(" Select distinct orio_apousiwn from mathimata where mathima='$grammh[math]' and semester='$grammh[semester]' "); $orio =mysql_fetch_assoc($result2); $or1=$orio[orio_apousiwn]; echo "Semester: $grammh[semester], class: $grammh[math], absences: $grammh[apousies], board_of_absences: $or1"."<BR>";} exit(); }
The script is working. the data shows results except the first line of results that only board_of_absences ( orio_apousiwn) is empty
one result:
Semester:A, class: Γλώσσα, absences: 23, board_of_absences:
Semester:A, class: Φυσική, absences: 12, board_of_absences: 22
Semester:A, class: Χρήση Η/Υ, absences: 4, board_of_absences: 16
the 2 and 3 line are ok in 1 there is no value in board_of_absences: but it should be........
i can not understand why.....
can u help me?????
Last edited by peter_budo; Jan 6th, 2009 at 2:03 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
What is the number you are expecting to be in the first slot?
Also, have you checked to make sure all the numbers are correct?
And why are you using DISTINCT here:
Are all of those values expected to be unique?
Also, have you checked to make sure all the numbers are correct?
And why are you using DISTINCT here:
PHP Syntax (Toggle Plain Text)
Select distinct orio_apousiwn
A little clarification goes a long way.
•
•
Join Date: Dec 2008
Posts: 12
Reputation:
Solved Threads: 0
yes, all the values are unique. U re right the distinct is not nessecery but for sure it doesnt cause the problem. i tried with or without it.
i will give u the data from table mathimata and from table apousies. it might help..
table mathimata
"1","1","Χρήση Η/Υ","A","16"
"2","1","Φυσική","A","22"
"3","2","Οικοκυρικά","Α","30"
"5","1","Γλώσσα","Α","16"
"8","2","Γεωγραφία","A","25"
"6","4","Ιστορία","A","23"
"7","4","Ιστορία τέχνης","A","12"
"9","2","Γυμναστική","A","12"
table apousies
"1","ΠΑΠΑΔΟΠΟΥΛΟΣ, ΓΕΩΡΓΙΟΣ , ΓΡΗΓΟΡΙΟΣ","1","A","Γλώσσα","23"
"2","ΠΑΠΑΔΟΠΟΥΛΟΣ, ΓΕΩΡΓΙΟΣ , ΓΡΗΓΟΡΙΟΣ","1","A","Φυσική","12"
"3","ΠΑΠΑΔΟΠΟΥΛΟΣ, ΓΕΩΡΓΙΟΣ , ΓΡΗΓΟΡΙΟΣ","1","A","Χρήση Η/Υ","4"
"5","Χαραλαμπίδου, Μαρία, Βασίλειος","2","A","Οικοκυρικά","12"
"6","Χαραλαμπίδου, Μαρία, Βασίλειος","2","A","Γυμναστική","11"
"7","Χαραλαμπίδου, Μαρία, Βασίλειος","2","A","Γεωγραφία","10"
in the result i and published in my previous post (for student ΠΑΠΑΔΟΠΟΥΛΟΣ, ΓΕΩΡΓΙΟΣ) iwas expecting the field orio_apousiwn (board_of_absences) to has value 23.
the data is in greek and i am not sure if i help or comfuse more by posting them
i will give u the data from table mathimata and from table apousies. it might help..
table mathimata
"1","1","Χρήση Η/Υ","A","16"
"2","1","Φυσική","A","22"
"3","2","Οικοκυρικά","Α","30"
"5","1","Γλώσσα","Α","16"
"8","2","Γεωγραφία","A","25"
"6","4","Ιστορία","A","23"
"7","4","Ιστορία τέχνης","A","12"
"9","2","Γυμναστική","A","12"
table apousies
"1","ΠΑΠΑΔΟΠΟΥΛΟΣ, ΓΕΩΡΓΙΟΣ , ΓΡΗΓΟΡΙΟΣ","1","A","Γλώσσα","23"
"2","ΠΑΠΑΔΟΠΟΥΛΟΣ, ΓΕΩΡΓΙΟΣ , ΓΡΗΓΟΡΙΟΣ","1","A","Φυσική","12"
"3","ΠΑΠΑΔΟΠΟΥΛΟΣ, ΓΕΩΡΓΙΟΣ , ΓΡΗΓΟΡΙΟΣ","1","A","Χρήση Η/Υ","4"
"5","Χαραλαμπίδου, Μαρία, Βασίλειος","2","A","Οικοκυρικά","12"
"6","Χαραλαμπίδου, Μαρία, Βασίλειος","2","A","Γυμναστική","11"
"7","Χαραλαμπίδου, Μαρία, Βασίλειος","2","A","Γεωγραφία","10"
in the result i and published in my previous post (for student ΠΑΠΑΔΟΠΟΥΛΟΣ, ΓΕΩΡΓΙΟΣ) iwas expecting the field orio_apousiwn (board_of_absences) to has value 23.
the data is in greek and i am not sure if i help or comfuse more by posting them
Last edited by dourvas; Jan 4th, 2009 at 6:59 am.
If this is your exact code you may be having inconsistencies due to syntax.
If that does not help I would next take the second queries results stick it in its own loop and echo all of its results with the number key to make sure that comes out correct.
Its all Greek to me.
PHP Syntax (Toggle Plain Text)
Change: echo "Semester: $grammh[semester], class: $grammh[math], absences: $grammh[apousies], board_of_absences: $or1"."<BR>"; To: echo "Semester: ". $grammh['semester'].", class: ".$grammh['math'].", absences: ".$grammh['apousies'].", board_of_absences: ".$or1."<BR>";
If that does not help I would next take the second queries results stick it in its own loop and echo all of its results with the number key to make sure that comes out correct.
•
•
•
•
the data is in greek and i am not sure if i help or comfuse more by posting them
Last edited by DiGSGRL; Jan 4th, 2009 at 10:22 am. Reason: Its early
A little clarification goes a long way.
![]() |
Other Threads in the PHP Forum
- Previous Thread: use images instead of the standard text link showing the private message info
- Next Thread: urgent help...
| Thread Tools | Search this Thread |
301 advanced apache api array autosuggest basics beginner broken cakephp class cms code combobox compression cron curl data database date datepart display dropdownlist dynamic email eregi error execution file files folder form forms function functions google head href htaccess html httppost if...loop image include includingmysecondfileinthechain ip javascript job joomla jquery js key library limit link login md5 menu mlm multiple mysql mysql_real_escape_string oop password paypal pdf pdfdownload php phpvotingscript problem procedure query random screen script search searchbox server session sessions smarty source space sql stored system table traffic tutorial unicode upload url variable video volume votedown web website youtube zend





