Page 1 of 1

need help with displaying of second row with onClick for all

Posted: Thu Jun 14, 2007 10:11 am
by bruceg
Hello,

I believe my issue here lies within the PHP/MySQL and not the JS. What I need is on this page http://www.carrentalsupport.com/bruce/Query.php#

if you click the more info link in the first row, a second row displays with more info...this is what I want, but it only works for the first row, and I need it to work for all entries.

here is my PHP/MySQL code

Code: Select all

<?php
$connection = mysql_connect("localhost","username","password"); 

mysql_select_db ('dbname'); 



$sql = "SELECT f2,f3,phone,f8,f9,f10,f11,f12,f13,f15 FROM station ORDER BY f11 ASC" ;

$sql_resulta = mysql_query($sql,$connection)  or die('Query failed: ' . mysql_error());
 
//result set
$rs = mysql_query($sql);
$img= "<img src='icons/apo.gif' width='15' height='17' alt='airportindicator'>";
//creating the table w/ headers
     
     echo "<table id='display' cellpadding='0' cellspacing='0' align='center'><tr><td class='header'>Airport Indicator</td><td class='header'>State</td><td class='header'>Airport Code</td><td class='header'>Airport Name</td><td class='header' colspan='2'>&nbsp;</td></tr>";

    
 
    //row for each record
     while ($row = mysql_fetch_array($rs))
     
      {                 
                 echo"<tr id='trX'><td>
    $img
</td><td> $row[6] </td><td> $row[0]</td><td> $row[1] </td><td id='header'><a href='#' onClick='FuncShowHide()'> More Info.</a></td><td id='header'><a class='WHATSTHIS' onclick='selectLoc([0])' href='javascript:;'>Select this Location</a></td></tr>";
                 echo"<tr id='hideShow' style='display:none'><td><strong>Address:</strong> $row[3] </td><td><strong>Address:</strong>$row[4] </td><td><strong>City:</strong> $row[5] </td><td> $row[6]</td><td>$row[7] </td><td><strong>Phone:</strong> $row[2] </td></tr>";     
     }  

     echo "</table>";
   

//close the db
mysql_close();

      echo  "</body>";
      echo  "</html>";
?>

any suggestions?...thanks!

Posted: Thu Jun 14, 2007 1:55 pm
by Begby
I looked at your page and it appears stuck in an infinite loop.

Also, your database has fields named f1, f2, f3, f4..... ?????? The first thing you should do is start over with a new database design.

Posted: Thu Jun 14, 2007 3:24 pm
by superdezign
My suggestion would be to do JavaScript in JavaScript. Placing JavaScript into PHP assumes that the usrs have JavaScript. I like to create all JavaScript-driven elements using JavaScripts, and leave their basic counterparts untouched for useres that have disabled JavaScript.

I'd set all of the onClick events through a JavaScript function.

Posted: Thu Jun 14, 2007 3:41 pm
by RobertGonzalez
It is all Javascript, not your PHP. This belongs in Client Side.

Basically what you want to do is present all the data and show/hide based on a click. The term is toggle and you want to look at ways to toggle the row class when a link is clicked. I think Google can help there.