Hello,
Going to try to explain this as best I can. I have a bunch of stuff in a database and I need to display this info within a table. This isn't a problem at all but, I need it to only display 3 td tags per line and then move on to the row.

so i need it to do :

code:

<table>
<tr>
<td>My First Row</td>
<td>My First Row 2</td>
<td>My First Row 3</td>
</tr>

<tr>
<td>My Second Row</td>
<td>My Second Row 2</td>
<td>My Second Row 3</td>
</tr>
</table>



and continue to do this through every entry in the database table.

so I have something like this that will display the info:

code:

for ($i = 1; $i <= $num; $i++){
   
        $chairArray = mysql_fetch_array($chairResult);
        $chairName = $chairArray['name'];
        $chairDescription = $chairArray['description'];
        $chairImage = $chairArray['image'];
       
        echo "<tr>";
        echo "<td>";
        echo "<img src=\"images/catalog/ottomans/thumbs/$chairImage\" width=\"157\" height=\"147\" />";
        echo "<br />";
        echo $chairName;
        echo "</td>";
        echo "</tr>";
       
       
    }

2

(0 replies, posted in Programming)

Hey there,

I have a class A that uses class B. Class B also uses class A. This is recursive and am wondering if you can redefine PHP classes like in C++.

class A{}

class B{
    private $classA;

    public function __construct($classA){
       $this->classA = $classA;
    }

    public function someFunc(){ echo 'blah'; }
}

class A{
    private $classB;

    public function __construct($classB){
        $classB->someFunc();
    }
}

3

(6 replies, posted in Programming)

Hi,
These are working for me, feel free to use them at your own risk

class MSSoapClient extends SoapClient {
    private $namespace;
    function __doRequest($request, $location, $action, $version) {
       

        $request = preg_replace('/<ns1:(\w+)/', '<$1 xmlns="'.$this->namespace.'"', $request, 1);
        $request = preg_replace('/<ns1:(\w+)/', '<$1', $request);
        $request = str_replace(array('/ns1:', 'xmlns:ns1="'.$this->namespace.'"'), array('/', ''), $request);
       
        // parent call
        return parent::__doRequest($request, $location, $action, $version);
    }
    function setNamespace($sNamespace)
    {
        $this->namespace=$sNamespace;
    }
   

To make a new customer - I'm only you can extend the function to add other details to the record.

function newKashflowCustomer($soapClient,$idAccount,$name,$address,$town,$postcode,$country,$email)
{
    //returns customer id if ok else 0
   
    $today = date("Y-m-d",mktime());
   
    $customerArray = array(
        "CustomerID"=>"",
        "Code"=>"",
        "Name"=>"$name",
        "Contact"=>"",
        "Telephone"=>"",
        "Mobile"=>"",
        "Fax"=>"",
        "Email"=>"$email",
        "Address1"=>"$address",
        "Address2"=>"",
        "Address3"=>"$town",
        "Address4"=>"$country",
        "Postcode"=>"$postcode",
        "Website"=>"",
        "EC"=>"0",
        "Notes"=>"",
        "Source"=>"",
        "Discount"=>"0",
        "ShowDiscount"=>"0",
        "PaymentTerms"=>"0",
        "ExtraText1"=>"1",
        "ExtraText2"=>"1",
        "CheckBox1"=>"1",
        "CheckBox2"=>"1",
        "Created"=>"$today",
        "Updated"=>"$today");
   
    $args = array ("UserName"=>"your username here", "Password"=>"your password here","custr"=>$customerArray);
    $oResponse = $soapClient->InsertCustomer($args);
    //handle any errors
    if($oResponse->Status != "OK")
    {
        echo $oResponse->StatusDetail;
        $return = 0;

    }
    else
    {
        $id = $oResponse->InsertCustomerResult;
       
        $return = $id;
       
    }
    return $return;
}

4

(2 replies, posted in General discussion)

Hello,
I have a problem with Javascript dropdown menus.
There is a flash animation just below my javascript menu. When i hover on the javascript menu the dorpdown goes behind the flash animation. Is there any solution to rectify this problem?

Hi,

I  having trouble with a piece of code that is throwing an Invalid Argument error in IE only.

Code:
setTimeout('callGA(\'' +url +'\')', 1000);


The method is declared as follows.
Code:
function callGA(GAurl) { do something }


Through alerts and other debugging the invalid argument is the "callGA(url)" argument that is being passed into setTimeout(). I am sure I am just doing something silly but any help would be really appreciated.

6

(2 replies, posted in Programming)

Hi,
In the code below, I understand the $place variable and how it's working. What I can't understand is how I'M getting the output "he played 1, 2, etc... How is that function and the $stanza variable returning a single digit number? Thanks
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Param Old Man</title>
</head>

<body>

<h1>Param Old Man</h1>
<h3>Demonstrates use of function parameters</h3>
<?php

print verse(1);
print chorus();
print verse(2);
print chorus();
print verse(3);
print chorus();
print verse(4);
print chorus();

function verse($stanza)
{
    switch($stanza)
    {
        case 1:
            $place = "thumb";
            break;
        case 2:
            $place = "shoe";
            break;
        case 3:
            $place = "knee";
            break;
        case 4:
            $place = "door";
            break;
        default:
            $place = "I don't know where";
    } //end switch

    $output = <<<HERE
    This old man, he played $stanza<br>
    He played knick-knack on my $place<br><br>
HERE;
    return $output;
} //end veruse

function chorus()
{
    $output = <<<HERE
    ...with a knick-knack<br>
    paddy-wack<br>
    give a dog a bone<br>
    this old man came rolling home<br>
    <br><br>
HERE;
    return $output;
}// end chorus

?>
</body>
</html>

7

(0 replies, posted in Programming)

Hi,
I'm using krsort, ksort, arsort and asort in a script. Fine all goes perfectly, except that the sort field is based on file names from the directory contents, and they are (historically) ugly, as in MMDDYY, not YYYYMMDD, causing the different years to be interspersed together.
if($_GET['sort'] == 'alpha'){
    if($_GET['mode'] == 'desc'){
        krsort($files);
        $highlight = 'alpha_desc';
    } else {
        ksort($files);
        $highlight = 'alpha_asc';
    }
} else {
    if($_GET['mode'] == 'asc'){
        asort($files, SORT_NUMERIC);
        $highlight = 'date_asc';
    } else {
        arsort($files, SORT_NUMERIC);
        $highlight = 'date_desc';
    }
}

8

(1 replies, posted in Programming)

Hi,
Database indexes help to speed the retrieval of data from MySQL database server faster. When retrieving the data, MySQL first check whether the indexes exists; If yes it will use index to select exact physical corresponding rows without scanning the whole table.

In general, it is suggested that you should put indexes on columns you usually use in retrieval such as primary key columns and columns used in join and sorts. Why not index every column? The most significant is that building and maintaining an indexes tables take time and storage space on database.

Usually you create indexes when creating tables. Any column in creating table statement declared as PRIMARY KEY, KEY, UNIQUE or INDEX will be indexed by MySQL. In addition, you can add indexes to the tables which has data. The statement to create index in MySQL as follows:

CREATE [UNIQUE|FULLTEXT|SPATIAL] INDEX index_name
USING [BTREE | HASH | RTREE]
ON table_name (column_name [(length)] [ASC | DESC],...)

First you specify the index based on the table types or storage engine:

    * UNIQUE means MySQL will create a constraint that all values in the index must be distinct. Duplicated NULL is allowed in all storage engine except BDB.
    * FULLTEXT index is supported only by MyISAM storage engine and only accepted columns which have data type is CHAR,VARCHAR or TEXT.
    * SPATIAL index supports spatial column and available in MyISAM storage engine. In addition, the column value must not be NULL.

Then you name the index using index types such as BTREE, HASH or RTREE also based on storage engine. Here are the list:
Storage Engine     Allowable Index Types
MyISAM     BTREE, RTREE
InnoDB     BTREE
MEMORY/HEAP     HASH, BTREE
NDB     HASH


Finally you declare which column on which table using the index.

In our sample database you can add index to officeCode column on employees table to make the join operation with office table faster as follows:

CREATE INDEX officeCode ON employees(officeCode)