您好我的表格中有一个名为百分比的字段,但我想要做的只是显示基于百分比的结果,即如果我设置10它只会显示10%的结果。
这是我的数据库,它是mysql中的Joomla数据库代码
// Select the required fields from the table.
$query->select(
'a.id, a.title, a.simulator, a.generation, a.quality, a.quantity, a.percentage, a.attribute, a.checked_out, a.checked_out_time, a.catid' .
', a.state, a.access, a.created, a.created_by, a.version, a.ordering'
);
$query->from('#__evolutionary_texture AS a');
// Join over the users for the checked out user.
$query->select('uc.name AS editor')
->join('LEFT', '#__users AS uc ON uc.id=a.checked_out');
// Join over the asset groups.
$query->select('ag.title AS access_level')
->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access');
// Join over the species.
$query->select('category.title AS category_title')
->join('LEFT', '#__categories AS category ON category.id = a.catid');
$query->select('parent.title AS parent_title')
->join('left', '#__categories AS parent ON parent.id=category.parent_id');
// Join over the section.
//$query->select('section.title AS section_title')
// ->join('LEFT', '#__categories AS section ON section.id = a.catid');
// Join over the users for the author.
$query->select('ua.name AS author_name')
->join('LEFT', '#__users AS ua ON ua.id = a.created_by');
$query->where('parent.title = ' . $db->quote($species));
//echo "section = $section";
$query->where('category.title = ' . $db->quote($section));
// check where generation.
$query->where('a.generation = ' . $db->quote($generation));
// check where simulator.
$query->where('a.simulator = ' . $db->quote($simulator));
// Debug the query
//var_dump($db->replacePrefix( (string) $query ) );
// Set the query and load the result.
$db->setQuery($query);
因为我尝试做的只是根据百分比显示纹理,因为这些数据被导入到名为第二人生的游戏中
我的百分比字段现在从0到100
答案 0 :(得分:0)
在分析您的代码/问题后,我可以建议您关注。
random_no
和times
random_no
的值为=array() of 100 int values from 1 to 100 randomly
//示例=array(23,15,67,98, ...., 5); // all 1-100 numbers once only
times
的值最初为0
,每次查询后将增加1
。当值达到99
时,接下来它将为0
并重新计算random_no
的值。 //代码在哪里查询数据库a.percentage >= $random_no[$times]
创建 $ randome_no 数组:
$random_no=array();
for($i=1;$i<=100;i++){
$random_no[]=$i;
}
shuffle($random_no);
以上方法将随机选择记录percentage
次