Jump to content

MySQL PHP Dropdown Not Showing Anything


faisalmukhtarch

Recommended Posts

I am using a drop-down box to fetch the result from MySQL and once i select the result from drop-down it will populate my html text-boxes. it was working fine until i added another drop-down. Kindly have a look at the link and let me know. I am new in programming. let me know if you need anymore elaboration. Thank you
http://pastebin.com/EJKA9RsK
This part is working

//This part is working
<?php
$vbCrLf = chr(13).chr(10);
error_reporting(0);
// open connection to MySQL server
$link = mysqli_connect("localhost", "root", "root", "print")
or die ('Unable to connect!');


//create and execute query
$query = "SELECT bin, iban, bename, benadd, bcoun, bcode, bname, badd FROM datee";
$result = mysqli_query($link,$query); 

//create selection list
$DropDownList .= "<select name='Company' id='DropDownListId' onchange='javascript:SelectChanged();'> ".$vbCrLf;
$DropDownList .= "<option value=''></option> ".$vbCrLf;

while($row = mysqli_fetch_row($result))
{
$heading = $row[0];
$DropDownList .= "<option value='$heading'>$heading</option> ".$vbCrLf;


$IbnArrayPhp .= 'IbnArray["'.$heading.'"]="'.$row[1].'";'.$vbCrLf;
$BenameArrayPhp .= 'BenameArray["'.$heading.'"]="'.$row[2].'";'.$vbCrLf;
$BenaddArrayPhp .= 'BenaddArray["'.$heading.'"]="'.$row[3].'";'.$vbCrLf;
$BcounArrayPhp .= 'BcounArray["'.$heading.'"]="'.$row[4].'";'.$vbCrLf;
$BcodeArrayPhp .= 'BcodeArray["'.$heading.'"]="'.$row[5].'";'.$vbCrLf;
$BnameArrayPhp .= 'BnameArray["'.$heading.'"]="'.$row[6].'";'.$vbCrLf;
$BaddArrayPhp .= 'BaddArray["'.$heading.'"]="'.$row[7].'";'.$vbCrLf;
}
$DropDownList .= "</select> ".$vbCrLf;
?>


<script language="Javascript" type="text/javascript">
var IbnArray = new Array();
<?php echo $IbnArrayPhp; ?>
var BenameArray = new Array();
<?php echo $BenameArrayPhp; ?>
var BenaddArray = new Array();
<?php echo $BenaddArrayPhp; ?>
var BcounArray = new Array();
<?php echo $BcounArrayPhp; ?>
var BcodeArray = new Array();
<?php echo $BcodeArrayPhp; ?>
var BnameArray = new Array();
<?php echo $BnameArrayPhp; ?>
var BaddArray = new Array();
<?php echo $BaddArrayPhp; ?>
function SelectChanged()
{
var Company = document.getElementById('DropDownListId').value;
document.getElementById('iban').value = IbnArray[Company];
document.getElementById('bename').value = BenameArray[Company];
document.getElementById('benadd').value = BenaddArray[Company];
document.getElementById('bcoun').value = BcounArray[Company];
document.getElementById('bcode').value = BcodeArray[Company];
document.getElementById('bname').value = BnameArray[Company];
document.getElementById('badd').value = BaddArray[Company];

}
</script>
<?php echo $DropDownList; ?>
</label>
</legend>

This part is not working
 

//This part is not working
<?php
$vbCrLf1 = chr(13).chr(10);
error_reporting(0);
// open connection to MySQL server
$link1 = mysqli_connect("localhost", "root", "root", "print")
or die ('Unable to connect!');


//create and execute query
$query1 = "SELECT aini, acname, acnum, num2, num3 FROM datee";
$result1 = mysqli_query($link1,$query1); 

//create selection list
$DropDownList1 .= "<select name='Company1' id='DropDownList1Id' onchange='javascript:SelectChanged();'> ".$vbCrLf1;
$DropDownList1 .= "<option value=''></option> ".$vbCrLf1;

while($row1 = mysqli_fetch_row($result1))
{
$heading1 = $row1[0];
$DropDownList1 .= "<option value='$heading1'>$heading1</option> ".$vbCrLf1;


$AcnameArrayPhp .= 'AcnameArray["'.$heading1.'"]="'.$row1[1].'";'.$vbCrLf1;
$AcnumArrayPhp .= 'AcnumArray["'.$heading1.'"]="'.$row1[2].'";'.$vbCrLf1;
$Num2ArrayPhp .= 'Num2Array["'.$heading1.'"]="'.$row1[3].'";'.$vbCrLf1;
$Num3ArrayPhp .= 'Num3Array["'.$heading1.'"]="'.$row1[4].'";'.$vbCrLf1;

}
$DropDownList1 .= "</select> ".$vbCrLf1;
?>


<script language="Javascript" type="text/javascript">
var AcnameArray = new Array();
<?php echo $AcnameArrayPhp; ?>
var AcnumArray = new Array();
<?php echo $AcnumArrayPhp; ?>
var Num2Array = new Array();
<?php echo $Num2ArrayPhp; ?>
var Num3Array = new Array();
<?php echo $Num3ArrayPhp; ?>


function SelectChanged()
{
var Company1 = document.getElementById('DropDownList1Id').value;
document.getElementById('acname').value = AcnameArray[Company1];
document.getElementById('acnum').value = AcnumArray[Company1];
document.getElementById('num2').value = Num2Array[Company1];
document.getElementById('num3').value = Num3Array[Company1];



}
</script>
<?php echo $DropDownList1; ?>
</label>
</legend>
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.