I'm currently working on displaying some arrays using PHP and MySQL.
Simplified code looks like this:
$sql = "SELECT * FROM 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 a lot out of the SQL here, so if there's something wrong in there please don't mind. The SQL statement works fine.
The problem is it's being outputted with commas separating each value, and it's looking real bad.
The HTML on the page when run looks something like this:
File1.pdf <br>
","
File2.pdf <br>
","
etc..
Now, I've looked around quite a bit and i've tried the following:
ltrim()
rtrim()
explode()
str_replace()
I know rtrim works, but it doesn't remove the commas. I tried something like:
$tryout_reports[] = rtrim($row['file_name'],"pdf");
And it took the pdf out of the end of each one, but when I replace "pdf" with "," it does nothing.
Feeling really stuck, any help would be really appreciated!
Thanks
EDIT: Forgot to add, the page that uses this data and displays it on the page has this:
table.append("<tr><th>Tryout Reports </th><td>" + data[0].tryout_reports + "</td></tr>");
That is inside of a jQuery function which runs when a job number is clicked to display additional information.