Jump to content

[SOLVED] Function/Echo Help


will35010

Recommended Posts

I have this function that creates options for a select menu. I have data for it to retrieve but it doesn't work. I know it's probably something simple, but I can't find the problem.

 

function getVehicles()
{
$sql1 = "SELECT vin, plate, year FROM vehicles";
$rt = mysql_query($conn, $sql1);
while($row1 = mysql_fetch_array($rt)) {
$list1 .= '<option value="' . $row1['vin'] . '">' . $row1['plate'] . ', ' . $row1['year'] . '</option>';
}	
return $list1;
}

 

Here is the html part:

 

<select name="vin" id="vin">
          <?php getVehicles() ?>
            </select>

I've also tried

<select name="vin" id="vin">
          <?php echo getVehicles() ?>
            </select>

 

Thanks!

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

function getVehicles()
{
$sql1 = "SELECT vin, plate, year FROM vehicles";
$rt = mysql_query($sql1);
while($row1 = mysql_fetch_array($rt)) {
$list1 .= '<option value="' . $row1['vin'] . '">' . $row1['plate'] . ', ' . $row1['year'] . '</option>';
}	
return $list1;
}

<?php echo getVehicles(); ?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.