Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Passing Variable through Link

Posted on 2003-02-20
10
Medium Priority
?
204 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
8 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

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

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
This article discusses how to implement server side field validation and display customized error messages to the client.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

580 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