//create db object// $db = new DB_Sql(); //open template// $tem = template_open("tekma_add.tpl"); //add header footer// $tem = template_add_head_foot($tem,head,foot); if ($_REQUEST["submit"]!='') { //then we need to insert a new one// $e_name = trim($_REQUEST['name']); $sql = "select * from tekma where name='$e_name'"; $db->query($sql); if ($db->affected_rows()>0) { $message = "Tekma ze obstaja"; } else { $sql = "INSERT INTO `timming`.`tekma` ( `tekma_id` , `name` ) VALUES ( NULL , '$e_name') "; $db->query($sql); $message = "Tekma uspesno vnesena"; } }
$db->query($sql); if ($db->next_record()) { $tem = str_replace("##TITLE##",$db->f("ename"). " - ". $db->f("tname"),$tem); } ///now the runners// $sql = "SELECT * FROM `timming` , users WHERE `timming`.event_id = $event_id AND tekma_id = $tekma_id AND STOP =0 AND `timming`.user_id = `users`.id_user "; $db->query($sql); if ($db->affected_rows()==0) { header("location:event_list.php"); exit(); } while ($db->next_record()) { $table.=$row; $table = str_replace("##NUMBER##",$db->f("number"),$table); $table = str_replace("##NAME##",$db->f("full_name"),$table); $table = str_replace("##USER_ID##",$db->f("id_user"),$table); $table = str_replace("##EVENT_ID##",$event_id,$table); $table = str_replace("##TEKMA_ID##",$tekma_id,$table); } //replace template variables// $tem = str_replace("##RUNNERS##",$table,$tem);