Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Francesco Paolini
Francesco Paolini
9,910 Points

if isset button

I'm trying to make the $sql variable change once the button with the name 'lang_en' is submitted, so it goes from selecting the 'eng_text' tab to select the 'it_text' tab, but it doesn't seems to work. Can you help?

<?php

include 'includes/conn.php';

if(isset($_POST['lang_en'])){ $sql = "SELECT * FROM it_text"; } else{ $sql = "SELECT * FROM eng_text"; }

$result = mysqli_query($conn, $sql);

$row = mysqli_fetch_all($result, MYSQLI_ASSOC);

var_dump($sql);

?>

<a href="#" type="submit" name='lang_en' class="w3-circle w3-margin w3-padding bg-img w3-display-topright" style="background-image: url('img/italian_flag.png')">IT</a>

this is what's there in conn.php: <?php

$serverName = 'localhost'; $userName = 'root'; $password = ''; $database = 'pers_text';

$conn = new mysqli($serverName, $userName, $password, $database)