will35010 Posted June 4, 2009 Share Posted June 4, 2009 I'm having a problem calling the second function from the first function. I don't know where the problem is. Any direction would be helpful. Thanks. function vehicleinfo() { require('lib/opendb.php'); require('lib/functions.php'); $query = mysqli_query($conn, "SELECT vin, plate, expire, year, make, model FROM vehicles"); while($row = mysqli_fetch_array($query)) { echo "<table width='900' border='1' align='center'> <tr> <td width='225' align='center' scope='col'>VIN: " . $row['vin'] . "</td> <td width='228' align='center' scope='col'>YEAR: " . $row['year'] . "</td> <td width='225' align='center' scope='col'>MAKE: " . $row['make'] . "</td> </tr> <tr> <td><div align='center'>PLATE: " . $row['plate'] . "</div></td> <td><div align='center'>EXPIRE: " . $row['expire'] . "</div></td> <td><div align='center'>MODEL: " . $row['model'] . "</div></td> </tr> <tr> <td><div align='center'>". currentMileage($row['vin']) ."</div></td> <td><div align='center'>miles until oil change</div></td> <td><div align='center'>Get MPG</div></td> </tr> </table> </tr> </table>"; } } function currentMileage($vin) { require('lib/opendb.php'); $query = mysqli_query($conn, "SELECT mileage FROM cmileage WHERE vin = ".$vin.""); $row = mysqli_fetch_array($query); echo $row['mileage']; } Quote Link to comment https://forums.phpfreaks.com/topic/160960-solved-function-help/ Share on other sites More sharing options...
wildteen88 Posted June 4, 2009 Share Posted June 4, 2009 Use return not echo in your second function. Quote Link to comment https://forums.phpfreaks.com/topic/160960-solved-function-help/#findComment-849435 Share on other sites More sharing options...
will35010 Posted June 4, 2009 Author Share Posted June 4, 2009 Use return not echo in your second function. I changed it to return but it didn't make a difference. Quote Link to comment https://forums.phpfreaks.com/topic/160960-solved-function-help/#findComment-849451 Share on other sites More sharing options...
Ken2k7 Posted June 4, 2009 Share Posted June 4, 2009 1. You could have use a JOIN and use one SQL to get everything. 2. In your second function var_dump $row['mileage']. What does that output? Quote Link to comment https://forums.phpfreaks.com/topic/160960-solved-function-help/#findComment-849455 Share on other sites More sharing options...
will35010 Posted June 4, 2009 Author Share Posted June 4, 2009 1. You could have use a JOIN and use one SQL to get everything. 2. In your second function var_dump $row['mileage']. What does that output? Thanks for the help. The problem was with my require('lib/functions.php'). It was declaring a variable twice and causing a fatal error. Quote Link to comment https://forums.phpfreaks.com/topic/160960-solved-function-help/#findComment-849458 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.