Get the ID generated in the last query (PHP)
mysql_insert_id — Get the ID generated in the last query
Use
mysql_insert_id();
More information can be found at:
http://php.net/mysql_insert_id
Useful Codes & Tips for Web Coding and Macros
mysql_insert_id — Get the ID generated in the last query
Use
mysql_insert_id();
More information can be found at:
http://php.net/mysql_insert_id
How to print 3 letter Alphanumeric with atleast 1 character as Numeric.
<?php
$alphanumeric= array(“0″,”1″,”2″,”3″,”4″,”5″,”6″,”7″,”8″,”9″,”A”,”B”,”C”,”D”,”E”,”F”,”G”,”H”,”I”,”J”,”K”,”L”,”M”,”N”,”O”,”P”,”Q”,”R”,”S”,”T”,”U”,”V”,”W”,”X”,”Y”,”Z”);
for($i=0; $i<36; $i++)
{
for($j=0; $j<36; $j++)
{
for($k=0; $k<36; $k++)
{if($i>=’10′ && $j>=’10′ && $k>=’10′)
{
}
else
{
$newword=$alphanumeric[$i].$alphanumeric[$j].$alphanumeric[$k];
echo “$newword<br>”;
}}
}
}?>
How to print all 3 letter long Alphanumeric words.
<?php
$alphanumeric= array(“0″,”1″,”2″,”3″,”4″,”5″,”6″,”7″,”8″,”9″,”A”,”B”,”C”,”D”,”E”,”F”,”G”,”H”,”I”,”J”,”K”,”L”,”M”,”N”,”O”,”P”,”Q”,”R”,”S”,”T”,”U”,”V”,”W”,”X”,”Y”,”Z”);
for($i=0; $i<36; $i++)
{
for($j=0; $j<36; $j++)
{
for($k=0; $k<36; $k++)
{$newword=$alphanumeric[$i].$alphanumeric[$j].$alphanumeric[$k];
echo “$newword<br>”;}
}
}?>
How to Print Alphabets.
You can print a range of Alphabets e.g. from A to Z or A to ZZ like A, B, C … AA, AB, AZ… ZY, ZZ and more
$length=”3″;
for ($alpha=’A'; strlen($alpha)<=$length; $alpha++)
{print “$alpha<br>”;
}
With this script you can display how much this Time this page has taken to load.
<?php
// Insert at the start of your document
$time = round(microtime(), 3);
// Insert at the end of your document
$time2 = round(microtime(), 3);
$generation = $time2 – $time;
echo “This page took $generation seconds to render”;
?>
You can fetch data from a webpage by using this script. It is useful when you need to fetch data like Stock Rates on your site.
Like if you want to fetch data between span tags.
<?php
// retrieve htmltagcontent tag contents
function get_htmltagcontent($file){
$h1tags = preg_match_all(‘/(<span>)(.*)(<\/span>)/ismU’,$file,$patterns);
$res = array();
array_push($res,$patterns[2]);
array_push($res,count($patterns[2]));
return $res;
}
$url_base=”http://Specify Base URL/”;
$url_dir=”Specify Directory Here or Leave it Blank”;
$pages_start=”1″;
$pages_num=”2″;
$pages_rows=”10″;
for($i=$pages_start; $i<($pages_num+$pages_start); $i++)
{
$url_query=($i*$pages_rows).”/”; //Create URL Query Part here
$url=$url_base.$url_dir.$url_query;
$file = file_get_contents($url);
$htmltagcontent = get_htmltagcontent($file);
if($htmltagcontent[1] != 0)
{
foreach($htmltagcontent[0] as $key => $val){
echo “<li>####” . $val . “</li>”;
}
echo “</ul>”;
}
else
{
echo “<br/><div class=\”error\”>No Tags found</div><br/>”;
}
}
?>
<?php
function getTitle($url) {
$fh = fopen($url, “r”);
$str = fread($fh, 5000);
fclose($fh);
$str2 = strtolower($str);
$start = strpos($str2, “<title>”)+7;
$len = strpos($str2, “</title>”) – $start;
return substr($str, $start, $len);
}
?>
<?php
$url=”http://example.com”;
echo getTitle($url);
function get_page_title($url)
{
if( !($data = file_get_contents($url)) ) return false;
if( preg_match(“#<title>(.+)<\/title>#iU”, $data, $t)) {
return trim($t[1]);
}
else
{
return false;
}
}
?>
<?php
function getTitle($Url){
$str = file_get_contents($Url);
if(strlen($str)>0){
preg_match(“/\<title\>(.*)\<\/title\>/”,$str,$title);
return $title[1];
}
}
$url=”http://example.com”;
echo getTitle($url);
?>