0

I do not know what the best option in my case is:

I use a SQL query (built into a php file) to feed na excel chart.

PROBLEM: My first column is made of complex serial numbers (such as 08/18), when excel updates the query, these numbers are automatically transformed into August/18.

BEST SOLUTION (That I can think of):

Edit php file to place a ' before the serial number, that way, when excel updates, it won´t transform into date (I think...)

How can I achieve this?

This is my code:

  <? while($sql1_recset = mysql_fetch_array($sql1)) {?>
    <tr>
    <td><?=$sql1_recset['ID'];?></td>
</tr>
<?}?>
</table>
</body>
</html>

I tried a few things, but I do not get PHP:

 <td><?{echo("'").echo($sql1_recset['ID']);?}></td>

doesn´t work

<td><?{echo("'")}&=$sql1_recset['ID'];?></td>

doesn´t work

 <td><?{echo("'")&$sql1_recset['ID'];?></td>

doesn´t work

ROCA
  • 81
  • 8

1 Answers1

0

You can concatenate strings in php using .. Have a read of the PHP docs for string operators.

You've tried two different things so to make this semi-worth the answer, I've included the corrected way of doing both:

  1. <td><?="'" . $sql1_recset['ID'];?></td> - <?= is the shorthand for echo, available by default since PHP 5.4
  2. <td><? echo "'" . $sql1_recset['ID']; ?></td>
frobinsonj
  • 1,109
  • 9
  • 21