Tuesday, February 19, 2013

Url-Parser-Function

Url Parser Function !

Asign variables for each parse and build your own Framework !

function parseIt()
{
$url = 'http://127.0.0.1/root/index.php?arg=value#3445678abcd';
print_r(parse_url($url));
echo'';
echo '
http://';
echo parse_url($url, PHP_URL_HOST);
echo '
';
echo parse_url($url, PHP_URL_PATH);
echo '
?';
echo parse_url($url, PHP_URL_QUERY);
echo '
#';
echo parse_url($url, PHP_URL_FRAGMENT);
//parse_str($str);

} //end function parseIt()
echo parseIt();

OUTPUTS:
Array ( [scheme] => http [host] => 127.0.0.1 [path] => /root/index.php [query] => arg=value [fragment] => 3445678abcd )

http://127.0.0.1
/root/index.php
?arg=value
#3445678abcd

Friday, February 15, 2013

Simplist Php Framework Ever.

Simple Php Framework. 

 Make this your main controller index.php page and start creating. Include your modals, in turn they request your views and page controllers. To pass id's for user etc by using index.php?page=profile&id= etc. Links too can all be passed using index.php?page= etc.
Add more pages if needed.

include('head.php');                    //head section above body tag= one or two second for members
?>
if(isset($_GET['page']))
{
  $page = ($_GET['page']);

  if($page == 'home')
  {
  include('menu.php');          //or members menus after login with a duplicate member/index.php
  include('leftmenu.php');
  include('home.php');
  include('rightmenu.php');
  include('footer.php');
  }
    if($page == 'about')
    {
    include('menu.php');
    include('leftmenu.php');
    include('about.php');
    include('rightmenu.php');
    include('footer.php');
    }
       if($page == 'policy')
       {
       include('menu.php');
       include('leftmenu.php');
       include('policy.php');
       include('rightmenu.php');
       include('footer.php');
       }
           if($page == 'signup')
           {
            include('menu.php');
            include('leftmenu.php');
            include('signup.php');
            include('rightmenu.php');
            include('footer.php');
            }
               if($page =='')
               {
               include('menu.php');
               include('leftmenu.php');
               include('home.php');
               include('rightmenu.php');
               include('footer.php');
               }

} else {
       include('menu.php');
       include('leftmenu.php');
       include('home.php');
       include('rightmenu.php');
       include('footer.php');
}
?>

Monday, February 4, 2013

Php Percent Of Profit Calculator Function

To customize this remove the =100 and =50 from the variable values. Place this into a php page and use a form to pass the values and sanitize them then add the function call line  below that to show output of this calculator. You will need two inputs to be passed one for Retail and One for Cost.

function percentOf($retail=100, $cost=50)
{
 $profit = ($retail - $cost);
 $percent = ($profit / $retail);
 $totalpercent = ($percent * 100);
 echo 'Total Retail
$';
 echo $retail;
 echo '
Subtract Total Cost
$cost;
Equals Profit $';
 echo $profit;
 echo '
Percent Total=';
 echo $percent;
 echo '%
You made a ';
 echo $totalpercent;
 echo ' percent profit';
 
 
 
  //return $link;

} // end function percentOf()

echo percentOf();

Php Retail Grocery Daily Report Function

PHP Retail Grocery DAILY REPORT FUNCTION

function dailyRep($totalz=17098, $tax=57, $gaskey=1775, $gas=1772, $lot=412, $mo=275, $ccr=545, $nonfood=1270, $oring=23, $dep=15998)
{
 $premerch=($totalz - $gaskey - $tax - $lot - $mo - $oring);
 $totalsales=($premerch + $lot + $mo);
 $nontax=($premerch - $nonfood);
 $gasdif=($gas - $gaskey);
 $moneys=($premerch + $tax + $gas + $lot + $mo);
 $cash=($dep + $ccr);
 $cashshort=($dep + $ccr - $moneys);

 echo 'Total From Z Reading
$';
 echo $totalz;
 echo '
Less Overings
$';
 echo $oring;
 echo '
Less Gas Sales Actual-----------------------Gas Actual
$';
 echo $gas;
 echo '
Less Gas From Z Tape
$';
 echo $gaskey;
 echo '
Dif +/-
';
 echo $gasdif;
 echo '
Equals Non Taxable Grocery Sales
$';
 echo $nontax;
 echo '
Plus Taxable Grocery Sales
$';
 echo $nonfood;
 echo '
Equals Total Merchandise Sales--------------Total Merchandise Sales
$';
 echo $totalsales;
 echo '
Add Tax-------------------------------------Plus Tax
$';
 echo $tax;
 echo '
Money To Account For-----------MA-------------Money Accounting
$';
 echo $moneys;
 echo '
Credit Card Report (counts as money)--CCR-----Add To Cash Count
$';
 echo $ccr;
 echo '
Total Money Counted Including Checks & CCR----Cash Deposit Count
$';
 echo $cash;
 echo '
Cash +/-(If this line is less than M/A it is Short)Total Over/Short Cash
';
 echo $cashshort;
  //return $link;

} // end function myFunction()

echo dailyRep();  //OUR FUNCTION CALL

Saturday, February 2, 2013

Automatic Query Pagination

Automatic Pagination Using query_count And Limit Control !

Simply place then into a function and query a count from the database, and assign $total to your query returned value

$total = $result_count['value'];

//querymsql_count as $total then devide by rows !
$rows = 10; // how many rows to show on each page !
$total = 50; //taken from query_count rows in database.
$count = ($total / $rows); //devide $total by $rows and pass this for pagination foreach
foreach (range('1', ''.$count.'') as $char) {
 print '' . $char . ' | ';
}
?>

Sunday, January 20, 2013

CONVERTING WWW ENTERED TEXT TO ACTUAL LINKS

 
HOW TO CONVERT NORMAL TEXT WEB LINKS INTO ACTUAL LINKS FOR BLOGS AND WALL POST.
This code will remove any www.something .somethings from all text and convert them to actual links.

$string = " bla bla bla http://www.example.com/ bla bla http://www.example.net/ bla bla bla";

$m = preg_match_all('/www.\/\/[a-z0-9A-Z.]+(?(?=[\/])(.*))/', $string, $match);

if ($m) {
$links=$match[0];
for ($j=0;$j<$m;$j++) {
$string=str_replace($links[$j],''.$links[$j].'">'.$links[$j].'</a>',$string);
}
}

echo $string;

?>