Website Design Nepal
Web Design Nepal, Website Design Nepal are the basic abstraction of this page.

PHP SOAP WSDL Script

Below is a simple example on how to use SOAP-WSDL with PHP. This example will help you pull data from WSDL using SOAP in PHP.

<?php
$client = new SoapClient("http://footballpool.dataaccess.eu/data/info.wso?wsdl");
$result = $client->TopGoalScorers(array('iTopN'=>5));
 
if ($_POST['topn'] > 0 && (int) $_POST['topn'] <= 20){
  $topn = (int) $_POST['topn'];
  $client = new SoapClient("http://footballpool.dataaccess.eu/data/info.wso?wsdl");
  $result = $client->TopGoalScorers(array('iTopN' => $topn));
  // Note that $array contains the result of the traversed object structure
  $array = $result->TopGoalScorersResult->tTopGoalScorer;
 
  print "
    <table border='2'>
      <tr>
        <th>Rank</th>
        <th>Name</th>
        <th>Goals</th>
      </tr>
  ";
 
  foreach($array as $k=>$v){
    print "
      <tr>
        <td align='right'>" . ($k+1) . "</td>
          <td>" . $v->sName . "</td>
          <td align='right'>" . $v->iGoals . "</td>
        </tr>";
  }
 
  print "</table>";
}
else {
?>
 
  <form id="topscorers" action="1.php" method="post">
    How long should your topscorers list be? (Choose a digit between 1 and 20).
    <input id="topn" name="topn" size="2" type="text" value="10" />
    <input id="submit" name="submit" type="submit" value="submit" />
  </form>
 
<?php
}
?>
WordPressStumbleUponShare
Tags: , , ,
Category : PHP, SOAP, WSDL, XML | 2 Comments »

PHP jQuery Star Rating

I was looking to create PHP jQuery star rating and luckily came across this script. I have created a very easy steps below so that even a layman can make this work with basic PHP and jQuery knowledge.

1. Create table using following SQL Query

CREATE TABLE IF NOT EXISTS `ratings` 
(  `rating_id` INT(11) NOT NULL AUTO_INCREMENT,
   `rating_article_id` INT(11) NOT NULL,   
`rating_num` INT(11) NOT NULL,   
`rating_ip` VARCHAR(25) NOT NULL,   
`rating_date` DATE NOT NULL,   
PRIMARY KEY (`rating_id`)
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

2. Create following PHP functions

function selectRating($article_id){         
$ip = $_SERVER['REMOTE_ADDR'];         
$dublicate_val = $this->checkDublicateRating($article_id,$ip);         
$total_rating_star = 5;         
$rating_star =NULL;         
$sql = "SELECT SUM(rating_num)AS total_rate, 
COUNT(*) AS total_row          
FROM ratings WHERE         
rating_article_id = '$article_id'";         
$resRating = mysql_query($sql);         
$recRating = mysql_fetch_array($resRating);         
if($recRating['total_row']>0)         {        
 $average = floor($recRating['total_rate']/$recRating['total_row']);         
$rate_percentage =($recRating['total_rate']
/($recRating['total_row']*$total_rating_star))*100;         
} 
else         
{
$average =0;         
$rate_percentage=0;         
}         
//echo $average;         
for($i=1;$i<=$average;$i++)         {         
if($dublicate_val==0)             {             
$ratval = $i;             
$rating_star.="<a href="javascript:;">
<img src='images/star_on.gif' border="0"  
id="$ratval" class="rating" /></a>";            
}             
else             
{            
 $rating_star.="<img src='images/star_on.gif' border="0" />";             
}         
}         
for($i=$average+1;$i<=$total_rating_star;$i++)         {             
if($dublicate_val==0)             {             
$ratval = $i;            
$rating_star.="<a href="javascript:;">
<img src='images/star_off.gif' border="0"
id="$ratval" class="rating" /></a>";             
}             
else             
{             
$rating_star.="<img src='images/star_off.gif' border="0" />";             
}         
}         
$rating_star="
<div style="width:160px; border:1px solid #fff; 
margin:5px 10px 0 0;padding:5px; float:left">".$rating_star."</div>";         
$rating_star .="<div style="width:160px; 
border:1px solid #fff; margin:5px 10px 0 0;padding:8px; 
float:left">Percentage:- 
".number_format($rate_percentage, 2, '.', '')."%</div>";
$rating_star .= "<div style="width:152px; border:1px solid #fff;
 margin:5px 10px 0 0;padding:8px; float:left">
Total Rate:- ".$recRating['total_row']."</div>
<div style="clear:both;"></div>";        
 return $rating_star;             
}
 function checkDublicateRating($id,$ip) {          
$sql="SELECT  COUNT(*) AS total_row FROM ratings 
WHERE rating_article_id = '".$id."' 
AND 
rating_ip='".$ip."'";     
$resCheck = mysql_query ($sql);    
 $recCheck = mysql_fetch_array($resCheck);     
return $recCheck['total_row'];     
} 
function insertRating($rate_id,$article_id)     
{        
$ip = $_SERVER['REMOTE_ADDR'];         
if($this->checkDublicateRating($article_id,$ip)==0)         
{              
$sql="INSERT INTO ratings 
SET rating_article_id = '".$article_id."', 
rating_num='".$rate_id."', rating_ip='".$ip."', 
rating_date=CURDATE()";
mysql_query ($sql);         
}     
}
 /// EOF

3. Create select_rating.php file with following piece of code

<?php /* 
Author: Prakash Bhandari 
Email:info@youngminds.com.np 
Date: Nov 5 2011 */ include("databaseconnection.php"); 
if(isset($_GET['articleID']) && is_numeric($_GET['articleID'])) 
{ 
$articleID = intval($_GET['articleID']);
echo selectRating($articleID); 
} 
?>

4. Create insert_rating.php file with following piece of code

<?php /*  
Author: Prakash Bhandari 
Email:info@youngminds.com.np 
Date: Nov 5 2011 */ 
include("databaseconnection.php"); 
if(isset($_GET['articleID']) && is_numeric($_GET['articleID']) 
&& $_GET['rateID'] && is_numeric($_GET['rateID'])) 
{ 
$rate_id = intval($_GET['rateID']); 
$article_id =intval($_GET['articleID']); 
insertRating($rate_id,$article_id); 
} 
?>

5. Create main file where you want to load the rating lets say index.php you can use following fiece of code in this page

<html>
<head>
<title>Rating</title> 
<script language="javascript" type="text/javascript"> 
$('.rating').live("click",function() {          
var id = $(this).attr("id");     
$('#loaderImage').html('<img src="images/loader.gif">');    
 var jqxhr = $.get("insert_rating.php
?articleID=<?php echo $articleID?>&rateID="+id);     
jqxhr.complete(function(){$('#loaderImage').fadeOut('fast');});                     
jqxhr.complete(function()
{$('#rating_select_area').
load("select_rating.php?articleID=<?php echo $articleID?>")});     
});/// end of unction     
</script> 
</head> 
<body> 
<div id="loaderImage"></div>         
<div id="rating_select_area">         
<?php echo selectRating($articleID); ?>         
</div> 
</body> 
</html>
WordPressStumbleUponShare

Multi Column Drop Down Menu

I was trying to find some nice attractive multi column drop down menu and came across this script. I like the look and feel of this and hence am sharing here with you. Click here for LIVE DEMO of multi column drop down menu.

Description:
Mega Menus refer to drop down menus that contain multiple columns of links. This jQuery script lets you add a mega menu to any anchor link on your page, with each menu revealed using a sleek expanding animation. Customize the animation duration plus delay before menu disappears when the mouse rolls out of the anchor. Mega cool!

<strong>Step 1: Add the following code to the section of your page:</strong>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="jkmegamenu.js">
// <![CDATA[
   /************************************************ jQuery Mega Menu- by JavaScript Kit (www.javascriptkit.com)  * This notice must stay intact for usage  * Visit JavaScript Kit at http://www.javascriptkit.com/ for full source code ***********************************************/
// ]]>
</script>
<script type="text/javascript">
// <![CDATA[
      //jkmegamenu.definemenu("anchorid", "menuid", "mouseover|click") jkmegamenu.definemenu("megaanchor", "megamenu1", "mouseover")
// ]]>
</script>

It references two external files. Download them below (right click, and select “save as”):

Step 2: Add the below HTML code to your page. It includes one example anchor link plus the associated mega drop down menu:

<!--Mega Menu Anchor-->
<a href="http://www.javascriptkit.com" id="megaanchor">Tech Links</a>
 
 
 
<!--Mega Drop Down Menu HTML. Retain given CSS classes-->
<div id="megamenu1" class="megamenu">
 
<div class="column">
	<h3>Web Development</h3>
	<ul>
	<li><a href="http://www.javascriptkit.com">JavaScript Kit</a></li>
	<li><a href="http://www.dynamicdrive.com/">Dynamic Drive</a></li>
	<li><a href="http://www.cssdrive.com">CSS Drive</a></li>
	<li><a href="http://www.codingforums.com">Coding Forums</a></li>
	<li><a href="http://www.javascriptkit.com/domref/">DOM Reference</a></li>
	</ul>
</div>
 
<div class="column">
	<h3>News Related</h3>
	<ul>
	<li><a href="http://www.cnn.com/">CNN</a></li>
	<li><a href="http://www.msnbc.com">MSNBC</a></li>
	<li><a href="http://www.google.com">Google</a></li>
	<li><a href="http://news.bbc.co.uk">BBC News</a></li>
	</ul>
</div>
 
<div class="column">
	<h3>Technology</h3>
	<ul>
	<li><a href="http://www.news.com/">News.com</a></li>
	<li><a href="http://www.slashdot.com">SlashDot</a></li>
	<li><a href="http://www.digg.com">Digg</a></li>
	<li><a href="http://www.techcrunch.com">Tech Crunch</a></li>
	</ul>
</div>
 
<br style="clear: left" /> <!--Break after 3rd column. Move this if desired-->
 
<div class="column">
	<h3>Web Development</h3>
	<ul>
	<li><a href="http://www.javascriptkit.com">JavaScript Kit</a></li>
	<li><a href="http://www.dynamicdrive.com/">Dynamic Drive</a></li>
	<li><a href="http://www.cssdrive.com">CSS Drive</a></li>
	<li><a href="http://www.codingforums.com">Coding Forums</a></li>
	<li><a href="http://www.javascriptkit.com/domref/">DOM Reference</a></li>
	</ul>
</div>
 
<div class="column">
	<h3>News Related</h3>
	<ul>
	<li><a href="http://www.cnn.com/">CNN</a></li>
	<li><a href="http://www.msnbc.com">MSNBC</a></li>
	<li><a href="http://www.google.com">Google</a></li>
	<li><a href="http://news.bbc.co.uk">BBC News</a></li>
	</ul>
</div>
 
<div class="column">
	<h3>Technology</h3>
	<ul>
	<li><a href="http://www.news.com/">News.com</a></li>
	<li><a href="http://www.slashdot.com">SlashDot</a></li>
	<li><a href="http://www.digg.com">Digg</a></li>
	<li><a href="http://www.techcrunch.com">Tech Crunch</a></li>
	</ul>
</div>
 
</div>

Configuration info

Each Mega Menu consists of an HTML anchor link, plus its associated drop down menu. The anchor link should just be any arbitrary link with a unique ID attribute:

<!--Mega Menu Anchor-->
<a href="http://www.javascriptkit.com" id="megaanchor">Tech Sites</a>

The associated drop down menu on the other hand should be a DIV containing a series of ULs in the format shown in the code of Step 2. It should also carry a unique ID:

<!--Mega Drop Down Menu HTML. Retain given CSS classes-->
<div id="megamenu1" class="megamenu">
Mega Menu HTML here...
</div>

With both of the above components defined on your page, in the HEAD section of your page, initialize this menu by calling:

<script type="text/javascript">
//jkmegamenu.definemenu("anchorid", "menuid", "mouseover|click")
jkmegamenu.definemenu("megaanchor", "megamenu1", "mouseover")
 
</script>

Where the first two parameters are the IDs of the anchor and associated drop down menu, and the 3rd, a string of either “mouseover” or “click”. This last parameter lets you specify which of these two actions the menu should be activated on the anchor link. Finally, yes, you can have multiple mega menus on your page. Just repeat the steps above and call jkmegamenu.definemenu() for each menu. Enjoy!

p.s: Inside the .js file, there are two variables you may wish to fine tune:

effectduration: 300, //duration of animation, in milliseconds
delaytimer: 200, //delay after mouseout before menu should be hidden, in milliseconds
WordPressStumbleUponShare

Facebook Invite Friends Button

Facebook is rolling out some major changes to how Pages work. Some are good, some not. The good changes include the new layout of facebook Pages with the tabs on the left sidebar instead of at the top, and, starting March 11, 2011, the ability to use iframes, HTML, Javascript and CSS without the FBML App! This is going to totally change how you can develop facebook Pages! Party time!

One of the recent changes in the “not so great” category is facebook’s decision to remove the “Suggest to Friends” link on facebook Pages. Admins of a page can still access this feature in the Edit Page area, but fans cannot. So, we’ve been flooded with requests to add an Invite Friends Tab to facebook Pages.  Here are the steps for how to create the Invite Friends Tab on a facebook Page, but keep in mind that as of March 11, 2011, facebook will be deprecating the FBML App.

  1. Go to  Static FBML App and click on Add to Page in the top left corner of the page. You will then see a list of your facebook pages. Click “Add to Page” to add the application.
  2. FBML is now added to your page.
  3. Go to the facebook Page you’re working on and click Edit Page.
  4. Click on Apps.
  5. Click on the FBML Apps and click on Go to App.
  6. Give the Tab a title like “Suggest to Friends.”
  7. Copy and Paste the below code replacing illuminea with your organization.
    Important! The action URL on line 3 of the code MUST be http://example.com and NOT http://www.example.com. No WWW welcome at this party.

    If you don’t follow these rules, you will get an error that says “Sorry, your request could not be processed. Please try again.”
<fb:request-form
method="post"
action="http://facebook.com/illuminea"
type="illuminea"
invite="true"
content="Connect with iluminea
<fb:req-choice url=http://www.facebook.com/illuminea label='Go' /> ">
<fb:multi-friend-selector actiontext="Invite your friends to connect with illuminea" rows="3" cols="3" showborder="true" />
</fb:request-form>
WordPressStumbleUponShare
Tags: ,
Category : Facebook | No Comments »
© 2003-2012 Copyright , Young Minds, Kathmandu, Nepal. All rights reserved.