如何检索 php 中表的布尔值?

How to retrieve the boolean values of the tables in php?

<?php
include 'config.php';

$sql1="SELECT Project_id FROM assigned_project_tester  where Tester_name IN (SELECT Username FROM user_master where Username='meet.patel')";
$result=$conn->query($sql1);


while($row=$result->fetch_assoc())
{  echo $proid[]=$row['Project_id'];            //this is getting printed from table project_master table   
    echo '<br>';

} 
$i='';
for ($i=0; $i<sizeOf($proid); $i++)
{
    echo 'here are agian project names';
    echo $proid[$i];                          //this checkpoint to check array  and for loop is working or not
    echo '<br>';
   $sql2="select Test_creation,Test_execution from assigned_project_tester where Project_id =' " . $proid[$i] . "'   ";
  $result1=$conn->query($sql2);
 while($row1=$result1->fetch_assoc())      //I think it is not getting inside while loop
  { echo 'inside if ';                     //this is not getting printed .............
     echo $row1['Test_creation'];          //test_creation is boolean value and data type is tinyint in table assigned_project_tester
     echo $row1['Test_execution'];         //test_execution is boolean value and data type is tiny integer in table assigned_project_master
                                           //what i want to do is print yes if user has test_creation permission else no
  }                                        //same for test_execution I knew that value stored in database is 1 and 0 but
                                           //why it is not getting printed        
}

Here two sql file code for two tables which I am using in my code is written
-- phpMyAdmin SQL Dump
-- version 3.3.9
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Mar 24, 2015 at 06:07 AM
-- Server version: 5.1.53
-- PHP Version: 5.3.4

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Database: `tmtool`
--

-- --------------------------------------------------------

--
-- Table structure for table `assigned_project_tester`
--

CREATE TABLE IF NOT EXISTS `assigned_project_tester` (
  `Assigned_id` int(11) NOT NULL AUTO_INCREMENT,
  `Project_manager` varchar(45) DEFAULT NULL,
  `Project_id` varchar(45) DEFAULT NULL,
  `Tester_name` varchar(45) DEFAULT NULL,
  `Test_creation` tinyint(1) NOT NULL,
  `Test_execution` tinyint(1) NOT NULL,
  PRIMARY KEY (`Assigned_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=61 ;

--
-- Dumping data for table `assigned_project_tester`
--

INSERT INTO `assigned_project_tester` (`Assigned_id`, `Project_manager`, `Project_id`, `Tester_name`, `Test_creation`, `Test_execution`) VALUES
(45, 'Pritesh Usadadiya', 'PRJ005', 'meet.patel', 0, 0),
(46, 'Pritesh Usadadiya', 'PRJ005', 'Pritesh', 1, 1),
(47, 'Pritesh Usadadiya', 'PRJ005', 'trilok.patel', 1, 1),
(49, 'Pritesh Usadadiya', 'PRJ009', 'Pritesh', 0, 1),
(50, 'Pritesh Usadadiya', 'PRJ009', 'trilok.patel', 0, 1),
(52, 'Pritesh Usadadiya', 'PRJ011', 'trilok.patel', 1, 0),
(54, 'Pritesh Usadadiya', 'PRJ008', 'Pritesh', 1, 1),
(55, 'Pritesh Usadadiya', 'PRJ008', 'trilok.patel', 1, 1),
(56, 'Pritesh Usadadiya', 'PRJ10', 'meet.patel', 0, 1),
(57, 'Pritesh Usadadiya', 'PRJ10', 'trilok.patel', 0, 1),
(58, 'Pritesh Usadadiya', 'PRJ009', 'meet.patel', 1, 1),
(59, 'Pritesh Usadadiya', 'PRJ011', 'meet.patel', 0, 1),
(60, 'Pritesh Usadadiya', 'PRO10', 'meet.patel', 1, 1);



-- phpMyAdmin SQL Dump
-- version 3.3.9
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Mar 24, 2015 at 06:08 AM
-- Server version: 5.1.53
-- PHP Version: 5.3.4

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Database: `tmtool`
--

-- --------------------------------------------------------

--

我想从名为 assigned_project_tester 的 table 中检索 Test_creation 和 Test_execution 的值,如果值为 1 则打印 yes 否则打印 no.I 有在代码中为您完成注释,请检查它。好吧,我正在尝试解决这个问题,因为 29 hours.All 正在打印其他内容,例如 project_id,而这只是行不通,请帮助我。提前致谢

我对你的一些问题感到困惑。似乎您不需要两个单独的查询。只有这个行得通吗?

SELECT Project_id, 
       Test_creation, 
       Test_execution 
FROM   assigned_project_tester 
WHERE  Tester_name = 'meet.patel'

这应该会列出 "meet.patel" 分配的所有项目及其状态。

然后您可以使用 while 语句循环遍历结果。

$result = $mysqli->query($query);

while ($row = $result->fetch_assoc()) {
    echo $row["Project_id"];
    echo $row["Test_creation"];
    echo $row["Test_execution "];
}

$result->free();