duanpi7578 2016-08-04 20:34
浏览 33

Mysqli查询没有返回任何内容,但在数据库中测试时,它返回需要返回的内容

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.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 ogg dd trandata 报错
    • ¥15 高缺失率数据如何选择填充方式
    • ¥50 potsgresql15备份问题
    • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
    • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
    • ¥60 pb数据库修改与连接
    • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
    • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
    • ¥20 神经网络Sequential name=sequential, built=False
    • ¥16 Qphython 用xlrd读取excel报错