+ 2

Anyone use XAMPP and can assist me with this please?

I want to look up any Superhero by their name or alias and retrieve only that superhero or leave the text field blank and when I click search, it should return the original list of superheroes: Captain America Ironman Captain Marvel etc… I added the PHP code for it. However, when I click search it’s showing everything in the PHP file, even the closing tags. I’d really appreciate the help. https://code.sololearn.com/WGKTeL1GY69H/?ref=app

6th Nov 2022, 7:19 PM
Triz
Triz - avatar
15 Answers
+ 5
// This works for me: onload = () => { var Btn = document.getElementById('searchBtn'); var result = document.getElementById('result'); var heroName= document.getElementById('searchBox'); Btn.onclick = event => { fetch(`superheroes.php?query=${heroName.value}`, { method: 'GET'}) //fetch(`superheroes.php?query=${heroName.value}`) .then(response =>{ return response.text(); // return the response as text }) .then(data =>{ result.innerHTML= data; }); } }
6th Nov 2022, 9:03 PM
JaScript
JaScript - avatar
+ 4
JaScript thank you. Did you modify the php code; Are you able to search for each character by name? When I click on search, I'm getting: , "name" => "Steve Rogers", "alias" => "Captain America", "biography" => "Recipient of the Super-Soldier serum, World War II hero Steve Rogers fights for American ideals as one of the world’s mightiest heroes and the leader of the Avengers.", ], [ "id" => 2, "name" => "Tony Stark", "alias" => "Ironman", And not a list with their Alias.
6th Nov 2022, 9:19 PM
Triz
Triz - avatar
+ 2
For a super hero that is found, the result should look like this: IRON MAN AKA TONY STARK Genius. Billionaire. Playboy…
6th Nov 2022, 7:23 PM
Triz
Triz - avatar
+ 2
To fix it you can cut the first loop and put them into last if statement.
6th Nov 2022, 10:29 PM
JaScript
JaScript - avatar
6th Nov 2022, 11:32 PM
JaScript
JaScript - avatar
+ 2
Triz An idea will be to remove the apostrophe from the user searching input and from php searching algorithm.
7th Nov 2022, 1:44 PM
JaScript
JaScript - avatar
+ 1
I checked again the php isn‘t changed only app.js. Here a picture of a searching result: https://dl.dropbox.com/s/432pk0smh9dq836/Bildschirmfoto%202022-11-06%20um%2022.35.22.png?raw=1
6th Nov 2022, 9:44 PM
JaScript
JaScript - avatar
+ 1
JaScript when you search for a specific character, the list with the other superheroes shouldn’t be showing but I don’t know how to fix that as yet
6th Nov 2022, 9:56 PM
Triz
Triz - avatar
+ 1
Triz For small tasks and training I use DraftCode on iPad. This app uses XAMPP implementation for server features and MySql for database.
6th Nov 2022, 10:10 PM
JaScript
JaScript - avatar
+ 1
JaScript I got it to work. Thanks alot!!! I really really appreciate it!
6th Nov 2022, 10:11 PM
Triz
Triz - avatar
+ 1
JaScript Ok. Thanks again!
6th Nov 2022, 10:56 PM
Triz
Triz - avatar
+ 1
JaScript When i search for T’challa, it says user not fount but it’s in the array. I think it’s because of the apostrophe, any idea how to fix this?
7th Nov 2022, 2:25 AM
Triz
Triz - avatar
+ 1
Triz did you fix the apostrophe problem?
7th Nov 2022, 6:33 PM
JaScript
JaScript - avatar
0
Very nice.
8th Nov 2022, 5:20 AM
Ikechukwu Daniel
Ikechukwu Daniel - avatar
0
Hello.
8th Nov 2022, 5:20 AM
Ikechukwu Daniel
Ikechukwu Daniel - avatar