I have 2 divs
stuff here
and div 2
stuff here
i have a id in users table that is either 1 or 2 by default its 1,
I want to hide the div based on a field called app_id if app_id equal 1 show div app1 if app_id is 2 show div app2
I have 2 divs
and div 2
i have a id in users table that is either 1 or 2 by default its 1,
I want to hide the div based on a field called app_id if app_id equal 1 show div app1 if app_id is 2 show div app2
Just select the value from the database and use if’s around the content you want to conditionally show.
would you care to give an example I am new to php
You cannot look up the syntax for a PHP if statement?
I sure have no result though
function hide_show(){
$sql = "SELECT * FROM users WHERE app_id = {$app_id}";
$result = query($sql);
if($app_id == 1){
return true;
} else {
return false;
}
}
[PHP]
<?php if (hide_show()){ echo '[/PHP]
Or:
[PHP]
<?php function hide_show(){ $sql = "SELECT * FROM users WHERE app_id = {$app_id}"; $result = query($sql); if($app_id == 1){ $html = '[/PHP]
Usage:
[PHP]
<?php hide_show(); ?>[/PHP]
Also, make sure you are using MySQLi or PDO for your database queries.