Jump to content

php function return


chriscloyd

Recommended Posts

my function is not displaying anything
okay heres my function

[code]
<?php
function get_project($i) {
$get_project = mysql_query("SELECT * FROM projects WHERE id = '$i'") or die(mysql_error());
$p = mysql_fetch_assoc($get_project) or die(mysql_error());
$p_name = $p['title'];
$p_type = $p['type'];
$p_startdate = $p['startdate'];
return $p_type;
        return $p_name;
        return $p_startdate;
if ($p['status'] != 'Completed') {
$p_status = 'In Progress';
return $p_status;
} else {
$p_status = 'Completed';
$p_enddate = $p['enddate'];
return $p_status;
                return $p_enddate;
}
}
?>
[/code]

heres my code calling the function

[code]
<?php
session_start();
include("config.php");
include("includes/porfolio_getfunctions.php");
if (isset($_GET['project'])){
$id = $_GET['project'];
get_project($id);
echo $p_name;
echo $p_type;
}
?>
[/code]
Link to comment
Share on other sites

once you use return inside a function the function code stops at that point the rest of the code won't be called.

so..
        return $p_type;
        return $p_name;
        return $p_startdate;

$p_name $p_startdat won't ever get called or anything below that line
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.