Thursday, 15 September 2011

javascript - Remove commas from php array -



javascript - Remove commas from php array -

i'm working on displaying arrays using php , mysql.

simplified code looks this:

$sql = "select * workorder"; $result = mysqli_query($dbc3,$sql); $tryout_reports = array(); while ( $row = mysqli_fetch_assoc($result) ) { $tryout_reports[] = $row['file_name'] . "<br />"; } $detail_report['tryout_reports'] = $tryout_reports;

i took lot out of sql here, if there's wrong in there please don't mind. sql statement works fine.

the problem it's beingness outputted commas separating each value, , it's looking real bad.

the html on page when run looks this:

file1.pdf <br> "," file2.pdf <br> "," etc..

now, i've looked around quite bit , i've tried following:

ltrim() rtrim() explode() str_replace()

i know rtrim works, doesn't remove commas. tried like:

$tryout_reports[] = rtrim($row['file_name'],"pdf");

and took pdf out of end of each one, when replace "pdf" "," nothing.

feeling stuck, help appreciated!

thanks

edit: forgot add, page uses info , displays on page has this:

table.append("<tr><th>tryout reports </th><td>" + data[0].tryout_reports + "</td></tr>");

that within of jquery function runs when job number clicked display additional information.

that comma comes javascript because parse straight array. can utilize join: w3schools.com/jsref/jsref_join.asp

javascript php mysql arrays

No comments:

Post a Comment