Using the following code:
<html>
<head>
<title>Issues- Reduced View</title>
</head>
<body marginheight="0" topmargin="0" marginwidth="0"
leftmargin="0" style="margin:0;padding:0" bgcolor="#B0E0E6">
<h1></h1>
<form action="reduced_view_issues.php" method="post">
<?php
//ini_set("display_errors","Off");
$server_name='xxx';
$user_name=''xxx';
$password='xxx';
$database_name='xxx';
$db1= new mysqli($server_name, $user_name, $password, $database_name);
include_once('functions.php');
if(is_numeric($_POST['ddsub_sector_id'])) {$subsectorid=$_POST['ddsub_sector_id'];} else {$subsectorid='1';}
if(empty($_POST['tbtickersearch'])) {$bondticker="'%'";} else {$bondticker="'".$_POST['tbtickersearch']."%'";}
if(is_numeric($_POST['ddcurrency_id'])) {$currencyid=$_POST['ddcurrency_id'];} else {$currencyid='NULL';}
if(is_numeric($_POST['ddcountry_id'])) {$countryid=$_POST['ddcountry_id'];} else {$countryid='NULL';}
if(empty($_POST['tbenterticker'])) {$enterticker='NULL';} else {$enterticker="'".$_POST['tbenterticker']."'";}
if(empty($_POST['tbenterlevel'])) {$enterlevel='NULL';} else {$enterlevel="'".$_POST['tbenterlevel']."'";}
if(is_numeric($_POST['ddquote_convention_id'])) {$quoteconventionid=$_POST['ddquote_convention_id'];} else {$quoteconventionid='NULL';}
if(is_numeric($_POST['ddbenchmark_id'])) {$benchmarkid=$_POST['ddbenchmark_id'];} else {$benchmarkid='NULL';}
if(empty($_POST['tbentermaturity'])) {$entermaturity='NULL';} else {$entermaturity="'".$_POST['tbentermaturity']."'";}
$result=get_dataset($db1,"call sp_filter_issues_reduced_view(".$subsectorid.",".$bondticker.",".$currencyid.",".$countryid.")");
//$result2=get_dataset($db1,"call sp_filter_issues_reduced_view(".$subsectorid.",".$bondticker.",".$currencyid.",".$countryid.")");
//$db1->close();
/*var_dump($stat_array);*/
?>
<table border="0"; style="border-collapse:collapse; border:solid 1px black"; bgcolor='#C0C0C0' width=100%>
<tr bgcolor='#C0C0C0' width=100%>
<td align='center'>
<table style="border-collapse:collapse; border:solid 1px #C0C0C0"; bgcolor='#C0C0C0'>
<tr bgcolor='#C0C0C0' width=100%>
<td style="width: auto">
Select Sub Sector
<?php simple_drop_down('ddsub_sector_id','sub_sector_id','sub_sector_name',$db1,"call sp_sub_sector",0,$subsectorid); ?>
</td>
<td >
</td>
<td style="width: auto">
Enter Description
<?php echo "<input type='text' name='tbtickersearch' value='".$_POST['tbtickersearch']."'/>"; ?>
</td>
<td style="width: auto">
Select Currency
<?php simple_drop_down('ddcurrency_id','currency_id','currency_ticker',$db1,"call sp_currency",1,$currencyid);?>
</td>
<td style="width: auto">
Select Country
<?php simple_drop_down('ddcountry_id','country_id','country_code',$db1,"call sp_country",1,$countryid);?>
</td>
<td style="width: auto">
<input type='submit' name='btnsearch' value='Search' style="width: auto">
</td>
</tr>
</table>
</td>
<td align='center'>
<table style="border-collapse:collapse; border:solid 1px #C0C0C0"; bgcolor='#C0C0C0'>
<tr bgcolor='#C0C0C0' width=100%>
<td style="width: auto">
Enter Description
<?php echo "<input type='text' name='tbenterticker' value='".$_POST['tbenterticker']."'/>"; ?>
</td>
<td style="width: auto">
Enter Level
<?php echo "<input type='text' name='tbenterlevel' value='".$_POST['tbenterlevel']."'/>"; ?>
</td>
<td style="width: auto">
Select Quote Convention
<?php simple_drop_down('ddquote_convention_id','quote_convention_id','quote_convention_name',$db1,"call sp_all_quote_convention",1,$quoteconventionid);?>
</td>
<td style="width: auto">
Select Benchmark
<?php simple_drop_down('ddbenchmark_id','issue_id','description',$db1,"call sp_benchmark",1,$benchmarkid);?>
</td>
<td style="width: auto">
Enter Call/Maturity
<?php echo "<input type='text' name='tbentermaturity' value='".$_POST['tbentermaturity']."'/>"; ?>
</td>
<td style="width: auto">
<input type='submit' name='btncurve' value='View Curve' style="width: auto">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<table border="1"; style="border-collapse:collapse; border:solid 1px black"; bgcolor='white'>
<tr bgcolor='#C0C0C0'>
<td align='center' style="border-collapse:collapse; border:solid 1px black; width: auto";>Description</td>
<td align='center' style="border-collapse:collapse; border:solid 1px black";>Currency</td>
<td align='center' style="border-collapse:collapse; border:solid 1px black";>Call Date</td>
<td align='center' style="border-collapse:collapse; border:solid 1px black";>Maurity Date</td>
<td align='center' style="border-collapse:collapse; border:solid 1px black";>ISIN</td>
<td align='center' style="border-collapse:collapse; border:solid 1px black";>Moody</td>
<td align='center' style="border-collapse:collapse; border:solid 1px black";>Fitch</td>
<td align='center' style="border-collapse:collapse; border:solid 1px black";>S&P</td>
<td align='center' style="border-collapse:collapse; border:solid 1px black";>Capital Type</td>
<td align='center' style="border-collapse:collapse; border:solid 1px black";>Bid ASW</td>
<td align='center' style="border-collapse:collapse; border:solid 1px black";></td>
<td align='center' style="border-collapse:collapse; border:solid 1px black";>Ask ASW</td>
<td align='center' style="border-collapse:collapse; border:solid 1px black";>Bid Sprd</td>
<td align='center' style="border-collapse:collapse; border:solid 1px black";></td>
<td align='center' style="border-collapse:collapse; border:solid 1px black";>Ask Sprd</td>
<td align='center' style="border-collapse:collapse; border:solid 1px black";>Bid Price</td>
<td align='center' style="border-collapse:collapse; border:solid 1px black";></td>
<td align='center' style="border-collapse:collapse; border:solid 1px black";>Ask Price</td>
<td align='center' style="border-collapse:collapse; border:solid 1px black";>Bid YTC</td>
<td align='center' style="border-collapse:collapse; border:solid 1px black";></td>
<td align='center' style="border-collapse:collapse; border:solid 1px black";>Ask YTC</td>
<td align='center' style="border-collapse:collapse; border:solid 1px black";>Bid YTM</td>
<td align='center' style="border-collapse:collapse; border:solid 1px black";></td>
<td align='center' style="border-collapse:collapse; border:solid 1px black";>Ask YTM</td>
<td align='center' style="border-collapse:collapse; border:solid 1px black";>Date</td>
<td align='center' style="border-collapse:collapse; border:solid 1px black";>Time</td>
<td align='center' style="border-collapse:collapse; border:solid 1px black";>Source</td>
<td align='center' style="border-collapse:collapse; border:solid 1px black";>Change on Day</td>
<td align='center' style="border-collapse:collapse; border:solid 1px black";>Change from Issue</td>
<td align='center' style="border-collapse:collapse; border:solid 1px black";>Quote Convention</td>
<td align='center' style="border-collapse:collapse; border:solid 1px black";>Price To</td>
<td align='center' style="border-collapse:collapse; border:solid 1px black";>Current Benchmark</td>
<td align='center' style="border-collapse:collapse; border:solid 1px black";>Issue Swap Spread</td>
<td align='center' style="border-collapse:collapse; border:solid 1px black";>Issue Benchmark Spread</td>
<td align='center' style="border-collapse:collapse; border:solid 1px black";>Issue Price</td>
<td align='center' style="border-collapse:collapse; border:solid 1px black";>Coupon Step</td>
<td align='center' style="border-collapse:collapse; border:solid 1px black";>Amt Issued</td>
<td align='center' style="border-collapse:collapse; border:solid 1px black";>Amt Outstanding</td>
</tr>
<?php
$irow=0;
foreach ($result as $row)
{
echo "<form action='select_issue3.php' method='post'>";
if ($irow % 2 != 0) # An odd row
$colour = "6699FF";
else # An even row
$colour = "white";
if (max($_POST['issueid'])==$row['issue_id'])
$colour="yellow";
echo "<tr bgcolor=".$colour.">";
echo "<td style='white-space: nowrap; width: auto; border-collapse:collapse; border:solid 1px black';>";
echo "<input type='submit' style='width: auto' id='bonddescription' name='bonddescription[]' value='" .$row['description']."'><input type='hidden' id='issueid' name='issueid[]' value='".$row['issue_id']."'>";
echo "</td>";
?>
<td style='white-space: nowrap; border-collapse:collapse; border:solid 1px black';>
<?php echo $row['currency_ticker'];?>
</td>
<td style='white-space: nowrap; border-collapse:collapse; border:solid 1px black';>
<?php echo $row['first_call_date'];?>
</td>
<td style='white-space: nowrap; border-collapse:collapse; border:solid 1px black';>
<?php echo $row['maturity_date'];?>
</td>
<td style='white-space: nowrap; border-collapse:collapse; border:solid 1px black';>
<?php echo $row['isin'];?>
</td>
<td style='white-space: nowrap; border-collapse:collapse; border:solid 1px black';>
<?php echo $row['moody'];?>
</td>
<td style='white-space: nowrap; border-collapse:collapse; border:solid 1px black';>
<?php echo $row['fitch'];?>
</td>
<td style='white-space: nowrap; border-collapse:collapse; border:solid 1px black';>
<?php echo $row['sandp'];?>
</td>
<td style='white-space: nowrap; border-collapse:collapse; border:solid 1px black';>
<?php echo $row['capital_name'];?>
</td>
<td align='right' style='white-space: nowrap; border-collapse:collapse; border:solid 1px black';>
<?php echo $row['bid_asw'];?>
</td>
<td align='center' style='white-space: nowrap; border-collapse:collapse; border:solid 1px black';>
/
</td>
<td align='left' style='white-space: nowrap; border-collapse:collapse; border:solid 1px black';>
<?php echo $row['ask_asw'];?>
</td>
<td align='right' style='white-space: nowrap; border-collapse:collapse; border:solid 1px black';>
<?php echo $row['bid_sprd'];?>
</td>
<td align='center' style='white-space: nowrap; border-collapse:collapse; border:solid 1px black';>
/
</td>
<td align='left' style='white-space: nowrap; border-collapse:collapse; border:solid 1px black';>
<?php echo $row['ask_sprd'];?>
</td>
<td align='right' style='white-space: nowrap; border-collapse:collapse; border:solid 1px black';>
<?php echo $row['bid_price'];?>
</td>
<td align='center' style='white-space: nowrap; border-collapse:collapse; border:solid 1px black';>
/
</td>
<td align='left' style='white-space: nowrap; border-collapse:collapse; border:solid 1px black';>
<?php echo $row['ask_price'];?>
</td>
<td align='right' style='white-space: nowrap; border-collapse:collapse; border:solid 1px black';>
<?php echo $row['bid_ytc'];?>
</td>
<td align='center' style='white-space: nowrap; border-collapse:collapse; border:solid 1px black';>
/
</td>
<td align='left' style='white-space: nowrap; border-collapse:collapse; border:solid 1px black';>
<?php echo $row['ask_ytc'];?>
<td align='right' style='white-space: nowrap; border-collapse:collapse; border:solid 1px black';>
<?php echo $row['bid_ytm'];?>
</td>
<td align='center' style='white-space: nowrap; border-collapse:collapse; border:solid 1px black';>
/
<td align='left' style='white-space: nowrap; border-collapse:collapse; border:solid 1px black';>
<?php echo $row['ask_ytm'];?>
</td>
<td style='white-space: nowrap; border-collapse:collapse; border:solid 1px black';>
<?php echo $row['price_date'];?>
</td>
<td style='white-space: nowrap; border-collapse:collapse; border:solid 1px black';>
<?php echo $row['price_time'];?>
</td>
<td style='white-space: nowrap; border-collapse:collapse; border:solid 1px black';>
<?php echo $row['source_code'];?>
</td>
<td style='white-space: nowrap; border-collapse:collapse; border:solid 1px black';>
<?php echo number_format($row['cod'],3);?>
</td>
<td style='white-space: nowrap; border-collapse:collapse; border:solid 1px black';>
<?php echo number_format($row['change_from_issue'],3);?>
</td>
<td style='white-space: nowrap; border-collapse:collapse; border:solid 1px black';>
<?php echo $row['quote_convention_name'];?>
</td>
<td style='white-space: nowrap; border-collapse:collapse; border:solid 1px black';>
<?php echo $row['price_to_name'];?>
</td>
<td style='white-space: nowrap; border-collapse:collapse; border:solid 1px black';>
<?php echo $row['current_benchmark_description'];?>
</td>
<td style='white-space: nowrap; border-collapse:collapse; border:solid 1px black';>
<?php echo $row['issue_swap_spread'];?>
</td>
<td style='white-space: nowrap; border-collapse:collapse; border:solid 1px black';>
<?php echo $row['issue_benchmark_spread'];?>
</td>
<td style='white-space: nowrap; border-collapse:collapse; border:solid 1px black';>
<?php echo $row['issue_price'];?>
</td>
<td style='white-space: nowrap; border-collapse:collapse; border:solid 1px black';>
<?php echo $row['coupon_step'];?>
</td>
<td style='white-space: nowrap; border-collapse:collapse; border:solid 1px black';>
<?php echo $row['amount_issued']/1000000;?>
</td>
<td style='white-space: nowrap; border-collapse:collapse; border:solid 1px black';>
<?php echo $row['amount_outstanding']/1000000;?>
</td>
</tr>
<?php
$irow++;
echo "</form>";
}
var_dump($_POST);
?>
</table>
</tr>
</table>
</form>
</body>
When I click on any button, i.e. the following fires:
echo "<input type='submit' style='width: auto' id='bonddescription' name='bonddescription[]' value='" .$row['description']."'><input type='hidden' id='issueid' name='issueid[]' value='".$row['issue_id']."'>";
This works correctly....except for the first row of any dataset. If there is 1 row it doesn't work, if there are 6 rows, row 1 still doesn't work, yet the rest do!
select_issue3.php contains the following:
if (isset($_POST['bonddescription']))
{include_once('reduced_view_issues.php');
include_once('select_issue.php');
}
which must be firing correctly, as the page works for any row other than 1.
This is select_issue.php:
<html>
<head>
<title>Sectors</title>
</head>
<body marginheight="0" topmargin="0" marginwidth="0"
leftmargin="0" style="margin:0;padding:0" bgcolor="#B0E0E6">
<form action="select_issue3.php" method="post">
<?php
//if(empty(max($_POST['issueid'])) {$issueid='NULL';} else {$issueid="'".max($_POST['issueid'])."'";}
$bond_issue_id=max($_POST['issueid']);
include_once('functions.php');
$server_name='xxx';
$user_name=''xxx';
$password='xxx';
$database_name='xxx';
$result_array=get_dataset($db1,"call sp_select_issue(".$bond_issue_id.")");
foreach ($result_array as $row)
{
$bond_description = $row['description'];
$bond_issue_id = $row['issue_id'];
?>
<table border="1" style="border:solid black" cellpadding="0"
cellspacing="0" width="100%" bgcolor='white'>
<td><table width='100%'>
<tr>
<td align='center'>
<form action="select_issue3.php" method="post">
<input type='submit' name='btnedit' value='Edit <?php echo $bond_description;?>'>
<?php echo "<input type='hidden' id='issueid' name='issueid[]' value='".$bond_issue_id."'>"; ?>
</form>
</td>
</tr>
<tr>
<td align="left">Notes</td>
<td>
<?php echo $row['notes'];?>
</td>
</tr>
<tr>
<td align="left">Benchmark</td>
<td>
<?php if($row['benchmark_bond_cb']="1") {$checked='checked';} ?>
<?php echo "<input type='Checkbox' id='value' disabled='true' value='".$checked."' checked=".$checked." name='cbbenchmarkid[]' >"; ?>
</td>
</tr>
</table>
</td>
<td>
<table width='100%'>
<tr>
<td align="left">Currency</td>
<td>
<?php echo $row['currency_ticker'];?>
</td>
</tr>
<tr>
<td align="left">Coupon</td>
<td>
<?php echo $row['coupon'];?>
</td>
</tr>
<tr>
<td align="left">Coupon Type</td>
<td>
<?php echo $row['coupon_type_name'];?>
</td>
</tr>
<tr>
<td align="left">Coupon Frequency</td>
<td>
<?php echo $row['coupon_frequency_code'];?>
</td>
</tr>
<tr>
<td align="left">Day Count</td>
<td>
<?php echo $row['day_count_name'];
?>
</td>
</tr>
</table>
</td>
<td>
<table width='100%'>
<tr>
<td>
Bookrunners
</td>
<td>
Exchanges
</td>
</tr>
<tr>
<td>
<table>
<?php
$result_array2=get_dataset($db1,"call sp_bookrunner(".$bond_issue_id.")");
foreach ($result_array2 as $row2)
{
echo "<tr>".$row2['bond_ticker']."</tr>";
}
?>
</table>
</td>
<td>
<table valign='top'>
<?php
$result_array3=get_dataset($db1,"call sp_exchange_issue(".$bond_issue_id.")");
foreach ($result_array3 as $row3)
{
echo "<tr><td valign='top'>".$row3['exchange_code']."</td></tr>";
}
?>
</table>
</td>
</tr>
</table>
</td>
<td>
<table width='100%'>
<tr>
<td align="left">Price To</td>
<td>
<?php echo $row['price_to_name'];?>
</td>
</tr>
<tr>
<td align="left">Quote Convention</td>
<td>
<?php echo $row['quote_convention_name'];?>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table width='100%'>
<tr>
<td align="left">Issuer</td>
<td>
<?php echo $row['issuer_name'];?>
</td>
</tr>
<tr>
<td align="left">Guarantor</td>
<td>
<?php echo $row['guarantor_name'];?>
</td>
</tr>
<tr>
<td align="left">Sub Sector</td>
<td>
<?php echo $row['sub_sector_name'];?>
</td>
</tr>
<tr>
<td align="left">Market</td>
<td>
<?php echo $row['market_name'];?>
</td>
</tr>
</table>
</td>
<td>
<table width='100%'>
<tr>
<td align="left">CUSIP</td>
<td>
<?php echo $row['cusip'];?>
</td>
</tr>
<tr>
<td align="left">Bloomberg Number</td>
<td>
<?php echo $row['bloomberg_number'];?>
</td>
</tr>
<tr>
<td align="left">ISIN</td>
<td>
<?php echo $row['isin'];?>
</td>
</tr>
</table>
</td>
<td>
<table width='100%'>
<tr>
<td align="left">Moody</td>
<td>
<?php echo $row['moody'];?>
</td>
</tr>
<tr>
<td align="left">Fitch</td>
<td>
<?php echo $row['fitch'];?>
</td>
</tr>
<tr>
<td align="left">S&P</td>
<td>
<?php echo $row['sandp'];?>
</td>
</tr>
</table>
</td>
<td>
<table width='100%'>
<td align="left">Capital Type</td>
<td>
<?php echo $row['capital_name'];?>
</td>
</tr>
<tr>
<td align="left">Collateral Type</td>
<td>
<?php echo $row['collateral_type_name'];?>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table width='100%'>
<tr>
<td align='right'>Bid ASW</td>
<td align='center'></td>
<td align='left'>Ask ASW</td>
<td align='right'>Bid Sprd</td>
<td align='center'></td>
<td align='left'>Ask Sprd</td>
<td align='right'>Bid Price</td>
<td align='center'></td>
<td align='left'>Ask Price</td>
<td align='right'>Bid YTC</td>
<td align='center'></td>
<td align='left'>Ask YTC</td>
<td align='right'>Bid YTM</td>
<td align='center'></td>
<td align='left'>Ask YTM</td>
<td>Date</td>
<td>Time</td>
<td>Source</td>
</tr>
<tr>
<?php
$result_array4=get_dataset($db1,"call sp_last_price(".$bond_issue_id.",5)");
foreach ($result_array4 as $row4)
{
?>
<td align='right'>
<?php echo $row4['bid_asw'];?>
</td>
<td align='center'>
/
</td>
<td align='left'>
<?php echo $row4['ask_asw'];?>
</td>
<td align='right'>
<?php echo $row4['bid_sprd'];?>
</td>
<td align='center'>
/
</td>
<td align='left'>
<?php echo $row4['ask_sprd'];?>
</td>
<td align='right'>
<?php echo $row4['bid_price'];?>
</td>
<td align='center'>
/
</td>
<td align='left'>
<?php echo $row4['ask_price'];?>
</td>
<td align='right'>
<?php echo $row4['bid_ytc'];?>
</td>
<td align='center'>
/
</td>
<td align='left'>
<?php echo $row4['ask_ytc'];?>
</td>
<td align='right'>
<?php echo $row4['bid_ytm'];?>
</td>
<td align='center'>
/
</td>
<td align='left'>
<?php echo $row4['ask_ytm'];?>
</td>
<td>
<?php echo $row4['price_date'];?>
</td>
<td>
<?php echo $row4['price_time'];?>
</td>
<td>
<?php echo $row4['exchange_code'];?>
</td>
</tr>
<?php
}
?>
</table>
</td>
<td>
<table width='100%'>
<tr>
<td align="left">Issue Benchmark</td>
<td>
<?php echo $row['issue_benchmark_description'];?>
</td>
</tr>
<tr>
<td align="left">Current Benchmark</td>
<td>
<?php echo $row['current_benchmark_description'];?>
</td>
</tr>
<tr>
<td align="left">Issue Swap Spread</td>
<td>
<?php echo $row['issue_swap_spread'];?>
</td>
</tr>
<tr>
<td align="left">Issue Benchmark Spread</td>
<td>
<?php echo $row['issue_benchmark_spread'];?>
</td>
</tr>
<tr>
<td align="left">Issue Price</td>
<td>
<?php echo $row['issue_price'];?>
</td>
</tr>
<tr>
<td align="left">Coupon Step</td>
<td>
<?php echo $row['coupon_step'];?>
</td>
</tr>
</table>
</td>
<td>
<table width='100%'>
<tr>
<td align="left">Announcement Date</td>
<td>
<?php echo $row['announcement_date'];?>
</td>
</tr>
<tr>
<td align="left">Interest Accrual Date</td>
<td>
<?php echo $row['interest_accrual_date'];?>
</td>
</tr>
<tr>
<td align="left">First Settlement Date</td>
<td>
<?php echo $row['first_settle_date'];?>
</td>
</tr>
<tr>
<td align="left">First Coupon Date</td>
<td>
<?php echo $row['first_coupon_date'];?>
</td>
</tr>
<tr>
<td align="left">Maurity Date</td>
<td>
<?php echo $row['maturity_date'];?>
</td>
</tr>
<tr>
<td align="left">Call Date</td>
<td>
<?php echo $row['first_call_date'];?>
</td>
</tr>
</table>
</td>
<td>
<table width='100%'>
<tr>
<td align="left">Amount Issued</td>
<td>
<?php echo number_format($row['amount_issued']);?>
</td>
<td></td>
</tr>
<tr>
<td align="left">Amount Outstanding</td>
<td>
<?php echo number_format($row['amount_outstanding']);?>
</td>
</tr>
<tr>
<td align="left">Minimum Size</td>
<td>
<?php echo number_format($row['min_size']);?>
</td>
</tr>
<tr>
<td align="left">Increment</td>
<td>
<?php echo number_format($row['increment']);?>
</td>
</tr>
<tr>
<td align="left">Par Amount</td>
<td>
<?php echo number_format($row['par_amount']);?>
</td>
</tr>
</table>
</td>
</tr>
</table>
<?php }
//$db1->close();
?>
</form>
</body>
</html>
functions.php is as follows (I don't believe there are any issues here):
<?php
//----------------------------------------------------------------------
$server_name='xxx';
$user_name=''xxx';
$password='xxx';
$database_name=''xxx';
$db1= new mysqli($server_name, $user_name, $password, $database_name);
//----------------------------------------------------------------------
/*function db_result_to_array($db1, $query_string){
//---------------------------------------------------------------------
$result = $db1->query($query_string);
$res_array = array();
while($res_away = $result->fetch_assoc()){
$field_id="'".$field_id."'";
$results[ $result[$field_id]] =$result;
}
//---------------------------------------------------------------------
*/
function get_combobox_dataset($db1, $query_string) {
//---------------------------------------------------------------------
$result2 = $db1->query($query_string);
if($result2 === false)
{
echo 'Error!';
}
else
{
// do the fetching...
}
/*
$num_results = $result1->num_rows;
$res_array = array();
for ($count=0; $row = $result1->fetch_assoc(); $count++) {
$res_array[$count]=$row;
}
return $res_array;*/
}
//---------------------------------------------------------------------
function get_dataset($db1, $query_string) {
//---------------------------------------------------------------------
$result1 = $db1->query($query_string);
//$num_results = $result1->num_rows;
if (! $result1) die($db1->error);
$num_results = $result1->num_rows;
$res_array = array();
while ($row = $result1->fetch_assoc()) {
$res_array[]=$row;
}
//$query_string->free();
$result1->free();
//#MAD Add these lines to "clear the pipe" after a Stored Procedure Call
while ($db1->more_results()) {
$db1->next_result();
// #MAD I'm not sure if these two lines are needed or not
// $result = $db1->store_result();
//$result1->free();
}
return $res_array;
}
//---------------------------------------------------------------------
function get_sub_dataset($db1, $query7,$sub_field_id) {
//---------------------------------------------------------------------
$query1 = $query7;
$result1 = $db1->query($query1);
$num_results = $result1->num_rows;
//$result8 = db_result_to_array($result1);
return $result1;}
$query1->free;
$result1->free;
//---------------------------------------------------------------------
function drop_down($array_name,$field_id, $query_field_id, $field_name,$db1,$query_string,$row,$multiple=0,$query_string2=0,$sub_field_id=0) {
//-------------------------------------------------------------------------------------------------------------------------
$stat_array=get_dataset($db1,$query_string);
//echo "<select name=".$array_name." width='100%'>";
if(empty($multiple)) {
echo "<select name=".$array_name." width='100%'>";
if ($row[$field_id] == $thiscat[$query_field_id]) {}{echo "<option>None Selected</option>";}
foreach ($stat_array as $thiscat)
{
echo '<option value="' . $thiscat[$query_field_id] . '"';
if ($row[$field_id] == $thiscat[$query_field_id]) {echo ' selected';}
echo '>' . $thiscat[$field_name] . '</option>';
}
}
else {echo "<select multiple size =".$multiple." name=".$array_name." width='100%'>";
foreach ($stat_array as $thiscat)
{
echo '<option value="' . $thiscat[$query_field_id] . '"';
$list_box_array=get_dataset($db1,$query_string2);
foreach ($list_box_array as $list_box_row)
{
if ($list_box_row[$sub_field_id] == $thiscat[$query_field_id]) {echo ' selected';}
}
echo '>' . $thiscat[$field_name] . '</option>';
}
}
echo "</select>";
}
//-------------------------------------------------------------------------------------------------------------------------
function simple_drop_down($drop_down_name,$field_id,$field_name,$db1, $query_string, $none=0, $default_value=0) {
//-----------------------------------------------------------------------------------------------------------------------------------
/*$stat_array=get_dataset($db1,"select * from tblcurrency;");
var_dump($stat_array);*/
echo "<select name=".$drop_down_name.">";
$stat_array=get_dataset($db1,$query_string);
if ($none == 1) {echo "<option>None Selected</option>";}
foreach ($stat_array as $thisstat){
echo "<option value=\"".$thisstat[$field_id]."\"";
if ($default_value == $thisstat[$field_id]) {echo ' selected';}
echo ">".$thisstat[$field_name]."</option>";
}
echo "</select>";
}
//-----------------------------------------------------------------------------------------------------------------------------------
?>
As usual, I'm completely clueless and can't figure this one out, how can rows 2 onwards work, yet not row 1!!!!
If it makes a difference the var_dump for row 1 for some reason includes controls above it on the page, for example:
var_dump for row 1:
array(11) { ["ddsub_sector_id"]=> string(1) "1" ["tbtickersearch"]=> string(0) "" ["ddcurrency_id"]=> string(13) "None Selected" ["ddcountry_id"]=> string(13) "None Selected" ["tbenterticker"]=> string(0) "" ["tbenterlevel"]=> string(0) "" ["ddquote_convention_id"]=> string(13) "None Selected" ["ddbenchmark_id"]=> string(13) "None Selected" ["tbentermaturity"]=> string(0) "" ["bonddescription"]=> array(1) { [0]=> string(17) "BACR 5.000 4/2013" } ["issueid"]=> array(1) { [0]=> string(2) "97" } }
var_dump for row 2:
array(2) { ["bonddescription"]=> array(1) { [0]=> string(18) "BACR 6.000 12/2017" } ["issueid"]=> array(1) { [0]=> string(2) "99" } }
I'm hoping someone can figure it out from this, as I don't understand why the var_dump includes all the extra info (as well as the correct info), yet somehow the correct info isn't collected when I try to capture it using $_POST....