Results 1 to 8 of 8

Thread: Not sure if possible! What language?

  1. #1
    Join Date
    Sep 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Not sure if possible! What language?

    Hello everyone,

    I am new here, hopefully someone can help me get started.

    I have a webpage using php and mysql consisting of 100 table cells (ten rows across and ten rows down) which is an php include file. The content for each cell is pulled out of the mysql database. Each cell is unique to a individual record in the database by ID. Another page on this same website is used to select the content to place in each cell, normally firstname, lastname. One field in the database is called responsible member this can change on each cell.

    One this same page I have another php include file designed to count the number of responsible members within the 100 cells and display the firstname, lastname on the side of the 100 table cells.

    What I would like to do is when you scroll over the username on the right, I would like to highlight the boxes on the left associated with that responsible member. Is this possible? I am sure that it is but don't know how to go about it. Any suggestions would be greatly appreciated.

  2. #2
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,891
    Thanks
    2
    Thanked 441 Times in 435 Posts

    Default

    best to post a link to your page so as to see how the data is rendered by the browser, ie using tables etc?
    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

  3. #3
    Join Date
    Sep 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    take a look at this.

    http://www.ndanet.com/project2/100_tables.php

    when scrolling over the name on the right I would like it to highlight the cells on the left associated with that name.

  4. #4
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,891
    Thanks
    2
    Thanked 441 Times in 435 Posts

    Default

    Code:
    <!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" xml:lang="en" lang="en">
    
    <head>
      <title></title>
    <script type="text/javascript">
    /*<![CDATA[*/
    
    function HighLight(cls,txt){
     var cells=zxcByClassName(cls)
     for (var td,z0=0;z0<cells.length;z0++){
      td=cells[z0];
      while (td.parentNode&&td.nodeName.toUpperCase()!='TD'){
       td=td.parentNode;
      }
      if (td.nodeName.toUpperCase()=='TD'){
       td.style.backgroundColor=cells[z0].innerHTML!=txt?'red':'blue';
      }
     }
    }
    
    function zxcByClassName(nme,el,tag){
     if (typeof(el)=='string') el=document.getElementById(el);
     el=el||document;
     for (var tag=tag||'*',reg=new RegExp('\\b'+nme+'\\b'),els=el.getElementsByTagName(tag),ary=[],z0=0; z0<els.length;z0++){
      if(reg.test(els[z0].className)) ary.push(els[z0]);
     }
     return ary;
    }
    
    
    /*]]>*/
    </script>
    
    </head>
    
    <body>
    <table border="1">
      <tr>
        <td><span class="name" >Name 1</span></td>
        <td><span class="name" >Name 2</span></td>
        <td><span class="name" >Name 3</span></td>
        <td><span class="name" >Name 4</span></td>
      </tr>
      <tr>
        <td><span class="name" >Name 1</span></td>
        <td><span class="name" >Name 2</span></td>
        <td><span class="name" >Name 3</span></td>
        <td><span class="name" >Name 4</span></td>
      </tr>
      <tr>
        <td><span class="name" >Name 1</span></td>
        <td><span class="name" >Name 2</span></td>
        <td><span class="name" >Name 3</span></td>
        <td><span class="name" >Name 4</span></td>
      </tr>
      <tr>
        <td><span class="name" >Name 1</span></td>
        <td><span class="name" >Name 2</span></td>
        <td><span class="name" >Name 3</span></td>
        <td><span class="name" >Name 4</span></td>
      </tr>
    </table>
    <table border="1" onmouseout="HighLight('name','???');">
      <tr>
    <td class="mse" onmouseover="HighLight('name','Name 1');" >Name 1</td>
      </tr>
      <tr>
    <td class="mse" onmouseover="HighLight('name','Name 2');" >Name 2</td>
      </tr>
      <tr>
    <td class="mse" onmouseover="HighLight('name','Name 3');" >Name 2</td>
      </tr>
      <tr>
    <td class="mse" onmouseover="HighLight('name','Name 4');" >Name 4</td>
      </tr>
    </table>
    
    </body>
    
    </html>
    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

  5. #5
    Join Date
    Sep 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Vic,

    That is exactly what I would like to do. I am running into a problem with including that into my php & mysql code.

    where do I stick the following code?

    class="mse" onMouseOver="HighLight('name','Name 1');"

    'Name 1' would be generated on the fly using php & mysql as shown below:

    <?php
    $count = 0;
    $db = mysql_pconnect("", "", "");
    mysql_select_db("",$db);
    $result2 = mysql_query ("SELECT DISTINCT responsible_member FROM 100_cells");
    if ($myrow2 = mysql_fetch_array($result2)) {
    do {
    if ($count == 0) {
    print ("<body bgcolor=\"#FFFFFF\" text=\"#000000\"><div align=\"center\"><table width=\"300\" border=\"0\" bgcolor =\"E9E9E9\" cellspacing=\"0\" cellpadding=\"0\" bordercolor=\"#FFFFFF\">
    <tr>");
    printf ("<td width = \"300\"><font face=\"verdana\" size=\"1\" color=\"666666\">%s</font></td>",$myrow2["responsible_member"]);
    print ("</tr>
    </table>
    </div>");
    $count = 1;
    } else {
    print ("<body bgcolor=\"#FFFFFF\" text=\"#000000\"><div align=\"center\"><table width=\"300\" border=\"0\" bgcolor =\"E9E9E9\" cellspacing=\"0\" cellpadding=\"0\" bordercolor=\"#FFFFFF\">
    <tr>");
    printf ("<td width = \"300\"><font face=\"verdana\" size=\"1\" color=\"666666\">%s</font></td>",$myrow2["responsible_member"]);
    print ("</tr>
    </table>
    </div>");

    $count = 0;
    }}while ($myrow2 = mysql_fetch_array($result2));
    }?>

    --------------

  6. #6
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,891
    Thanks
    2
    Thanked 441 Times in 435 Posts

    Default

    PHP Code:
    printf ("<td width = \"300\"><font face=\"verdana\" size=\"1\" color=\"666666\">%s</font></td><span class=\"mse\" onmouseover=\"HighLight('name','",$myrow2["responsible_member"],"');\">",$myrow2["responsible_member"],"</span>"); 
    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

  7. #7
    Join Date
    Sep 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Vic,

    I am having a little problem with getting the code to work for me. I just noticed that what I am displaying on the right is not the same cell properties as listed on the left. On the left (100 table cells), I post three different cell properties one on top of another along with one line of just basic text. The first line is normal text "square #". Next line is pulled from the database "firstname", which is associated with square #. Next line is also pulled from the database "lastname", which is also associated with the square #. The last line is an if then statement which is also pulling content from the mysql database associate with square #.

    Now on the right I pull distinct members located in the same database however in a cell called "responsible_member". Here is a piece of code to see what I am talking about.

    Also, I want you to know that I used php include files to pull all this information into the index.
    ----------

    index.php (located on the left side - this is only a small piece of the code)

    <?php
    $count = 0;
    $db = mysql_pconnect("", "", "");
    mysql_select_db("",$db);
    $result1 = mysql_query("SELECT * FROM 100_cells where id=1",$db);
    $myrow1 = mysql_fetch_array($result1);
    printf ("<font face=\"arial\" size=\"1\" color=\"cccccc\">square #%s<br></font>",$myrow1["id"]);
    printf ("<font face=\"verdana\" size=\"1\" color=\"666666\">%s<br></font>",$myrow1["firstname"]);
    printf ("<font face=\"verdana\" size=\"1\" color=\"666666\">%s<br></font>",$myrow1["lastname"]);
    if ( $myrow1["status"] == "NULL" ) {
    echo ('<a href="complete_100_cells_1.php?id=1"><font face="Arial, Helvetica, sans-serif" size="2" color=FF0000>FILL IN</font></a>');
    } elseif ( $myrow1["status"] == "yes" ){
    echo ('<font face="Georgia, Times New Roman, Times, serif" size="2" color=FF0000>YES</font>');
    } else {
    echo "AVAILABLE";
    }
    ?>


    -----------

    members.php (located on the right side - this is only a small piece of the code)

    <?php
    $count = 0;
    $db = mysql_pconnect("", "", "");
    mysql_select_db("",$db);
    $result2 = mysql_query ("SELECT DISTINCT responsible_member FROM 100_cells WHERE responsible_member NOT LIKE 'Admin' ORDER BY timesent");
    if ($myrow2 = mysql_fetch_array($result2)) {
    do {
    if ($count == 0) {
    print ("<body bgcolor=\"#FFFFFF\" text=\"#000000\"><div align=\"center\"><table width=\"300\" border=\"0\" bgcolor =\"E9E9E9\" cellspacing=\"0\" cellpadding=\"0\" bordercolor=\"#FFFFFF\">
    <tr>");
    printf ("<td width = \"300\"><font face=\"verdana\" size=\"1\" color=\"666666\">%s</font></td>",$myrow2["responsible_member"]);
    print ("</tr>
    </table>
    </div>");
    $count = 1;
    } else {
    print ("<body bgcolor=\"#FFFFFF\" text=\"#000000\"><div align=\"center\"><table width=\"300\" border=\"0\" bgcolor =\"E9E9E9\" cellspacing=\"0\" cellpadding=\"0\" bordercolor=\"#FFFFFF\">
    <tr>");
    printf ("<td width = \"300\"><font face=\"verdana\" size=\"1\" color=\"666666\">%s</font></td>",$myrow2["responsible_member"]);
    print ("</tr>
    </table>
    </div>");
    $count = 0;
    }}while ($myrow2 = mysql_fetch_array($result2));
    }?>

    --------
    mysql database

    id (1 - 100)
    timesent (time stamp when data entered)
    firstname (determined by member)
    lastname (determined by member)
    status
    responsible_members (consist of firstname and lastname from another database - hardly ever the same as firstname and lastname of this database)

    ----------

    any suggestions will be appreciate

  8. #8
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,891
    Thanks
    2
    Thanked 441 Times in 435 Posts

    Default

    questions on PHP and mysql are best posted in the relavent forums
    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •