Click here to Skip to main content
15,886,788 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

Im beginner of Php.

I connect the database and fetch the data it's returning fine.
here I created table with Link buttons through php but it's giving syntax error in update
I don't know where I went wrong.
So, Can anyone solve this?

here my php code is

PHP
<?php

mysql_connect("localhost","root","") or die(mysql_error());
mysql_select_db("Sample") or die(mysql_error());
$result = mysql_query("Select * from Test_Table") or die(mysql_error());

echo "<table border=\"1\" align=\"1\">";
echo "<tr><th>Test Name </th>";
echo "<th> Test Description </th>";
echo "<th> Test Phone Number </th>";
echo "<th> Insert </th>";
echo "<th> Edit </th>";
echo "<th> Delete </th></tr>";
while($row=mysql_fetch_array($result))
{
    echo "<tr><td>";
    echo $row['TestName'];
    echo "</td>";
    echo "<td>";
    echo $row['TestDescription'];
    echo "</td>";
    echo "<td>";
    echo $row['TestPhoneNo'];
    echo "</td>";
    echo "<td>";
    echo "<a href='Insert.php'>Insert</a>";
    echo "</td>";
    echo "<td>";
    echo "<a href="Update.php?Updates=$row['TestId']">Update</a>";
    echo "</td>";
    echo "<a href="Delete.php?id=$row['TestId']">Delete</a>";
    echo "</td></tr>";
}
echo "</table>"

?>
Posted
Comments
Nirav Prabtani 3-Jul-13 3:25am    
where is update.php ???
U@007 3-Jul-13 3:33am    
when i click on Update link button Im redirected to another page with selected id that is Update.php
Nirav Prabtani 3-Jul-13 3:46am    
ya but i said where is the coding of update.php??

1 solution

You should break your echo commands into multiple parts.
For ex:
echo "<a href="Update.php?Updates=$row['TestId']">Update</a>";

-->
echo '<a href="Update.php?Updates='.$row['TestId'].'>Update</a>';

Do similarly to Delete.
 
Share this answer
 
v2
Comments
U@007 3-Jul-13 6:05am    
hi thanh,

thank you it's working fine
:) 5+

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900