Jump to content

Recommended Posts

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'];
}

Link to comment
https://forums.phpfreaks.com/topic/160960-solved-function-help/
Share on other sites

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.  ;D

 

Link to comment
https://forums.phpfreaks.com/topic/160960-solved-function-help/#findComment-849458
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.