I wrote the below query and when I run it in my php file it does not come back with any results. But when I go in phpmyadmin and test the query it returns the proper results.
I pull the selected fields from a multiple select drop down on the page before and send it into $industry. I print $industry right now to make sure that the correct value is passed. Then I am trying to run a query where I need to have get all companies from the addcompany table where I only need the Companies that are Active (active_company is the column), and also are in the same industry as the selected ones on the page before ($industry). After the query I try to print the results but I do not get anything back.
$industry=$_POST['MultipleIndustryType'];
print_r($industry);
$query= "SELECT * FROM addcompany WHERE active_company LIKE '%Active%' AND industry_types LIKE '%$industry%'";
$result= mysqli_query($mysqli, $query) or die(mysqli_error($myslqi));
$rows=mysqli_fetch_assoc($result);
print_r($rows['company_name]');
What happens after this code is that I use FPDF and FPDI to create a pdf report using a while loop which loops like this:
while($rows=mysqli_fetch_array($result)){
I do have a connection ($mysqli) and it does work. I've been going through other peoples questions on here and have tried numerous different possible solutions to my problem to avail.
EDIT: the dropdown on the page before pulls from the database industry types Ex. None, Biopesticides, Biofertilizers,...etc.
the expected result from
print_r($industry);
, for example i select Biopesticides from the prior page, is Array ( [0] => Biopesticides ). I have always been able to get this to print.
the expected result from the next one,
print_r($rows['company_name]');
,should be a list of company names from my database. Ex.:
Array ( [0] => test company 1 [1] => test company 1 [2] => test company 2 )
or something similar to the above.