$ row [ 'max'] 주어진 값에 따라 데이터베이스에 x 번을 삽입해야하는 다음 코드가 있지만 1 개만 삽입됩니다. 누군가 내 길을 보여 주실 수 있습니까? 감사.PHP 카운터 루프가 작동하지 않습니다.
어쩌면$query = "SELECT * FROM challenges WHERE rate='fixed'";
$query_result = mysql_query($query);
while ($row = mysql_fetch_array($query_result)) {
$spawn_time = preg_split('/,/', $row['time']);
$spawn_time_results = count($spawn_time);
$limitno = $row['max'];
$spawn_counter = 0;
while ($spawn_counter <= $spawn_time_results) {
if ($spawn_time[$spawn_counter] == date("i")) {
$time = time();
$insert_instance = "INSERT INTO instances (id,defeated,time)
VALUES ('{$row['id']}',0,{$time})";
$insert_result = mysql_query($insert_instance);
}
$spawn_counter++;
}
}
오류 메시지가 있습니까? '$ insert_result = mysql_query ($ insert_instance);를'$ insert_result = mysql_query ($ insert_instance) 또는 die (mysql_error());로 바꾸어보십시오. – svens
데이터베이스는 어떻게 생겼습니까? 어쩌면 기둥이 유일 할 수도 있습니다. 인스턴스의 열 id가 문자열 또는 숫자입니까? – Codler