list all posts

<h3>Posts</h3>
<ul>

                <?php while(have_posts()) : the_post(); ?>

<?php foreach((get_the_category()) as $category)
                          { $my_query = new WP_Query(‘category_name=’ . $category->category_nicename . ‘&orderby=title&order=asc&showposts=100’);} ?>

                       <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>

       <li><a href=”<?php the_permalink(); ?>” title=”<?php the_title(); ?>”><?php the_title(); ?></a></li>

                      <?php endwhile; ?>

<?php break; endwhile; ?>

</ul>

Posted in WordPress. Comments Off on list all posts »

Code to display visitors IP address on website

get_ip_list below is a function that you must call in order to get something.

function get_ip_list() {
$tmp = array();
if (isset($_SERVER[‘HTTP_X_FORWARDED_FOR’]) && strpos($_SERVER[‘HTTP_X_FORWARDED_FOR’],’,’)) {
$tmp += explode(‘,’,$_SERVER[‘HTTP_X_FORWARDED_FOR’]);
} elseif (isset($_SERVER[‘HTTP_X_FORWARDED_FOR’])) {
$tmp[] = $_SERVER[‘HTTP_X_FORWARDED_FOR’];
}
$tmp[] = $_SERVER[‘REMOTE_ADDR’];
return $tmp;
}
echo echo implode(“,”,get_ip_list());

Posted in Php Functions, Php Skills. Comments Off on Code to display visitors IP address on website »

Redirect by PC or mobile access

php code as follows:

$iswap = isset($_SERVER[‘HTTP_ACCEPT’])? $_SERVER[‘HTTP_ACCEPT’]:”;
if(strpos($iswap,”wap”)>0)
{
@header(“Location: /wap/”);
}

Posted in Php Code. Comments Off on Redirect by PC or mobile access »

Add php code into html for lunarpage.com

Add php code into html for lunarpage.com linux host.

try this line in a blank .htaccess

AddType application/x-httpd-php php html

Posted in Php Code, Php Skills. Comments Off on Add php code into html for lunarpage.com »

Add php code into html for php5

AddType application/x-httpd-php5 .html .htm .php
AddHandler application/x-httpd-php5 .html .htm .php

Posted in Php Code, Php Skills. Comments Off on Add php code into html for php5 »

Load different pictures each time.

Just add the following codes within the body:

<script language=”JavaScript”>

var how_many_ads = 5
var now = new Date()
var sec = now.getSeconds()
var ad = sec % how_many_ads;
ad +=1;

if (ad==1){
url=”http://kingphp.com“;
alt=”ad1″;
banner=”img/ad1.jpg”;
width=”240″;
height=”320″;
}

if (ad==2) {
url=”http://kingphp.com“;
alt=”ad2″;
banner=”img/ad2.jpg”;
width=”240″;
height=”320″;
}

if (ad==3) {
url=”http://kingphp.com“;
alt=”ad3″;
banner=”img/ad3.jpg”;
width=”240″;
height=”320″;
}

if (ad==4) {
url=”http://kingphp.com“;
alt=”ad4″;
banner=”img/ad4.jpg”;
width=”240″;
height=”320″;
}

if (ad==5) {
url=”http://kingphp.com“;
alt=”ad5″;
banner=”img/ad5.jpg”;
width=”240″;
height=”320″;
}

document.write(‘<center>’);
document.write(‘<a href=\”‘ + url + ‘\” target=\”_blank\”>’);
document.write(‘<img src=\”‘ + banner + ‘\” width=’)

That’s all.

</script>

Posted in Javascript. Comments Off on Load different pictures each time. »

Javascript Changing Picture

Ad the following code between head:
<code>
<script language=JavaScript>
<!–
var pic_ar=new Array();
var pic_arlink=new Array();
var adNum=0;
pic_ar[0]=”img/ad1.jpg”;
pic_ar[1]=”img/ad2.jpg”;
pic_ar[2]=”img/ad3.jpg”;
pic_ar[3]=”img/ad4.jpg”;
pic_ar[4]=”img/ad5.jpg”;
pic_ar[5]=”img/ad6.jpg”;
pic_ar[6]=”img/ad7.jpg”;
pic_ar[7]=”img/ad8.jpg”;
pic_ar[8]=”img/ad9.jpg”;
pic_ar[9]=”img/ad10.jpg”;
pic_ar[10]=”img/ad11.jpg”;
pic_ar[11]=”img/ad12.jpg”;
var preloadedimages=new Array();
for (i=1;i<pic_ar.length;i++){
preloadedimages[i]=new Image();
preloadedimages[i].src=pic_ar[i];
}
function setTransition(){
if (document.all){
pic_arrotator.filters.revealTrans.Transition=Math.floor(Math.random()*23);
pic_arrotator.filters.revealTrans.apply();
}
}
function playTransition(){
if (document.all)
pic_arrotator.filters.revealTrans.play()
}
function nextAd(){
if(adNum<pic_ar.length-1)adNum++ ;
else adNum=0;
setTransition();
document.images.pic_arrotator.src=pic_ar[adNum];
playTransition();
theTimer=setTimeout(“nextAd()”, 5000);
}
function displayStatusMsg() {
status=pic_arlink[adNum];
document.returnValue = true;
}
//–>
</script>
</–more–>
</code>
add the following code in the body:
<code>
<p style=”text-align:center;text-indent:0″><IMG style=”FILTER: revealTrans(duration=2,transition=20);border:1px solid #ccc” height=320 src=”img/ad1.jpg” width=”240″ border=”1″ name=”pic_arrotator”></p>
<script language=JavaScript>nextAd()</script>

</code>
That’s all.

Posted in Javascript. Comments Off on Javascript Changing Picture »

PHP to detect mobile phones

The most efficient way to detect mobile phones with PHP, this simply queries the accept headers, the user agent and checks for any tell tale signs that the browser we’re sniffing is a mobile device. (more…)

Posted in Php Code. Comments Off on PHP to detect mobile phones »

How to remove the special characters in title?

< ?php $hotel=" How to study; PHP? "; $foldername = stripslashes ($hotel); //This erase white-spaces on the beginning and the end in each line of a string: $foldername = preg_replace('~^(\s*)(.*?)(\s*)$~m', "\\2", $foldername); //erases all NON-alfanumerics $foldername = ereg_replace("[^[:alnum:] ]","",$foldername); (more…)

Posted in Php Learning. Comments Off on How to remove the special characters in title? »

how to deal with a sentence as a page title?

<?php
$hotel=”  How to study PHP  “;
$hotel= trim($hotel);
$array=explode(” “, $hotel);

$hotel=implode(“-“, $array);
echo ($hotel);
?>

Posted in Php Skills. Comments Off on how to deal with a sentence as a page title? »
King Php Science Designed by:KingPhp.com Welcome, you are from: 54.205.172.57