0

Please help me to fix the error. Parse error: syntax error, unexpected 'sonum' (T_STRING) in /aaa/dsearch.php on line 36

if(mysqli_num_rows($result) > 0)  
{  
    while($row = mysqli_fetch_array($result))
    {
        $output .= '
        <tr>  
            <td>'. $row["sonum"] .'</td>  
            <td>'. $row["regdate"] .'</td>  
            <td>'. $row["salesperson"] .'</td>  
            <td>'. $row["company"] .'</td>  
            <td>'. $row["status"] .'</td>
            <td>
            <a href="so.php?edit=<?php echo $row['sonum']; ?>" class="btn btn-info">Edit</a>
            <a href="process.php?delete=<?php echo $row['sonum']; ?>" class="btn btn-danger" onclick="return confirm('Are you sure you want to delete this item?');">Delete</a>
            </td>  
        </tr>
        ';
    }
}
0

1 Answer 1

0

You include PHP code inside PHP string value, not inside HTML text. For example, instead of

<a href="so.php?edit=<?php echo $row['sonum']; ?>" class="btn btn-info">Edit</a>

you should use:

<a href="so.php?edit=' . $row['sonum'] . '" class="btn btn-info">Edit</a>
2
  • Thank you for your advice. but I still have this error. Parse error: syntax error, unexpected 'Are' (T_STRING) in ...
    – John Jeong
    Commented Jan 5, 2020 at 9:14
  • this is another issue: you have to escape single quote, replace ' with \'
    – Anatoliy R
    Commented Jan 5, 2020 at 9:17

Not the answer you're looking for? Browse other questions tagged or ask your own question.