0
function projectdetails($proj_id) {
    include('includes/connection.inc.php');
    $details = "SELECT * FROM projects WHERE id = ?";
    
    $stmt = $conn->prepare($details); 
    $stmt->bind_param("i", $proj_id);
    $stmt->execute();
    $result = $stmt->get_result(); 
    $project = $result->fetch_assoc();

    $conn->close();
    return $project; 
}

How do I call the Columns after storing in a "return"

<?php 

$projectidentifier = $_GET['project'];
projectdetails('$projectidentifier');

?>
<?php echo $project['ProjectTitle']; ?> 

in the HTML code doesn't seem to work and gives ---- undefined variable error?

  • Can you show where you call the function as well as the code where you try and access the values. – Nigel Ren Mar 07 '21 at 07:28
  • updated the code – Shelby Bradley Mar 07 '21 at 07:31
  • Your quotes round the parameter you pass are probably causing some other errors (you don't need quotes round variables - especially single quotes - see https://stackoverflow.com/questions/3446216/what-is-the-difference-between-single-quoted-and-double-quoted-strings-in-php), you also need to store the return value. `$project = projectdetails($projectidentifier);` – Nigel Ren Mar 07 '21 at 07:37
  • Problem Solved - cheers removed '' from variable and stored the function call as a var. works like magic. Thanks Nigel. – Shelby Bradley Mar 07 '21 at 07:43

0 Answers0