i have a problem. I write this function tu recover a previous branch from my DB entity, and i want that the function return a string with I can see this information. this is the code:
function stampaOggettoCollezione($tipoOggetto, $id, $connection, $percorso="")
{
$i=0;
switch($tipoOggetto)
{
case 'casaeditrice':
return $percorso;
break;
case 'storia':
$dati = array("storia", "IDCasaEditrice", "casaeditrice");
break;
case 'testata':
$dati = array("testata", "IDStoria", "storia");
break;
case 'albo':
$dati = array("albo", "IDTestata", "testata");
break;
}
$sql = "SELECT * FROM ".$dati[0]." WHERE ID=$id";
$result=mysqli_query($connection,$sql);
$IDSuperiore=mysqli_fetch_array($result)[$dati[1]];
$sql = "SELECT * FROM ".$dati[2]." WHERE ID=$IDSuperiore";
$result = mysqli_query($connection, $sql);
$nomeSuperiore=mysqli_fetch_array($result)['nome'];
$percorso = $percorso . $nomeSuperiore;
stampaOggettoCollezione($dati[2], $IDSuperiore, $connection, $percorso);
}
i'm sure that code works, i try some echo in the code to check the final path. My problem is that i can't write the return like a string in my webpage. What do you think about? there's some problem with the declaration? Thanks
casein the function actually returns a value. So unless thatcaseis invoked, nothing will be returned.stampaOggettoCollezione($dati[2], $IDSuperiore, $connection, $percorso); }withreturn stampaOggettoCollezione($dati[2], $IDSuperiore, $connection, $percorso); }