Jump to content

definitely need help with this problem


Recommended Posts

hey, i need some help, i am trying to use an array to create an dynamic statement so i can create this page no matter what the own decided to add to the database

$query = mysqli_query($con, "SELECT * FROM department ORDER BY id ASC") or die('Error: ' . mysqli_error($con));
            while($row = mysqli_fetch_assoc($query)){
                $id = $row['id'];
                $name = $row['name'];
                $list[] = $name;
                $detail = $row['description'];
                $department = $row['type'];
        foreach($list as $items){
            $items = strtolower($items);
            echo $items . '<br>';
        if($product == $items){

ok so the above codes, get all the information for me, which i need, it then add the name only to the array list[]. after that i used the foreach function to convert the array, and remove all uppercases to lowercases.


now for the last statement it suppose to create an if statement which it compares the items, to the $product and if it does then it does something. but this is the part i need help with.


how do i go about getting this done? any tips or hints?

Link to comment
Share on other sites

Is $product suppose to be string containing a product name? You can have the if statement inside the foreach loop. When it loops through and $product is equal to $items, then do something.

yes the $product gets the name from another page. and ill definitely try that, thanks Don

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...