Forum Moderators: open

Message Too Old, No Replies

Need to click table cell and extract additional data.

Perhaps use AJAX?

         

shruti

8:33 pm on Jul 25, 2008 (gmt 0)

10+ Year Member



My boss is making me cry by asking me to do things that Google Gmail and Yahoo mail has done. :(
:(

"The bigger part is the one that I want to work with"

What I want to do is that :

if I click on any of the Cellid(from table "traff" that is displayed), it will get that Cellid Value and then match it with tablename " comments" and then on click will pop up a balloon with all the values from table "comments" where date =Currdate

Below is all that you will need:
==========================================================

My data base table "comments" is

CELLID , problem ,solution , comments ,userid , date .
===========================================================

My data base table traff is

BSCID, Cellid , Seiz , Drps ,dropflag ,RF, Oth ,Traff, trafflag , Total , DIT , IHFL ,ihfflag , TCD , TCA ,SDD , SDA ,TAVL ,tchaflag , Drate ,date .
===========================================================

This is the page that displays the whole table:

<?php
$host = "localhost";
$user = "shruti";
$pass = "patel";
$dbname = "tmetrix";

$connection = mysql_connect("localhost", "root", "") or die("Cannot connect to MySQL server: " . mysql_error());
$db_selected = mysql_select_db('tmetrix', $connection);

$dt= DATE('Y-m-d');
$data = mysql_query("SELECT * FROM traff where date = '$dt'")
or die(mysql_error());
Print "<table border=0 cellspacing=0 cellpadding=0 style='width:100%'>";


$info= mysql_query($query);
$num_data = mysql_num_rows($data);

for($i=0; $i < $num_data; $i++) {

$row = mysql_fetch_array($data);

$rows[$i]['BSCID'] = "<td style='text-align:left'>" . $row['BSCID'] . "</td>";

$rows[$i]['Cellid'] = "<td style='text-align:left'>" . $row['Cellid'] . "</td>";

$rows[$i]['Seiz'] = "<td>" . $row['Seiz'] . "</td>";
$rows[$i]['Drps'] = "<td>" . $row['Drps'] . "</td>";
$rows[$i]['RF'] = "<td>" . $row['RF'] . "</td>";
$rows[$i]['Oth'] = "<td>" . $row['Oth'] . "</td>";
$rows[$i]['Traff'] = "<td>" . $row['Traff'] . "</td>";
$rows[$i]['Total'] = "<td>"."(" . $row['Total'] .")". "</td>";

$rows[$i]['DIT'] = "<td>" . $row['DIT'] . "</td>";

$rows[$i]['IHFL'] = "<td>" . $row['IHFL'] . "</td>";
$rows[$i]['TCD'] = "<td>" . $row['TCD'] . "</td>";
$rows[$i]['TCA'] = "<td>" . $row['TCA'] . "</td>";
$rows[$i]['SDD'] = "<td>" . $row['SDD'] . "</td>";
$rows[$i]['SDA'] = "<td>" . $row['SDA'] . "</td>";
$rows[$i]['TAVL'] = "<td>" . $row['TAVL'] ."%". "</td>";
$rows[$i]['Drate'] = "<td>" . $row['Drate'] . "</td>";

if($row['dropflag'])
$rows[$i]['Drps'] = str_replace('<td>','<td style="font-weight:bold;color:#CC0066">',$rows[$i]['Drps']);

if($row['trafflag'])
$rows[$i]['Traff'] = str_replace('<td>','<td style="font-weight:bold;color: #CC0066">',$rows[$i]['Traff']);

if($row['ihfflag'])
$rows[$i]['IHFL'] = str_replace('<td>','<td style="font-weight:bold;color:#CC0066">',$rows[$i]['IHFL']);

if($row['tchaflag'])
$rows[$i]['TAVL'] = str_replace('<td>','<td style="font-weight:bold;color:#CC0066 ">',$rows[$i]['TAVL']);

}

for($i=0; $i < $num_data; $i++) {

if($i % 2)
{
print '<TR bgcolor="#ffffff">';
}
else
{
print '<TR bgcolor="#CCCCCC">';
}

foreach($rows[$i] as $cell)
echo $cell;
}

print "</TR>\n";

?>

[edited by: DrDoc at 12:41 am (utc) on July 26, 2008]

DrDoc

12:57 am on Jul 26, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Your bolded line:
$rows[$i]['Cellid'] = "<td style='text-align:left'>" . $row['Cellid'] . "</td>";

If you modify it slightly:

$rows[$i]['Cellid'] = "<td style='text-align:left' [b]onclick='getComments(" . $row['Cellid'] . ")'[/b]>" . $row['Cellid'] . "</td>";

Then you will need to create the

getComments
function, which should initiate an AJAX call to the server in order to retrieve the data. Set up another PHP script which is dedicated to extracting the comments.

Do you have any AJAX experience?

shruti

12:48 pm on Jul 28, 2008 (gmt 0)

10+ Year Member



No, Sorry I have no experience with AJAX.....I am even new to PHP. I am learning everyday new things to make my project work. But sometimes I need help from experienced programmers and webmasters like you all.

Please help me with the getComments (AJAX) too.

Thanks in Advance.

shruti

3:52 pm on Jul 29, 2008 (gmt 0)

10+ Year Member



No one is helping me! :(

I tried, but its not working