Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Arturs Sosins  >  Phones Complete class  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Simple example
Class: Phones Complete class
Query information of devices from Phones Complete
Author: By
Last change: credits changed
Date: 3 years ago
Size: 2,144 bytes
 

Contents

Class file image Download
<?php
/************************************************************* 
 * This script is developed by Arturs Sosins aka ar2rsawseen, http://webcodingeasy.com 
 * Fee free to distribute and modify code, but keep reference to its creator 
 * 
 * This class can create user friendly interface to browse 
 * PhonesComplete user generated mobile phone database
 * and perform searches for different phone models 
 * based on parameter values using PhonesComplete API
 * 
 * For more information, examples and online documentation visit:  
 * http://webcodingeasy.com/PHP-classes/Phones-Complete-class
**************************************************************/

//declaring class instance
include("./mobile.class.php");
$mob = new mobile_phones();


if(isset(
$_POST['search']))
{
    
//excluding post search data from request url
    
$ex[0] = 'search';
    
    
//creating search url from array of parameters
    
$url $mob->make_url($_POST$ex);
    
//performing search based on created url
    
$phones $mob->search($url);
    
//outputing result
    
echo "<pre>";
    
print_r($phones);
    echo 
"</pre>";
}
//selecting all phone related parameters
$arr $mob->get_param_list("bluetooth");
//simple userinterface form
echo "<form action='' method='post'>";
echo 
"<table>";
foreach(
$arr as $key => $val)
{
    echo 
"<tr>";
    
//create select input for bluetooth
    
if($val == "bluetooth")
    {
        echo 
"<td>".$val."</td><td><select name='".$val."'>";
        echo 
"<option value=''></option>";
        
//selecting all possible values for bluetooth parameter
        
$btvals$mob->get_all_values($val);
        
//outputting values
        
foreach($btvals as $bt)
        {
            echo 
"<option value='".$bt."'>".$bt."</option>";
        }
        echo 
"</select></td>";
    }
    
//else creating simple text boxes
    
else
    {
        echo 
"<td>".$val."</td><td><input type='text' name='".$val."' ";
        if(isset(
$_POST[$val]))
        {
            echo 
"value='".$_POST[$val]."'";
        }
        echo 
"/></td>";
    }
    echo 
"</tr>";
}
echo 
"<tr><td colspan='2' align='center'><input type='submit' value='Search'/></td></tr>";
echo 
"</table>";
echo 
"<input type='hidden' name='search'/>";
echo 
"</form>";
    
?>