Page 1 of 1

plz help ----php looping is nt working

Posted: Wed Oct 08, 2008 6:05 am
by panjad

Code: Select all

            <div class="latest_news">
                <h3>Latest @ TRI</h3>
<div> <!-- <marquee bgcolor="#FFFFFF" scrollamount="2" behavior="scroll" truespeed="truespeed" scrolldelay="100" direction="up" onmouseover="this.stop()" onmouseout="this.start()" loop="true"> --><left>
<?php
                    $result = $database->query("SELECT * FROM sw_latest ORDER BY weight");
                    while($row = mysql_fetch_array($result)){
                    echo "\n<p><img src=\"images/strelica2.gif\" width=\"6px\" height=\"5px\" alt=\"\" /> ".$row['content']."</p>";
                    }
                    ?>
 
 
        </left>
        <!--</marquee>-->
        </div>
 
    
    
 
</div>
 
 
 
 
 
            <div class="upcoming_workshops">
            <h3>Upcoming Workshops</h3>
 
 
 
<?php
    echo "<script type=\"text/javascript\" src=\"collapsibleText.js\"></script>";          //source of collapsible javascript
$month = array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sept","Oct","Nov","Dec");
            $types = $database->query("SELECT * FROM workshop_types ORDER BY weight");
                for($a1=1;$a1<=15;$a1++)
                {
                
            while($tp = mysql_fetch_array($types)){
            
            echo"<table >";
            echo"<tr>";
            echo"<td>";
            echo"<a href=\"index.php?page=".$tp['full_name']."\">".$tp['full_name']."</a>";
            echo"</td>";
            echo"<td align=\"right\">";
            echo "<div onClick=\"openClose('$a1')\" class=\"mainExpand\ style=\"cursor:hand;cursor:pointer\"><h4>Details of upcoming workshops</h4></div>";
            echo"</td>";
            echo"</tr>";
            echo"</table>";
                
                
 
 
$sql ="SELECT * FROM sw_workshops where type='".$tp['code']."' and start_date >= CURRENT_DATE() AND status <> 'closed' order by start_date asc";
                $result = $database->query($sql);
                if ($database->error())echo "failed DB";
                if(mysql_num_rows($result)==0){
                echo $tp['desc_msg'];
                }
                
                
                
                while($row = mysql_fetch_array($result)){
                
$sdate = explode("-",$row['start_date']);
$edate = explode("-",$row['end_date']);     
 
 
 
                                        
                    if ($row['status'] == "regn open"){
                        $url = link_gen("wksp_reg.php?type=".$tp['code']."&id=".$row['id']);
 
 
                        echo "<div id=\"$a1\" class=\"texter\"><li>At ".$row['venue'].", ".$row['city']." <br>From ".$sdate[2]." ".$month[$sdate[1]-1]." ".substr($sdate[0],2,2)." to ".$edate[2]." ".$month[$edate[1]-1]." ".substr($edate[0],2,2).
                            "<br><a href=\"".$url."\">Register now</a></li></div>"; 
                    }
                    if ($row['status'] == "regn closing"){
                        $url = link_gen("wksp_reg.php?type=".$tp['code']."&id=".$row['id']);
            
                        echo "<div id=\"$a1\" class=\"texter\"><li>At ".$row['venue'].", ".$row['city']." <br>From ".$sdate[2]." ".$month[$sdate[1]-1]." ".substr($sdate[0],2,2)." to ".$edate[2]." ".$month[$edate[1]-1]." ".substr($edate[0],2,2).
                            "<br><a href=\"".$url."\">Registrations Closing Soon!</a></li></div>";
                    
                    }
                    if ($row['status'] == "on hold")
                        echo "<div id=\"$a1\" class=\"texter\"><li>At ".$row['venue'].", ".$row['city']." <br>From ".$sdate[2]." ".$month[$sdate[1]-1]." ".substr($sdate[0],2,2)." to ".$edate[2]." ".$month[$edate[1]-1]." ".substr($edate[0],2,2).
                            "<br>Registrations Opening Soon...</li></div>";
                    
                    if ($row['status'] == "regn closed")
                        echo "<div id=\"$a1\" class=\"texter\"><li>At ".$row['venue'].", ".$row['city']." <br>From ".$sdate[2]." ".$month[$sdate[1]-1]." ".substr($sdate[0],2,2)." to ".$edate[2]." ".$month[$edate[1]-1]." ".substr($edate[0],2,2).
                            "<br>Registrations Closed !</li></div>";
                    
                }
                
            }
            
            }
            
            ?>
            
            </div>

the javascript used for expanding list is below

Code: Select all

/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Sandeep Gangadharan | http://www.sivamdesign.com/scripts/ */
if (document.getElementById) {
  document.write('<style type="text/css">.texter {display:none; border-left:white 20px solid; color:#404040; font: .9em verdana, arial, helvetica, sans-serif; margin-bottom: 12px;}</style>') }
 
  var divNum = new Array(1,2,3,4,5,6,7,8,8,9,10,11,12,13);  // at the left you should add a1, a2 etc. for each header you wish to include
                                          // so if you want 4 headers you should add a1, a2, a3, a4 in the format shown
                                          // enclosed in double quotes
function openClose(theID) {
  for(var i=0; i < divNum.length; i++) {
    if (divNum[i] == theID) {
      if (document.getElementById(divNum[i]).style.display == "block") { document.getElementById(divNum[i]).style.display = "none" }
      else {
        document.getElementById(divNum[i]).style.display = "block"
      }
  } else {
    document.getElementById(divNum[i]).style.display = "none"; }
  }
}
the problem is whenever i click on first name its appropriate info is expanded but if i click on other then also the 1st info gets exapnded so i want each information of perticuler topic after clicking on that perticuler item


can anyone tell me how to do that

plz help its very urgent

Re: plz help ----php looping is nt working

Posted: Wed Oct 08, 2008 7:43 am
by aceconcepts
What you need is a toggle switch - take a look at: http://www.dynamicdrive.com/dynamicinde ... llapse.htm