
z4z07
Members-
Posts
12 -
Joined
-
Last visited
z4z07's Achievements

Member (2/5)
0
Reputation
-
I've tried somehting like this: <?php $result = mysqli_query($conn, "SELECT cat_name FROM domeniu_activitate INNER JOIN user_pers_juridica WHERE cat_id LIKE cat_id AND product_id = '$id'"); while($row = mysqli_fetch_array($result)) { echo $row['cat_name']; } ?>
-
Hi guys! I have 2 mysql tables 1 named categories and the other one named products. In the first table i have cat_id, cat_name and in the secoudn one i have product_id, product_name, product_price, cat_id Now on the product page where i have my product listed i wanna display the cat_name based on the cat_id wich is present in both tables. What is the correct mysql syntax for this. Thank you very much.
-
Categories and subcategories array and dynamic dropdown list
z4z07 replied to z4z07's topic in PHP Coding Help
Hey guys i manage to put something together for my secound problem, but i encounter i little issue. When i execute the form to post in my db the subcat and the subsubcat it stores the subcat and subsubcat id's, and i want to store only the url of the subcat and subsubcat. I will post bellow my php and javascript code: $query = "SELECT id_domeniu, nume_domeniu, url_domeniu FROM domeniu_activitate WHERE categorie = 'servicii'"; $result = mysqli_query($conn, $query); while($row = mysqli_fetch_assoc($result)){ $categories[] = array("id" => $row['id_domeniu'], "val" => $row['nume_domeniu']); } $query = "SELECT id_subdomeniu, id_domeniu, url_subdomeniu, nume_subdomeniu FROM subdomeniu_activitate"; $result = mysqli_query($conn, $query); while($row = mysqli_fetch_assoc($result)){ $subcats[$row['id_domeniu']][] = array("id" => $row['id_subdomeniu'], "val" => $row['nume_subdomeniu']); } $jsonCats = json_encode($categories); $jsonSubCats = json_encode($subcats); <?php echo "var categories = $jsonCats; \n"; echo "var subcats = $jsonSubCats; \n"; ?> function loadCategories(){ var select = document.getElementById("categoriesSelect"); select.onchange = updateSubCats; for(var i = 0; i < categories.length; i++){ select.options[i] = new Option(categories[i].val, categories[i].id); } } function updateSubCats(){ var catSelect = this; var catid = this.value; var subcatSelect = document.getElementById("subcatsSelect"); subcatSelect.options.length = 0; //delete all options if any present for(var i = 0; i < subcats[catid].length; i++){ subcatSelect.options[i] = new Option(subcats[catid][i].val,subcats[catid][i].id); } } -
Categories and subcategories array and dynamic dropdown list
z4z07 replied to z4z07's topic in PHP Coding Help
Ok, i appologies for my english because i'm a little bit tired, so let me explain more clearly. So lets say like this i have 2 main categories ( IT and MOBILE ) these 2 categories they are not in a table in database because the are only two and are prestabilited. For every category i have the same subcategories and subsubcategories like IT -> Computers --> HDD's and MOBILE -> Iphone --> Iphone7 (hope i'm clear). In the database i store two tables one for IT (subcategory_table) and one for Mobile (subsubcategory_table) In these tables i have the following structure: 1. subcategory: id_subcat, name, url, it (or mobile - the name of the main category) 2. subsubcategory: id_subsubcat, name, url, id_subcat Now base on these i wanna solve the problems from my main post. Hope i was very cleary and you understood my english! -
Categories and subcategories array and dynamic dropdown list
z4z07 replied to z4z07's topic in PHP Coding Help
For the 1st problem i have the following code to display the subcategories and categories in the menu, but this code will return me the result as you see in the screen i attached. http://tinypic.com/r/2ue2zxl/9 <?php $result = mysqli_query($conn, "SELECT * FROM domeniu_activitate INNER JOIN subdomeniu_activitate ON domeniu_activitate.id_domeniu = subdomeniu_activitate.id_domeniu WHERE categorie = 'servicii'"); while($row = mysqli_fetch_array($result)) { echo '<li>'; echo '<a href="">' . $row['nume_domeniu'] . '</a>'; echo '<ul>'; echo '<li><a href="servicii.php">' . $row['nume_subdomeniu'] . '</a></li>'; echo '</ul>'; echo '</li>'; } ?> -
Categories and subcategories array and dynamic dropdown list
z4z07 replied to z4z07's topic in PHP Coding Help
The database has a proper design with catID in subcat table etc. The problem i have is how can i dynamic bring the to front. -
Categories and subcategories array and dynamic dropdown list
z4z07 posted a topic in PHP Coding Help
Hey guys, I'm struggling for a while to 2 things for my website. 1st - In my db i have 2 main categories - with 10 subcategories and another 10 subsubcategories. From now i have a main menu wich i want to display dynamic the subcategories and subsubcategories like in the code i've provided below <li><a href="marci.php"><i class="fa fa-building" aria-hidden="true" style="font-size: 14px;"></i> Marci</a> <ul class="dropdown"> <li> <a href="marci.php">Auto</a> <ul> <li><a href="">Masini</a></li> <li><a href="">Piese auto</a></li> <li><a href="">Accesorii auto</a></li> <li><a href="">Acumultori auto</a></li> <li><a href="">Anvelope Auto</a></li> </ul> </li> <li> <a href="marci.php">Constructii</a> <ul> <li><a href="">Acoperisuri</a></li> <li><a href="">Ferestre si usi</a></li> <li><a href="">Zidarie</a></li> <li><a href="">Gleturi si adezivi</a></li> <li><a href="">Termoizolatie</a></li> <li><a href="">Sanitare</a></li> <li><a href="">Alte categorii </a></li> </ul> </li> </ul> </li> 2nd - In my register form i have 3 select inputs with categories, subcategories and subsubcategories, now i want when a user select a category display the 2 selects with subcat and subsubcat, and if a subcat is selected to display the right categories and so on. I've posted a picture below to see how it looks How can i achive this two things! Thank you very much! -
Restrict user access in backend for specific pages!
z4z07 replied to z4z07's topic in PHP Coding Help
Yes. Why? You say that may be the problem??? -
Restrict user access in backend for specific pages!
z4z07 replied to z4z07's topic in PHP Coding Help
Any help... please... -
Restrict user access in backend for specific pages!
z4z07 replied to z4z07's topic in PHP Coding Help
Not working ... If i logged in with a user who have user_level = admin or user_level = editor shows only No Admin. In the pages.php file i've put the following code: <?php include '_inc/access.php'; ?> <?php // only Admin: if($user_wert == "2") // This is the Query for the Admin { echo "This Looks only the Admin"; exit; } else { die("No Admin"); } ?> In this page i want only the admin to see it. -
Restrict user access in backend for specific pages!
z4z07 replied to z4z07's topic in PHP Coding Help
Something like that, but except administrator part. Forget the adminsitrator part because he can see al the pages. What i want to do is to put the code into a .php page called access.php and include this page in the pages that i want to protect from the user who have user_level = editor. So i want that the users who have user_level = editor to see only the pages that i've not included the script - the pages that are accesible for every one. For example: i have pages admin.php, pages.php, newsletter.php and messages.php - the admin can view all the pages, but the editor can view online admin.php and newsletter.php, so for that i must include the script in the rest of the pages messages.php and pages.php to restrict access for users that are logged in with user_level = editor. -
Hi guys, in my database i have the table called users, where i have 5 fields (id, username, email, password, user_level) - for the user_level field i have 2 options administrator and editor. What i want to do is that when the user who is logged in have administrator in the user_level field to see all the pages from backend, and the user who have in the user_level field editor to see only some of the pages from the backend such as newsletter, or messages. I hope you understand what i'm asking if not fell free to ask me if you need more specific details. I tried to make a php page called access.php wher i put the following code, but not working <?php session_start(); $sql = $mysqli->query("SELECT user_level FROM imobiliare_users WHERE id=$id"); $user_level = $mysqli->query($sql); echo $user_level; if ($user_level !="administrator") { echo "You are not the proper user type to view this page"; die(); } ?> Hope you can help me. Thx in advance for help.