bertrc Posted November 20, 2022 Share Posted November 20, 2022 (edited) I have two files index.php and cocoa_type_chocolate.php I have 1 links is dark chocolate. I want one query when I press one link index.php <a href='cocoa_type_chocolate.php?type_chocolate=dark'>Dark</a> cocoa_type_chocolate.php mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); $mysqli = mysqli_connect("localhost", "root", "*****", "cocoa"); $query = "SELECT chocolate.id_chocolate,chocolate.name_chocolate,type_chocolate.id_type_chocolate, type_chocolate.type_chocolate ,type_chocolate.id_chocolate FROM chocolate INNER JOIN type_chocolate ON chocolate.id_chocolate =type_chocolate.id_type_chocolate WHERE type_chocolate='dark'"; $result = mysqli_query($mysqli, $query); /* numeric array */ while ($row = mysqli_fetch_array($result, MYSQLI_BOTH)) { printf("%s %s %s %s %s\n", $row["id_chocolate"], $row["name_chocolate"], $row["id_type_chocolate"],$row["type_chocolate"],$row["id_chocolate"]);?> <br> <?php } ?> Edited November 20, 2022 by bertrc Quote Link to comment https://forums.phpfreaks.com/topic/315563-_get-in-query-mysql-in-condicion-where/ Share on other sites More sharing options...
Barand Posted November 20, 2022 Share Posted November 20, 2022 Please stop posting your code on a single line. It's ****ing annoying. 1 Quote Link to comment https://forums.phpfreaks.com/topic/315563-_get-in-query-mysql-in-condicion-where/#findComment-1602796 Share on other sites More sharing options...
mac_gyver Posted November 20, 2022 Share Posted November 20, 2022 the new-line/end-of-line setting in your programming editor is set to a non-standard setting. changing it to any of the other choices would be an improvement and allow the forum software to display your code properly. Quote Link to comment https://forums.phpfreaks.com/topic/315563-_get-in-query-mysql-in-condicion-where/#findComment-1602797 Share on other sites More sharing options...
bertrc Posted November 21, 2022 Author Share Posted November 21, 2022 have two files index.php and cocoa_type_chocolate.php I have 1 links is dark chocolate. I want one query when I press one link index.php <a href='cocoa_type_chocolate.php?type_chocolate=dark'>Dark</a> cocoa_type_chocolate.php mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); $mysqli = mysqli_connect("localhost", "root", "*****", "cocoa"); $query = "SELECT chocolate.id_chocolate,chocolate.name_chocolate,type_chocolate.id_type_chocolate, type_chocolate.type_chocolate ,type_chocolate.id_chocolate FROM chocolate INNER JOIN type_chocolate ON chocolate.id_chocolate =type_chocolate.id_type_chocolate WHERE type_chocolate='dark'"; $result = mysqli_query($mysqli, $query); /* numeric array */ while ($row = mysqli_fetch_array($result, MYSQLI_BOTH)) { printf("%s %s %s %s %s\n", $row["id_chocolate"], $row["name_chocolate"], $row["id_type_chocolate"],$row["type_chocolate"],$row["id_chocolate"]);?> <br> <?php } ?> Edited 13 hours ago by bertrc Quote Link to comment https://forums.phpfreaks.com/topic/315563-_get-in-query-mysql-in-condicion-where/#findComment-1602817 Share on other sites More sharing options...
bertrc Posted November 21, 2022 Author Share Posted November 21, 2022 I have two files index.php and cocoa_type_chocolate.php. I have 1 links is dark chocolate. I want one query when I press one link. I want to change the condition where, to change between 3 chocolates milk, dark, and white. in the condicion where I should use get. but I have problem with the url and where condicion. index.php <a href='cocoa_type_chocolate.php?type_chocolate=dark'>Dark</a> cocoa_type_chocolate.php mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); $mysqli = mysqli_connect("localhost", "root", "*****", "cocoa"); $query = "SELECT chocolate.id_chocolate,chocolate.name_chocolate,type_chocolate.id_type_chocolate, type_chocolate.type_chocolate ,type_chocolate.id_chocolate FROM chocolate INNER JOIN type_chocolate ON chocolate.id_chocolate =type_chocolate.id_type_chocolate WHERE type_chocolate='dark'"; $result = mysqli_query($mysqli, $query); /* numeric array */ while ($row = mysqli_fetch_array($result, MYSQLI_BOTH)) { printf("%s %s %s %s %s\n", $row["id_chocolate"], $row["name_chocolate"], $row["id_type_chocolate"],$row["type_chocolate"],$row["id_chocolate"]); ?> <br> <?php } ?> Quote Link to comment https://forums.phpfreaks.com/topic/315563-_get-in-query-mysql-in-condicion-where/#findComment-1602819 Share on other sites More sharing options...
bertrc Posted November 21, 2022 Author Share Posted November 21, 2022 (edited) It is working thank you index.php <a href='cocoa_type_chocolate.php?type_chocolate=dark'>Dark</a> <a href='cocoa_type_chocolate.php?type_chocolate=milk'>Milk</a> <a href='cocoa_type_chocolate.php?type_chocolate=white'>White</a> cocoa_type_chocolate.php mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); $mysqli = mysqli_connect("localhost", "root", "*****", "cocoa"); $query = "SELECT chocolate.id_chocolate,chocolate.name_chocolate,type_chocolate.id_type_chocolate, type_chocolate.type_chocolate ,type_chocolate.id_chocolate FROM chocolate INNER JOIN type_chocolate ON chocolate.id_chocolate =type_chocolate.id_type_chocolate WHERE type_chocolate='$_GET[type_chocolate]'"; $result = mysqli_query($mysqli, $query); /* numeric array */ while ($row = mysqli_fetch_array($result, MYSQLI_BOTH)) { printf("%s %s %s %s %s\n", $row["id_chocolate"], $row["name_chocolate"], $row["id_type_chocolate"],$row["type_chocolate"],$row["id_chocolate"]); ?> <br> <?php } ?> Edited November 21, 2022 by bertrc Quote Link to comment https://forums.phpfreaks.com/topic/315563-_get-in-query-mysql-in-condicion-where/#findComment-1602821 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.