Jump to content

Drop down list to control data shown


andrew_biggart

Recommended Posts

I am currently trying to use a drop down list to controll which content is shown on a page. For example the user will have a list of projects in a drop down list, once one of the projects is selected the main div should show the relative content.

 

I have followed a tutorial but cannot seem to get the information to be displayed.

 

these are the two files I have

 

client_section.php

<? 
session_start();
if(!session_is_registered(myusername)){
header("location:login.php");
}
?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" type="text/css" href="styling.css">
<script>
function getproject(strURL) {		

	var req = getXMLHTTP();

	if (req) {

		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				// only if "OK"
				if (req.status == 200) {						
					document.getElementById('citydiv').innerHTML=req.responseText;						
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}
			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}

}
</script>
</head>

<body>
<div id="wrapper">
<div id="header">
        <div id="digital-logo"><img src="peppermint-digital.png" alt="Peppermint Digital" /></div>
      	<div id="digital-number">0161 941 4252</div>
  	</div>
  	<div id="company-info">
    <?php
include("config.php");
$client_username=$_GET['client'];

$sql1=" SELECT * FROM client_list WHERE client_username = '$client_username' ";
$result1=mysql_query($sql1);

while($rows1=mysql_fetch_array($result1)){
?>
    	<div id="company-logo"><img src="<?php echo $rows1['client_logo']; ?>" alt="<?php echo $rows1['client_username']; ?> Logo" /></div>
        <div id="company-details">
        	<p><?php echo $rows1['client_username']; ?></p>
            <p><?php echo $rows1['client_contact']; ?></p>
            <p><?php echo $rows1['client_email']; ?></p>
            <p><?php echo $rows1['client_number']; ?></p>
        </div>
        <div id="welcome">Welcome Back, <?php echo $rows1['client_contact']; ?>. <a href="logout.php">Logout!</a></div>
    <?php
}
// close connection 
mysql_close($sql1);
?>
    </div>

    <div id="navigation">
    	<div id="menu">
            <ul id="digital_menu">
                <li>Web Design</li>
                <li>Web Development</li>
                <li>SEO Reports</li>
            </ul>       
        </div>
        <div id="drop-down-text">Project Selection</div>
      	<form method="post" action="#">
	<div id="drop-down">
            <select class="project-select" name="project_selection" nChange="getproject('find_project.php?project='+this.value)" >
            	<option>Select a project</option>
			<?php
                include('config.php');
                $client_username=$_GET['client'];
                                                    
                // Retrieve data from database 
                $sql2=" SELECT * FROM project_list WHERE client_username = '$client_username' ";
                $result2=mysql_query($sql2);
                                                
                // Start looping rows in mysql database.
                while($rows2=mysql_fetch_array($result2)){
                ?>
                <option><? echo $rows2['project_name']; ?></option>
                <?
                // close while loop 
                }
                                                
                // close connection 
                mysql_close();
                ?>
            </select> 
        </div>
        </form>
    </div>
<div id="main">
    </div>
</div>
</body>
</html>

 

find_project.php

    <?php
include("config.php");
$project=$_REQUEST['project'];

$sql3=" SELECT * FROM project_list WHERE project_name = '$project' ";
$result3=mysql_query($sql3);

while($rows3=mysql_fetch_array($result3)){
?>
    <div id="content">
    	<div id="left-col">
        	<div id="notes-holder"><?php echo $rows3['project_instructions']; ?></div>
            <div id="instructions-holder"><?php echo $rows3['project_comments']; ?></div>
        </div>
        <div id="right-col">
            <div id="image-holder">Main Image</div>
            <div id="thumb-holder">Thumbs</div>
        </div>
    </div>
    <div id="account-section"> 
    	<div id="account-contact">
        	<div id="account-manager">Account Manager : <?php echo $rows3['project_staff']; ?></div>
            <div id="account-contactform">Contact Form</div>
        </div>
    </div>
<?php
}
// close connection 
mysql_close();
?>

 

Can anyone see what I am doing wrong?

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.