flooker
asked on
Passing Variable through Link
its simple IF else statments but i am stuck .
first thing i am passing variable through link like
<a href="teacher.php?ID=1">Th is is Test</a>
Teacher.php
<?php
if($ID == 1){
if($row["CountOfCourseCode "] < 1 ){
if ($row = mysql_fetch_array($result) ) {
$i = $row["CountOfCourseCode"];
if($first AND $year AND $i > 0 ){
do {
print ("The Teacher $first. Teaching ");
print $row["CountOfCourseCode"];
print (" Courses $i. $ID.");
}
while($row = mysql_fetch_array($result) );
}
else {
print "NOT GETTING ID $ID.";
}
}
else {
print "Sorry, no records were found!";
}
}
else {
print "Sorry, no records were found!";
}
}
else {
print "Sorry No Record Found! ";
}
?>
what i need is simple . if the user comes through the Link The ID=1 the script should print "Welcome" but the problem is when Data base doent match any record its still giving msg "Not getting" . although to test this in FORM ACTION i am passing Teacher.php?ID=1 also .
help will be appreciated .
first thing i am passing variable through link like
<a href="teacher.php?ID=1">Th
Teacher.php
<?php
if($ID == 1){
if($row["CountOfCourseCode
if ($row = mysql_fetch_array($result)
$i = $row["CountOfCourseCode"];
if($first AND $year AND $i > 0 ){
do {
print ("The Teacher $first. Teaching ");
print $row["CountOfCourseCode"];
print (" Courses $i. $ID.");
}
while($row = mysql_fetch_array($result)
}
else {
print "NOT GETTING ID $ID.";
}
}
else {
print "Sorry, no records were found!";
}
}
else {
print "Sorry, no records were found!";
}
}
else {
print "Sorry No Record Found! ";
}
?>
what i need is simple . if the user comes through the Link The ID=1 the script should print "Welcome" but the problem is when Data base doent match any record its still giving msg "Not getting" . although to test this in FORM ACTION i am passing Teacher.php?ID=1 also .
help will be appreciated .
ASKER
Thats for Reply Cris .. Its Still not working . even before doin ur suddestion when i am printing the Code vale for $ID its showing its 1 but whats goin on with If statments thats i canot understand . I even tried "OR" woth seconf If but still its giving msg " NOT GETTING I"
ASKER
Thats for Reply Cris .. Its Still not working . even before doin ur suddestion when i am printing the Code vale for $ID its showing its 1 but whats goin on with If statments thats i canot understand . I even tried "OR" woth seconf If but still its giving msg " NOT GETTING I"
ASKER
sorry for Typoes ! yaakh .. well i am re-arranging my comments . the code bit u gave me its no working either . problem is when i am giving all correct data in form fields its getting data back to me No problems with that .
Now when First IF goes fine but second IF goes False its Even i Tried
if($row["CountOfCourseCode "] < 1 OR $ID ==1 )
Its Printing "Not getting in ! ."
what i need is If , user is comming through URL with ...?ID=1 value it should let him in the first IF but if No records found according to hissearch simply print "No records found". thats what its not doing . i dono whats wrong going on ! .
Now when First IF goes fine but second IF goes False its Even i Tried
if($row["CountOfCourseCode
Its Printing "Not getting in ! ."
what i need is If , user is comming through URL with ...?ID=1 value it should let him in the first IF but if No records found according to hissearch simply print "No records found". thats what its not doing . i dono whats wrong going on ! .
ASKER
sorry for Typoes ! yaakh .. well i am re-arranging my comments . the code bit u gave me its no working either . problem is when i am giving all correct data in form fields its getting data back to me No problems with that .
Now when First IF goes fine but second IF goes False its Even i Tried
if($row["CountOfCourseCode "] < 1 OR $ID ==1 )
Its Printing "Not getting in ! ."
what i need is If , user is comming through URL with ...?ID=1 value it should let him in the first IF but if No records found according to hissearch simply print "No records found". thats what its not doing . i dono whats wrong going on ! .
Now when First IF goes fine but second IF goes False its Even i Tried
if($row["CountOfCourseCode
Its Printing "Not getting in ! ."
what i need is If , user is comming through URL with ...?ID=1 value it should let him in the first IF but if No records found according to hissearch simply print "No records found". thats what its not doing . i dono whats wrong going on ! .
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
And you do have Register_globals=on in the php.ini file?
I´m no ace in php, but I had to turn that on to pass variables on between php-documents..
I´m no ace in php, but I had to turn that on to pass variables on between php-documents..
It looks like you might have been getting a bit confused.
Let me know if this is what you want to do..
if ($ID == 1) {
$result = // perform query
if ($result) {
// if query returned valid information
while ($row = mysql_fetch_array($result) ) {
if ($row["first"] AND $row["first"] AND $row["CountOfCourseCode"] > 0) {
// loop over and print info
print "The Teacher $first. Teaching ";
print $row["CountOfCourseCode"];
print " Courses $i. $ID.";
}
}
} else {
// no valid results
print "no records found";
}
} else {
print "ID not found";
}
Let me know if this is what you want to do..
if ($ID == 1) {
$result = // perform query
if ($result) {
// if query returned valid information
while ($row = mysql_fetch_array($result)
if ($row["first"] AND $row["first"] AND $row["CountOfCourseCode"] > 0) {
// loop over and print info
print "The Teacher $first. Teaching ";
print $row["CountOfCourseCode"];
print " Courses $i. $ID.";
}
}
} else {
// no valid results
print "no records found";
}
} else {
print "ID not found";
}
<?php
// Inserted text
$ID = $_REQUEST['ID'];
// End inserted text
if($ID == 1){
if($row["CountOfCourseCode
if ($row = mysql_fetch_array($result)
$i = $row["CountOfCourseCode"];
if($first AND $year AND $i > 0 ){
etc...
Let me know if this works...
Chris