^if(def $form:id && def $form:type){ } ^connect[$connect_string]{ $q[^table::sql{select id, text from quote where id^if($form:type eq 'next'){>}{<}'$form:id' and active=1 ^if($form:type eq 'prev'){order by id desc} limit 1}] ^if(!$q){ $q[^table::sql{select id, text from quote where active=1 order by id ^if($form:type eq 'next'){asc}{desc} limit 1}] } } var text='^untaint{$q.text}'^; var QId=$q.id^;