skip to Main Content

I’m trying to add an edit button to this table, the table is in html as is the button, the data is been taken out of phpmyadmin.
The error i get is: syntax error, unexpected token "class", expecting "," or ";" in the line before $valor[accID].
This is my code:

<?php 

    $data = array();
    $data = popularCustomerTable();
      foreach($data AS $row => $valor){
       echo "<tr>
        <td> "<a class= "address-book-edit btn--e-transparent-platinum-b-2"; href="dashboard-customer-edit.php">Edit</a> "</td>
        <td>".$valor["accID"]."</td>
        <td>".$valor["cusName"]."</td> 
        <td>".$valor["cusEmail"]."</td> 
        <td>".$valor["cPass"]."</td> 
        <td>".$valor["cPhone"]."</td> 
        <td>".$valor["cusMailAddress"]."</td> 
        <td>".$valor["cusBillAddress"]."</td> 
        <td>".$valor["cusCity"]."</td>
        <td>".$valor["cusSate"]."</td> 
        <td>".$valor["cusCountry"]."</td> 
        <td>".$valor["cusZipCode"]."</td> 
        <td>".$valor["cusStatus"]."</td>  
        </tr>";
      }                                                                   
 ?>

2

Answers


  1. try this for the quotes:

    echo "<tr>
        <td> <a class= 'address-book-edit btn--e-transparent-platinum-b-2' href='dashboard-customer-edit.php'>Edit</a></td>
        <td>".$valor['accID']."</td>
        <td>".$valor['cusName']."</td> 
        <td>".$valor['cusEmail']."</td> 
        <td>".$valor['cPass']."</td> 
        <td>".$valor['cPhone']."</td> 
        <td>".$valor['cusMailAddress']."</td> 
        <td>".$valor['cusBillAddress']."</td> 
        <td>".$valor['cusCity']."</td>
        <td>".$valor['cusSate']."</td> 
        <td>".$valor['cusCountry']."</td> 
        <td>".$valor['cusZipCode']."</td> 
        <td>".$valor['cusStatus']."</td>  
        </tr>";
    
    Login or Signup to reply.
  2. You can do it this way:

    <?php 
    
        $data = array();
        $data = popularCustomerTable();
        foreach($data AS $row => $valor):
    ?>
            <tr>
            <td>
                 <a class= "address-book-edit btn--e-transparent-platinum-b-2"
                   href="dashboard-customer-edit.php?id=<?php echo $valor["accID"]; ?>">Edit
                 </a>
            </td> <!-- I added a an ID identifier to the link -->
            <td>"<?php echo $valor["accID"] ?>"</td>
            <td>"<?php echo $valor["cusName"] ?>"</td> 
            <td>"<?php echo $valor["cusEmail"] ?>"</td>
            <td>"<?= $valor["cPhone"] ?>"</td> <!-- Or use this way-->
            ....
            </tr>"
    <?php endforeach; ?>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search