문제

Ok, so I'm having trouble using $_GET. It seems like when I try to use it with multiple links, it comes out null. The first part of the code is just producing two links and then figuring out which link was clicked. The second part is creating a bunch of links with people's names. The problem is that my $num variable always comes out to be null. The weird thing is that I tried not using $_GET for the first part, I only used it for the second part, and $num was no longer null. However, some other stuff didn't work the way I want it to so I have to do it this way. The two pieces of code are in different functions. Is there something about $_GET that won't let me do this? Thanks in advance!

This is the first part of the code:

$profLink = "<br><a href=?urlID=sortProf >By Professor</a></br>";
$yearLink = "<br><a href=?urlID=sortYear >By Year</a></br>";

echo $profLink;
echo $yearLink;

 if(isset($_GET['urlID'])){
    $urlID = $_GET['urlID'];}

if ($urlID == "sortProf"){

$v = sortByLastName($v);

 displayNames($v, $k);

}

else if ($urlID == "sortYear"){
echo "check2";


}
}

This is the second part (where the trouble is):

foreach($v as $name){
        $nameLink = "<a href=?num=$nameCount > $name </a><br />";
        echo $nameLink;
        $nameCount++;
       // echo $nameCount;
    }
     if(isset($_GET['num'])){
    $num = $_GET['num'];}

올바른 솔루션이 없습니다

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top