Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing PHP table to JavaScript

Status
Not open for further replies.

JustinC474

Programmer
Jul 27, 2009
1
US
I am currently in an internship where my main goal is to construct a database that can be run client-side (in JS). I have it done it PHP and am having a very hard time switching it to javascript.

Rows = all info on one client
Columns = Specific information (name, date, etc)

Up until last monday i had never programmed PHP HTML or JavaScript so any help at all would be greatly appreciated.

This is the PHP function that creates a table (and works well)
($data = 2D array of client information; $numRows = number of rows; $columns = array of column headers)

Code:
     function printJSTable()
      {
        echo '<script language="Javascript" src = "java_script.js"></script>';
        echo '<table id = "myTable" class = "halloween" border = "1">';
        echo '<tr>';
        foreach($this->columns as $header => $order)
        {
                echo '<th>';
                echo $header;
                echo '</th>';
        }
        echo '</tr>';
        $counter = 0;
        for($i = 0; $i < $this->numRows; $i++)
        {
                echo '<tr >';
                foreach($this->data[$i] as $key => $value)
                {
                        echo '<td id ="'.$counter.'" onmouseover = "ParaOver(this)" onmouseout = "ParaOut(this)" onclick = "changeInfo(id)">';
                        if($value!="")
                                echo $value;
                        else
                        {
                                echo '<input type = "button" value = "Empty" size = 10>';
                        }
                        $counter++;
                        echo '</td>';

                }
                echo '</tr>';
        }
        echo '</table>';
      }

any help at all would be great!! thanks!
 
What do you mean when you say 'can be run client-side (in JS)'?

If you mean you want to be able to update the DB using only client-side code then I think you'll be sorely disappointed, as you'd ultimately still need server-side code unless you go with some sort of IE-only Active-X control.

Dan


Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top