?
Solved

Passing Variable through Link

Posted on 2003-02-20
10
Medium Priority
?
203 Views
Last Modified: 2011-04-14
its simple IF else statments but i am stuck .

first thing i am passing variable through link like

<a href="teacher.php?ID=1">This 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 .
0
Comment
Question by:flooker
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 

Expert Comment

by:sidesh0w
ID: 7990856
It almost looks like you need to read in the request variable.  Try inserting this:

<?php
// Inserted text
$ID = $_REQUEST['ID'];
// End inserted text


 if($ID == 1){
 if($row["CountOfCourseCode"] < 1  ){
 if ($row = mysql_fetch_array($result)   ) {
 $i = $row["CountOfCourseCode"];
 if($first AND $year AND $i > 0 ){


etc...

Let me know if this works...

Chris
0
 

Author Comment

by:flooker
ID: 7991137
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"
0
 

Author Comment

by:flooker
ID: 7991150
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"
0
Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

 

Author Comment

by:flooker
ID: 7991188
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 ! .  
0
 

Author Comment

by:flooker
ID: 7991258
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 ! .  
0
 
LVL 6

Accepted Solution

by:
carchitect earned 120 total points
ID: 7991751
<?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!";
}
?>

0
 

Expert Comment

by:Spawny
ID: 7995948
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..
0
 

Expert Comment

by:spere
ID: 8007550
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";
}
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question