Jump to content

Display database results using Php Ajax and dropdown list


Paulk
 Share

Recommended Posts

Hello team,

I tested the training here: https://www.w3schools.com/php/php_ajax_database.asp
It works fine but I obtain only the first line (ID) in the Placeholder.
So, to go ahead with my project, is to select by brand or by modele.
My database is like this:

CREATE TABLE IF NOT EXISTS `allbrands` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `Brand` varchar(60) COLLATE latin1_general_ci DEFAULT NULL,
  `Model` varchar(60) COLLATE latin1_general_ci DEFAULT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=1 ;

--
-- Table `allbrands`
--

INSERT INTO `allbrands` (`ID`, `Brand`, `Model`) VALUES
(1, 'Peugeot', '108'),
(2, 'Peugeot', '208'),
(3, 'Renault', 'Clio'),
(4, 'Dacia', 'Sandero');

 

So, in the dropdown list, I would like listed all brands and that Ajax go to search the selected brand in database and display the brands and models according the one selected.
If I'm using exactly what it describe in the training, the got only the first line where the ID is 1, means "Peugeot 108"
Clearly, if I selected "Peugeot" in dropdown list, I should obtain this result in Placeholder:

Peugeot 108
Peugeot 208


Could you help me to obtain that?
Thank you
Paul

 

Link to comment
Share on other sites

What does your selection query look like?

Edited by niche
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...