0

I've a table with multiple rows containing a button tag which opens a modal.

I want to pass the row id as I want to run a PHP script to select some values from a MySQL table.

Here is my button tag code:

echo "<button type=\"button\" class=\"btn btn-info btn-sm\" data 
toggle=\"modal\" data-target=\"#info<?php echo $row['0'];?>\">";
                echo "Info"; echo"</button>";
                echo "</td>";

And below is my modal tag code:

<!-- Modal -->
<div class="modal fade" id="info<?php echo $row['0'];?>" role="dialog">
    <div class="modal-dialog modal-lg">

    <!-- Modal content-->
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">&times;</button>
            <h4 class="modal-title">Replica Table </h4>
        </div>
    <div class="modal-body">
        <p><b>Device name:</b>XYZ<br><br>
            <b>Manufecturer name:</b>XYZ<br><br>
            <b>Total no:</b>12<br><br>
            <b>sold no:</b>12<br>
            <br><br>
            <table>
                <tr>
                    <th><?php echo $row['0'] ?>;</th>
                    <th><?php echo $row['0'] ?></th>
                    <th>IP Address</th>
                    <th>GPS</th>
                    <th>SOLD/AVAILABLE</th>
                    <th>Status</th>
                    <th>key</th>
                </tr>

I get the error below:

Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in

nyedidikeke
  • 6,899
  • 7
  • 44
  • 59
Osama Bin Saleem
  • 779
  • 1
  • 12
  • 24

2 Answers2

1

No need to write the PHP tag inside echo. Try with below code if it works for you.

echo "<button type=\"button\" class=\"btn btn-info btn-sm\" data-toggle=\"modal\" data-target=\"#info".$row['0']."\">";
            echo "Info"; 
            echo"</button>";
            echo "</td>";
shubhangee
  • 529
  • 3
  • 10
1

try this:

echo "<button type=\"button\" class=\"btn btn-info btn-sm\" data-toggle=\"modal\" data-target=\"#info".$row['0']."\">";
echo "Info";
echo"</button>";
echo "</td>";
nyedidikeke
  • 6,899
  • 7
  • 44
  • 59