PHP Classes

File: x/funcoes.php

Recommend this page to a friend!
  Classes of Rodrigo Faustino   PHP Game Geolocation   x/funcoes.php   Download  
File: x/funcoes.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: PHP Game Geolocation
Game to add locations of crimes to a map
Author: By
Last change:
Date: 2 months ago
Size: 1,177 bytes
 

Contents

Class file image Download
<?php
function monta_select($campo, $start, $end) {
   
$select = "<select name=\"$campo\" id=\"$campo\">\n";
    for(
$i = $start; $i <= $end; $i++) {
       
$select .= "\t<option value=\"". sprintf("%02d", $i) ."\">".sprintf("%02d", $i)."</option>\n";
    }
       
$select .= "</select>\n";
    return
$select;
}

function
monta_combo($campo) {
    if(
$campo == "") {
        return
false;
    }
   
$select = "<select name=\"campo\">\n";
    for(
$i = 0; $i < count($campo); $i++) {
       
$select .= "\t<option value=\"$i\">{$campo[$i]}</option>\n";
    }
       
$select .= "</select>\n";
    return
$select;
}

function
Pega_Preferencia($campo) {
   
$campo = explode(",", $campo);
    for(
$i = 0; $i < count($campo); $i++) {
        switch (
$campo[$i]) {
            case
"R":
               
$preferencia[] = "Romantico";
                break;
            case
"S":
               
$preferencia[] = "Suspense";
                break;
            case
"P":
               
$preferencia[] = "Policial";
                break;
            case
"F":
               
$preferencia[] = "Fic??o";
                break;
        }
    }
    return isset(
$preferencia) ? $preferencia : false;
}

function
Seleciona_Item($valor, $campo) {
    return
preg_replace("#<option value=\"$valor\">#is", "<option value=\"$valor\" selected=\"selected\">", $campo);
}
?>