jeudi 18 février 2021

PHP IF inside another IF

I have this code that redirects after updating the data

    if($query) 
        echo 'Congratulations! Data entered.'
    else 
        echo 'Warning! Data not entered!'
                
        // redirect 
        $link = "../members/cinema.php?id=" . $row['PersonID'] . "";
        echo '<script>window.location ="'.$link.'"</script>';

} 
    
    
else echo "<script type=\"text/javascript\">alert('Errore! Database noot select.');</script";

    
}

but I would like to put this inside $link =

link = "../members/cinema.php?id=" . $row['PersonID'] . "";
 echo '<script>window.location ="'.$link.'"</script>';

and replace with this code but keeping the script

    if($row['pers_autor'] == "Autore") 
    { 
        echo "<a href=\"members/autori.php?id=" . $row['PersonID'] . "\">" . $row['Name'] . "</a>" ; 
                    
    }
    elseif ($row['pers_autor'] == "Comprimario")
    {
        echo "<a href=\"members/comprimari.php?id=" . $row['PersonID'] . "\">" . $row['Name'] . "</a>";               
    }
    else
   {
    echo "<a href=\"members/cinema.php?id=" . $row['PersonID'] . "\">" . $row['Name'] . "</a>";
                    
   }

Aucun commentaire:

Enregistrer un commentaire