ameliabob Posted June 2, 2018 Share Posted June 2, 2018 I am building a table at a server and returning it to the user I have tried putting the $p where it is as shown. I have also tried it in the first <td $s =" <td ".$p.">><input type='radio' name='entry' ></td>"; It does not seem to get to GetFinishData(). Any thoughts or how can I get whatever failure to show up somewhere? $p = "onclick=\"GetFinishData('".$r[rowId]."')\""; $s =" <td>><input type='radio' name='entry' .$p.></td>"; Thanks Link to comment Share on other sites More sharing options...
dsonesuk Posted June 2, 2018 Share Posted June 2, 2018 You have not escaped html string with double quotes to insert $p PHP variable. Link to comment Share on other sites More sharing options...
ameliabob Posted June 3, 2018 Author Share Posted June 3, 2018 Would you mind modifying whichever string to fix this? Thanks Link to comment Share on other sites More sharing options...
dsonesuk Posted June 3, 2018 Share Posted June 3, 2018 Everything between double quotes will be treated as text string " <td>><input type='radio' name='entry' .$p.></td>"; You need to come out text string by exiting out from text string highlighted in red by enclosing within double quotes. " <td>><input type='radio' name='entry' .$p.></td>"; Now use your little grey cells to figure out where to place these end and start quotes to get "html text string" php code "html text string". Link to comment Share on other sites More sharing options...
ameliabob Posted June 4, 2018 Author Share Posted June 4, 2018 (edited) OK I tried to simplify the code but still can't get it to work. $s .= "<td"; $s .= " onclick=\"GetFinishedData('9')\" > "; $s .= $r[symbol]."</td>"; When I look at the generated code it looks like it should. Maybe I have run out of little grey cells. Edited June 4, 2018 by ameliabob The first line of code should be only $s = "<td"; Link to comment Share on other sites More sharing options...
iwato Posted June 4, 2018 Share Posted June 4, 2018 The term $r[symbol] looks like an unworkable mixture of PHP and Javascript. If $r is the name of a PHP array, then symbol must be enclosed in either single or double quotation marks. Also, what is present to cause the appearance of $r[symbol] to be read as the value of an element of a PHP array? Roddy Link to comment Share on other sites More sharing options...
ameliabob Posted June 4, 2018 Author Share Posted June 4, 2018 (edited) The whole function looks like this [code} $qry= "select * from holdings where 'pl' is not null order by 'symbol'ASC"; $result = mysqli_query($cxn,$qry) or die("ShowExit didn't work. ".mysqli_error($cxn)); if(mysqli_num_rows($result)==0){ $s = "alertThere are no entries in the database that meet your criteria. Try changing the search."; }else{ $s = "resp <table id='t01' border='1' >"; $s .= "<tr><th>Type</th><th>Symbol</th><th>Expire Month</th><th>Qty</th>"; $s .= "</tr>"; while($r=mysqli_fetch_array($result)){ $s .= "<td>".$r[nature]."</td>"; $s .= "<td"; $s .= " onclick=\"GetFinishedData('9')\" > "; $s .= $r[symbol]."</td>"; if($r[nature]=="O") $s .= "<td><center>".$r[expireMonth]."</td>"; else $s .= "<td><center>n/a</td>"; $s .= "<td>".$r[qty]."</td>"; $s .= "</tr>"; } $s .= "</table>"; echo($s); [/code] Edited June 4, 2018 by ameliabob Link to comment Share on other sites More sharing options...
iwato Posted June 4, 2018 Share Posted June 4, 2018 When referring to the name of an element in an associative array you must learn to enclose the name of the element in either single or double quotation marks. Incorrect: $r[nature] Correct: $r['nature'] Roddy Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now