Oracle&PHP drop down box?

CupRamen

New member
i would like to know if it was possible that you could populate a drop down box from data already in your database using oracle and php
Parse error: parse error, expecting `','' or `';'' in C:\Apache\Apache2\htdocs\project\test2.php on line 13

I tried using this method but i get this error beacuse i am not uisng mysql, i am using oracle so i changed it to try work with oracle 10g, the codes below:

<?
if ($conn = oci_connect('hr', 'hr')) {
print 'Successfully connected to Oracle Database!';
oci_close($conn);
}
else {
$errmsg = oci_error();
print 'Oracle connect error: ' . $errmsg['message'];
}

$city=oci_query("SELECT * FROM country");

echo "<select name='city'><option value="0"> </option>";
while($row=oci_fetch_assoc($States)){
extract($row);
echo "<option value="$city">$city</option>";
}
echo "</select>";

?>
 
well yes there is. Use this snippet to help you along:

PS: You will have to tweek the connection settings but it will work

-- --------------------------------------------------------

--
-- Table structure for table `states`
--

DROP TABLE IF EXISTS `states`;
CREATE TABLE IF NOT EXISTS `states` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`state` varchar(100) NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=52 ;

INSERT INTO `states` (`id`, `state`) VALUES
(1, 'Alabama'),
(2, 'Alaska'),
(3, 'Arizona'),
(4, 'Arkansas'),
(5, 'California'),
(6, 'Colorado'),
(7, 'Connecticut'),
(8, 'Delaware'),
(9, 'District of Columbia'),
(10, 'Florida'),
(11, 'Georgia'),
(12, 'Hawaii'),
(13, 'Idaho'),
(14, 'Illinois'),
(15, 'Indiana'),
(16, 'Iowa'),
(17, 'Kansas'),
(18, 'Kentucky'),
(19, 'Louisiana'),
(20, 'Maine'),
(21, 'Maryland'),
(22, 'Massachusetts'),
(23, 'Michigan'),
(24, 'Minnesota'),
(25, 'Mississippi'),
(26, 'Missouri'),
(27, 'Montana'),
(28, 'Nebraska'),
(29, 'Nevada'),
(30, 'New Hampshire'),
(31, 'New Jersey'),
(32, 'New Mexico'),
(33, 'New York'),
(34, 'North Carolina'),
(35, 'North Dakota'),
(36, 'Ohio'),
(37, 'Oklahoma'),
(38, 'Oregon'),
(39, 'Pennsylvania'),
(40, 'Rhode Island'),
(41, 'South Carolina'),
(42, 'South Dakota'),
(43, 'Tennessee'),
(44, 'Texas'),
(45, 'Utah'),
(46, 'Vermont'),
(47, 'Virginia'),
(48, 'Washington'),
(49, 'West Virginia'),
(50, 'Wisconsin'),
(51, 'Wyoming');


//Now the function to pull create the <select>

//Link to your database right here
<?
$States=mysql_query("SELECT * FROM states ORDER BY state ASC");
echo "<select name="State"><option value="0"></option>";
while($row=mysql_fetch_assoc($States)){
extract($row);
echo "<option value="$state">$state</option>";
}
echo "</select>";
?>
 
Back
Top