+ 2

add $id to favorites (mysql)

I need to add an $id from the list into my database with a favorite button. <?php include "server.php"; $json = file_get_contents('**personal link**'); $obj = json_decode($json); foreach($obj->AttractionInfo AS $attraction ) { if($attraction->Type != 'Attraction') { continue; } echo "<ul class='lists'>"; echo "<li>" . $attraction->Id . "</li><br>"; echo "</ul>"; } I need the button to add the id from $attraction->id into the database, can anyone help me out?

2nd Jul 2020, 7:23 PM
newbiecoder
5 ответов
+ 1
Hello Ipang, the ul is there just for the styling, i forgot to add the il and the blank one is there because i want to add the button there
2nd Jul 2020, 8:08 PM
newbiecoder
+ 1
i just need a button that can take the $id into a sql query
2nd Jul 2020, 8:31 PM
newbiecoder
0
Hi newbiecoder, Can you tell me what you are doing with this line? 👇 echo $attraction->Id . "" . ><br>"; I'm particularly interested in: * Why there's a <ul> ... </ul> but no <li> ... </li> inside it * The purpose of blank string between <$attraction->Id> and the "<br>".
2nd Jul 2020, 8:01 PM
Ipang
0
newbiecoder I see, so here we want to collect the content of all the <li> ... </li> inside the <ul> ... </ul>. Is this the idea? I would probably add an 'Id' attribute to the <ul> tag, collect contenta of all <li> tags within, then add each <li> content into some string which then can be used to form a SQL statement for insert (just an idea). Also please update the Description so others who came here later understands better 👍
2nd Jul 2020, 8:20 PM
Ipang
0
Ipang, with this i get a list of attractions and i want a button next to every single attraction that can add that attraction to my database, the table i my database is called "favorites" and it has to add these attractions into efteling_id
2nd Jul 2020, 8:30 PM
newbiecoder