Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/248.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 查找特定字段的行id号_Php - Fatal编程技术网

Php 查找特定字段的行id号

Php 查找特定字段的行id号,php,Php,我工作的组织有一个投票平台,是在我任职之前建立的,我找不到具体的指标来获得触发将投票限制在每人一张所需的投票条件。我被告知一个print\r会给我所需的适当数据,但我无论如何都不是一个php开发人员,甚至不知道如何运行print\r。代码如下: if ($thewebform->data[6][0] == $row->id) //this is the row that needs to be edited echo '<link type="text/css" rel="

我工作的组织有一个投票平台,是在我任职之前建立的,我找不到具体的指标来获得触发将投票限制在每人一张所需的投票条件。我被告知一个print\r会给我所需的适当数据,但我无论如何都不是一个php开发人员,甚至不知道如何运行print\r。代码如下:

if ($thewebform->data[6][0] == $row->id) //this is the row that needs to be 
edited

echo '<link type="text/css" rel="stylesheet" 
href="/sites/default/files/awardsvoting/awardsvoting.css"/>';
echo '<hr/>';
echo "<strong>form name</strong><br/>";


// get the webform module
include_once(drupal_get_path('module', 'webform') 
."/includes/webform.submissions.inc");

// get all the webform submissions with the nid of the webform
$filters = array('nid' => 6548);

try {
$thewebforms = webform_get_submissions($filters);
// print_r($thewebforms);

//determine how many votes the project is entitled to, based on membership 
type
// if it's a corporate membership, they get two votes
if ($row->membership_type == '6'){
$votesallowed = 2;  
}
// if it's a non-profit membership, they get two votes
else if ($row->membership_type == '3'){
$votesallowed = 2;  
}

// if it's a student membership, they get none
else if ($row->membership_type == '5') {
$votesallowed = 0;  
}

// if it's any other type of membership, they get one
else {
$votesallowed = 1;
}
//echo "votes allowed = " . $votesallowed;
// figure out how many votes the project has already cast, if any
// the index of $thewebform->data has to be readjusted for the index of the 
org_id in the webform
$votesused = array();
    foreach($thewebforms as $thewebform) {
    // echo $thewebform->data[6][0];
    // print_r($row->id);
    if ($thewebform->data[6][0] == $row->id) {
        $votesused[] = $thewebform;
        }
    }

// determine if the project has any votes left  
$votesremaining = $votesallowed - count($votesused);
//echo "remaining votes: " . $votesremaining;
echo "Votes remaining: " . $votesremaining . "/" . $votesallowed . "<br/>";

if ($votesremaining > 0) {
    echo '<a class="myButton" href="voting url' . $row->id . '&cid=' . 
$_SESSION[CiviCRM][userID] . '">Vote! 
</a>';
}
echo '<hr/>';
}
catch (exception $e) {
drupal_set_message($e->getMessage());
}
第10行的代码中已经有行ID的打印。您可以通过删除//来取消对此的注释。这将显示$row->id中的所有数据,可能只是一个数字。我不知道您的代码或数据库的其余部分是什么样子的,因此这可能会也可能不会真正满足您的需求

有更多关于打印的信息

这样打印是所谓调试的一部分。请确保只在开发服务器上进行调试,而不是在实时环境中进行调试。否则,任何使用投票系统的人都可能看到调试信息

编辑:如下面评论中所述,您也可以尝试使用替换来代替打印

print_r($row->id);


如何运行打印\u r。。。。打印Web表单;或者你想看的任何变量。脚本执行完毕后,屏幕上将显示该对象/数组的数据结构。我们不知道这个数据结构,也不知道这个代码执行的上下文,也不知道创建这个场景所使用的示例数据,所以现在任何人都可以实际地给你很多帮助。我已经在我的问题中添加了其余的投票代码。我已尝试取消对print\r的注释,但仍然无法让它显示代码。请尝试回显print\r以查看您的问题中提到的var print,您提到将投票限制为每人一票。在代码中,它提到了每个项目的投票。在这种情况下,可以安全地假设这两个术语是可互换的吗?@Worthwelle是的,它们是可互换的。在这种情况下,根据您的会员级别,您有权获得不同数量的投票。我要查找的是org_id字段的id,它与成员类型相关。您可能需要在浏览器中查看页面源以查看打印的内容。如果没有显示值,您能否验证所做的更改是否已上载到运行代码的服务器?
echo $row->id;