will35010 Posted June 2, 2009 Share Posted June 2, 2009 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 More sharing options...
Alex Posted June 2, 2009 Share Posted June 2, 2009 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(); ?> Link to comment https://forums.phpfreaks.com/topic/160665-solved-functionecho-help/#findComment-847894 Share on other sites More sharing options...
will35010 Posted June 2, 2009 Author Share Posted June 2, 2009 Thanks! Link to comment https://forums.phpfreaks.com/topic/160665-solved-functionecho-help/#findComment-847905 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.