vjmehra Posted March 24, 2013 Share Posted March 24, 2013 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.... Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted March 24, 2013 Share Posted March 24, 2013 the symptom is that of a variable being reused. since you have posted a book-load of double-spaced code, it would help if you identified which variable name you are var_dump'ing and in which piece of code it is to pin down where to even start looking. without knowing which variable you are talking about, the only apparent problem is you have an extra </form> tag at the end of the select_issue.php code file that is messing with all the forms being output in that file. Quote Link to comment Share on other sites More sharing options...
vjmehra Posted March 24, 2013 Author Share Posted March 24, 2013 Ooops! The variable is $issueid Sorry, I thought it would be better to post all the code, rather than leave gaps :-( Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted March 24, 2013 Share Posted March 24, 2013 (edited) and in which file? i've looked at some of the code more and you have nested form tags that are invalid. the first opening form tag is what will be submitted to, so I don't even think your form is submitting to the file you think it is. you need to clean up all your code and validate the resulting html. there's problems with form tags and table tr/td tags. i also see one = sign in an if() test that is assiging a value instead of comparing a value. Edited March 24, 2013 by mac_gyver Quote Link to comment Share on other sites More sharing options...
vjmehra Posted March 24, 2013 Author Share Posted March 24, 2013 By clicking the button in reduced_view_issues.php this then fires the script select_issue3.php, which runs an if statement and for this particular case, then fires select_issue.php. This all works correctly, otherwise it wouldn't work for rows 2 onwards surely? I have multiple <form> tags per page, this is because each row needs to be submitted on a button click, so there are multiple tags by design, however I hadn't noticed up until now that row 1 never worked! Quote Link to comment Share on other sites More sharing options...
vjmehra Posted March 24, 2013 Author Share Posted March 24, 2013 I'm sure the clue is in the var_dump....but I can't work out how to interpret what it is saying! Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted March 24, 2013 Share Posted March 24, 2013 nested forms are invalid. you need to fix that before you can fix anything else your code might be doing. to help yourself and anyone else you might be asking to help you, you should also elimiate all the commneted out code and since you are creating a database connection in the functions.php file, elimiate the variables and connections you also creating in the individual files. Quote Link to comment Share on other sites More sharing options...
vjmehra Posted March 24, 2013 Author Share Posted March 24, 2013 Sorry just to ensure I understand what you are saying...when you say nested forms are invalid, you mean: <form> <form> Code </form> </form> Is invalid? But the following: <form> Code </form> <form> Code </form> Is okay? I tried removing the nesting, but the same result occurs. I still don't understand why if this shouldn't work at all, why it would work for rows 2 onwards. That aside, I will tidy up the code and re-post, but I can't remove the multiple <form> tags completely, as otherwise nothing will work! Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted March 25, 2013 Share Posted March 25, 2013 Ooops! The variable is $issueid Sorry, I thought it would be better to post all the code, rather than leave gaps :-( there's only one $issueid variable in the posted code, in some commented out code. its not an array. it cannot be what your var_dump output is from. you also never stated in which code the var_dump output is being done at. the very first piece of posted code isn't identified either. i'm guessing its reduced_view_issues.php. if that's the case, your select_issue3.php file is producing more invalid html, with two complete html documents in it. the issue isn't all the code, it's that you haven't provided accurate information about the code and the problem that pins down where to look in it. why if this shouldn't work at all, i'm guessing the above statement is referring to the nested form tags? no one said they wouldn't do anything, they will - the first opening form tag is what will be submitted to in the very first piece of posted code, you have an initial form tag with action=reduced_view_issues.php. all the other opening form tags inside of that form tag, at least up to the first closing </form> tag (which just might be why your first row doesn't work) will be ignored and any (at least the first one) of the submit buttons should submit to reduced_view_issues.php instead of select_issue3.php. Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted March 25, 2013 Share Posted March 25, 2013 as a continuation of the above reply - i just duplicated your var_dump of the $_POST output. after hitting the submit button on the first row - array(11) { ["ddsub_sector_id"]=> string(0) "" ["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(0) "" } ["issueid"]=> array(1) { [0]=> string(0) "" } } after hitting the submit button on the 2nd row - array(2) { ["bonddescription"]=> array(1) { [0]=> string(0) "" } ["issueid"]=> array(1) { [0]=> string(0) "" } } this is due to the mess of nested form tags. TAKE A LOOK AT THE URL IN YOUR BROWSER'S ADDRESS BAR when you submit the first and other row's forms. you will see that the first row submits to reduced_view_issues.php. the remainder of the rows submit to select_issue3.php you need to make sure that the html you produce is valid and it wouldn't hurt to learn some css so that you can clean up and reduce all the styling in the markup. Quote Link to comment Share on other sites More sharing options...
Solution vjmehra Posted March 25, 2013 Author Solution Share Posted March 25, 2013 The <form></form> tags were indeed causing the issue! Thanks for that, I didn't realise you couldn't nest them. In-fact, I actually thought that is what I had to do (initially) in this instance, so I appreciate you're help and also I've learnt something, so all good :-) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.