Monthly Archives: September 2008

CMS:
http://drupal.org/
http://www.joomla.org/

Project Task Mgmt:
http://www.dotproject.net/

Books:
http://www.packtpub.com/

Hosting:
http://godaddy.com

Stock Photos:
http://us.fotolia.com/godaddy

e-commerce:
http://www.oscommerce.com/

on-line forum:
http://www.simplemachines.org/

blog:
http://wordpress.org/

Step 1: Make the UL LI list:

<ul id="sortme">
 <li id="27" class="sortitem">蒼龍</li>
 <li id="44" class="sortitem">朱雀</li>
 <li id="136" class="sortitem">玄武</li>
 <li id="19" class="sortitem">白虎</li>
</ul>

Step 2: Make the List Sortable

$(document).ready(function() {
	  $("#sortme").sortable({});
});

Step 3: Capture Mouse Up Event

$("#sortme").bind("mouseup", function(){
	alert('Mouseup Event');
});

Step 4: Get the Serial Data

$("ul li").each(function(i){
	data[i] = $(this).text() ;
});

But problem for this one is you get one more item: total member in data array is R+1

IN Step 4: Can also use the built in function:

strdata = $(this).sortable("serialize");

But here the ID of the UL list must be in form of xxx_1, xxx_2… etc. And also PROBLEM is in the mouseup event handler, the strdata only captures R-1 data !!! WHY WHY WHY

Iterates over the images inside the div and scales its id:

 $("div img").each(function(i){
   this.id = this.id + "_" + i;
 });

Before

 <div><img id='me'/><img id='me'/></div><img id='me' />

After:

 <div><img id='me_0'/><img id='me_1'/></div><img id='me' />

To incorporate an image slideshow:

Step 1: include jquery and innerfade files

<script type="text/javascript" src="jquery-1.2.6.min.js"></script>
<script type="text/javascript" src="jquery.innerfade.js"></script>

Step 2: include this jquery script in the header

<script type="text/javascript">
$(document).ready(
  function(){
  $('ul#portfolio').innerfade({
  speed: 1000,
  timeout: 5000,
  type: 'random',
  containerheight: '220px'
  });
});
</script>

Step 3: the actual list of images

<ul id="portfolio">
<li>
<a href="http://..."><img src="xxx.jpg" alt="Good Guy bad Guy" /></a>
</li>
<li>
<a href="http://.../xxx.html"><img src="images/www.gif" alt="Whizzkids" /></a>
</li>
...
</ul>

can’t solve it working !!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Using static variables

Another important feature of variable scoping is the static variable. A static variable exists only in a local function scope, but it does not lose its value when program execution leaves this scope.

<?php
function Test()
{
    static $a = 0;
    echo $a;
    $a++;
}
?>
	$GLOBALS['choice'] = array(0 => $opt1[0], 1 => $opt2[0], 2 => $opt3[0], 3 => $ans[0]);
	$GLOBALS['num'] = range(0,3);
	srand((float)microtime() * 1000000);
	shuffle($GLOBALS['num']);

	echo "<p style='color:rgb(1,255,1);'>以下那一個是錯別字:</p>";
	for ($i = 0; $i <= 3; $i++) {
		echo $i+1 . ": " . $GLOBALS['choice'][$GLOBALS['num'][$i]] . "  ";

		// to capture the answer number (for MC of four options)
		if ($GLOBALS['num'][$i] == 3) $GLOBALS['ansnum'] = $i;
	}

<?php
$a = 1; /* global scope */ 

function Test()
{
    echo $a; /* reference to local scope variable */
} 

Test();
?>

This script will not produce any output because the echo statement refers to a local version of the $a variable, and it has not been assigned a value within this scope. You may notice that this is a little bit different from the C language in that global variables in C are automatically available to functions unless specifically overridden by a local definition. This can cause some problems in that people may inadvertently change a global variable. In PHP global variables must be declared global inside a function if they are going to be used in that function.

A little technical problem:
PHP part:

<select id="mc">
  <option value="1"><?php echo $choice[0];?></option>
  <option value="2"><?php echo $choice[1];?></option>
  <option value="3"><?php echo $choice[2];?></option>
  <option value="4"><?php echo $choice[3];?></option>
</select>

<input type="button" id="answer_btn" style="float: left;" value="選擇答案" onclick="answerbox(<?php echo $ans[0];?>)"/>

jScript part:

function answerbox(a) {

obja = document.getElementById("mc");
if (a == obja.value)
	alert ("correct !");
else
	alert ("wrong !");

}

CAN’T GET IT OUT !!!!!!!!!!!!!!!!!!!!!

$query = "SELECT cword FROM ww_tbl ORDER by rand() LIMIT 1";
$result = mysql_query($query);
$opt1 = mysql_fetch_row($result);
$query = "SELECT cword FROM ww_tbl ORDER by rand() LIMIT 1";
$result = mysql_query($query);
$opt2 = mysql_fetch_row($result);
$query = "SELECT cword FROM ww_tbl ORDER by rand() LIMIT 1";
$result = mysql_query($query);
$opt3 = mysql_fetch_row($result);
$query = "SELECT wword FROM ww_tbl ORDER by rand() LIMIT 1";
$result = mysql_query($query);
$ans = mysql_fetch_row($result);

$choice = array(0 => $opt1[0], 1 => $opt2[0], 2 => $opt3[0], 3 => $ans[0]);
$num = range(0,3);
srand((float)microtime() * 1000000);
shuffle($num);

echo "<p style='color:rgb(1,255,1);'>以下那一個是錯別字:</p>";
foreach ($num as $n) {
    echo $choice[$n] . "  ";
}