chriscloyd Posted January 25, 2007 Share Posted January 25, 2007 my function is not displaying anythingokay heres my function[code] <?phpfunction 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]<?phpsession_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 https://forums.phpfreaks.com/topic/35631-php-function-return/ Share on other sites More sharing options...
trq Posted January 25, 2007 Share Posted January 25, 2007 You can only call return once within a function. Link to comment https://forums.phpfreaks.com/topic/35631-php-function-return/#findComment-168763 Share on other sites More sharing options...
sspoke Posted January 25, 2007 Share Posted January 25, 2007 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 https://forums.phpfreaks.com/topic/35631-php-function-return/#findComment-168766 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.