0

After adding this code:

<?php
    foreach($emp as $empdata){
    echo "<tr><td>".$empdata[emp_id]."</td><td>"."<a href="?>edit.php?emp_id=<?php echo $empdata[emp_id] ">".$empdata[emp_name]."</a></td></tr>";
    } ?>

I get this:

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /home/kumar/public_html/amsConcrete/single_pages/employee/show_employee.php on line 23 

Any suggestions? Please

0

3 Answers 3

2

It looks like something went a little funny in the middle of your output:

$empdata[emp_id]."</td><td><a href='edit.php?emp_id=".$empdata[emp_id]."'>".$empdata[emp_name]."</a></td></tr>";

I think this should do the trick though.

You don't need to run echo inside the string (in fact it's a bad thing). You can however just use the variables as they are - which you did for part of it, but not the other part.

Sign up to request clarification or add additional context in comments.

2 Comments

@RC Yeah, noticed (and fixed that) and also got rid of a silly looking concat that served no purpose as well. Cheers!
What about array keys without quotes? They are constants or what?
0

Try This. It should be work

<?php
    foreach($emp as $empdata){
    echo "<tr><td>".$empdata[emp_id]."</td><td><a href='edit.php?emp_id=". $empdata[emp_id]. "'>".$empdata[emp_name]."</a></td></tr>";
    } ?>

Comments

0
//This is more easier format 
<?php
    foreach($emp as $empdata){
?>
    <tr>
        <td><?php echo $empdata['emp_id'] ?></td>
        <td><a href='edit.php?emp_id=<?php echo $empdata["emp_id"] ?>'><?php echo $empdata['emp_name'] ?></a></td>
    </tr>    

<?php  } ?>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.