cannot display hidden value in mysql div

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • blackchakra
    New Member
    • Apr 2013
    • 1

    cannot display hidden value in mysql div

    this is my code..i cannot find my mistake

    Code:
    <head> <meta http-equiv="content-type" content="text/html;charset=iso-8859-1"> <title>TestPage</title> <script type="text/javascript">
    function contactSelect() {
    var selectedValue = document.getElementById("cd-dropdown").value;
    document.getElementById("Background").style.visibility = "hidden";
    document.getElementById("Objective").style.visibility = "hidden";
    document.getElementById("Contact Us").style.visibility = "hidden";
    document.getElementById("Director").style.visibility = "hidden";
    document.getElementById("Office").style.visibility = "hidden";
    if(selectedValue == "1")
    document.getElementById("Background").style.visibility = "visible";
    if(selectedValue == "2")
    document.getElementById("Objective").style.visibility = "visible";
    if(selectedValue == "3")
    document.getElementById("Contact Us").style.visibility = "visible";
    if(selectedValue == "4")
    document.getElementById("Director").style.visibility = "visible";
    if(selectedValue == "5")
    document.getElementById("Office").style.visibility = "visible";
    }
    </script> </head> <body onload="contactSelect();"> <select id="cd-dropdown" class="cd-select" onchange="contactSelect();"> <option value="-1" selected>Choose a contact information</option> <option value="1">Background</option> <option value="2">Objective</option> <option value="3">Contact Center</option> <option value="4">Contact Director</option> <option value="5">Contact Office Manager</option> </select> <div class="fleft"> <?php //to make connection with database
    	$conn=mysql_connect("localhost","root","") or die(mysql_error());
    
    	//to select the targeted database
    	mysql_select_db("ickp",$conn) or die(mysql_error());
    
    	//Create query
    	$query="SELECT * FROM about";
    
    	//to run sql query in database
    	$result=mysql_query($query,$conn) or die(mysql_error());
     
    	//Check whether the query was successful or not
    	if(isset($result)){
    		if(mysql_num_rows($result) == 1) {
    			//Login Successful
                
    			while ($row = mysql_fetch_array($result)){
    ?> <div id="Background" class="display" style="display:none"> <?php   
    			echo "$row[background]<br/>";
    ?> </div> <div id="Objective" class="display" style="display:none"> <p>Among the key areas conducted by the Center are:</p><br /> <?php
    			echo "<p>1.	$row[objective1]</p><br/>";
    			echo "<p>2.	$row[objective2]</p><br/>";
    			echo "<p>3.	$row[objective3]</p><br/>";
    			echo "<p>4.	$row[objective4]</p><br/>";
    ?> </div> <div id="Contact Us" class="display" style="display:none"> <?php
    			echo "<p><strong>$row[CoEname]</strong></p>";
    			echo "<p>$row[UniName]</p>";
    			echo "<p>$row[road]</p>";
    			echo "<p>$row[postcode], $row[city]</p>";
    			echo "<p>$row[state]</p>";
    			echo "<p>Fax: $row[fax]</p><br/>";
    ?> </div> <div id="Director" class="display" style="display:none"> <?php
    			echo "<p><strong>$row[director]</strong></p>";
    			echo "<p>$row[d_email]</p>";
    			echo "<p>$row[d_phone]</p><br/>";
    ?> </div> <div id="Office" class="display" style="display:none"> <?php
    			echo "<p><strong>$row[office]</strong></p>";
    			echo "<p>$row[o_email]</p>";
    			echo "<p>$row[o_phone]</p><br/>";
    ?> </div> <?php
    }
    		}}
    	else {
        die("Query failed");
    	}
    	?> </div></body> </html>
    thanks in advance
    Last edited by Rabbit; Apr 14 '13, 06:26 PM. Reason: Please use code tags when posting code.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    I don't understand what problem you're having. Are you saying that the problem is the PHP and that it's not displaying data from the database? In which case you are in the wrong forum and I can move the question for you.

    If however you are saying the javascript is not working to hide/unhide the divs, then we need the source code from the client side.

    Comment

    • omerbutt
      Contributor
      • Nov 2006
      • 638

      #3
      so far there isnt any mistake as seeing the code , but untill unless you identify what problem you are facing , try sticking to the rules use double quotes / single quotes around the table field names.

      regards,
      Omer aslam

      Comment

      Working...