【发布时间】:2012-01-27 16:52:49
【问题描述】:
我整天都在尝试用 PHP 实现以下目标:
更新:这是我正在使用的代码,请阅读中间的消息
<?php
include ('acs_params.php');
$acs_value_based = array(25, 30, 35, 40, 45, 50, 60, 70);
$acs_types = array("$add_total","$done_total");
print_r($acs_id);
foreach ( $acs_value_based as &$value ) {
foreach ( $acs_types as &$counters) {
if ($counters >= $value) {
if ($acs_types[0] == $counters) {$acs_types1 = '1'; $acs_name = 'Tasker'; $acs_action = 'adding';}
if ($acs_types[1] == $counters) {$acs_types1 = '2'; $acs_name = 'Completer'; $acs_action = 'completing';}
if ($value == '25') { $acs_lvl = '1'; $acs_id = '25';}
if ($value == '30') { $acs_lvl = '2'; $acs_id = '30';}
if ($value == '35') { $acs_lvl = '3'; $acs_id = '35';}
$acs_exists = $acs_types1 . $acs_id;
在这里它应该检查这个数组是否 print_r($acs_id);包含的值 $acs_存在。如果该值已经存在,则不应执行以下代码, 相反,脚本应该从头开始,但第二个值是 数组 print_r($acs_id);。如果该值尚不存在,则继续查询。 (我希望我的目标很明确)。
mysql_query("INSERT INTO users_log(id, log, userid, date, points, action) VALUES
(id, 'achievement 1', '$username', '$currenttime', '0', '8') ");
mysql_query("INSERT INTO users_achievements(id, userid, acs_id, date) VALUES
(id, '$username', '$acs_types1$acs_id', '$currenttime') ");
?>
【问题讨论】:
-
到目前为止你写了什么代码?
-
我真的不明白你想要做什么。你能举个例子吗?
-
请重新阅读更新后的问题:)
-
我还是不明白。为什么你一直在谈论“重新启动脚本,但使用数组的第二个值”???一个简单的循环有什么问题?还不清楚……
$acs_exists是字符串吗?为什么要附加当前 id ($acs_id)?$acs_types1是什么?