-3
while($row=mysqli_fetch_assoc($result))
    { 
        echo "`<tr>`<tr>";
        echo "<td><a href="viewproject.php?q=$row['pid']">"$row['pname']"</a></td>";

    }

I tried echoing $row['pid'] in viewproject.php page using $_GET['q'].

However the above code generates the following error:

Parse error: syntax error, unexpected 'viewproject' (T_STRING), expecting ',' or ';'

Panda
  • 6,955
  • 6
  • 40
  • 55
ggss
  • 11

2 Answers2

1
while($row=mysqli_fetch_assoc($result))
    { 
        echo "`<tr>`<tr>";
        echo "<td><a href='viewproject.php?q=".$row['pid']."'>".$row['pname']."</a></td>";

    }

Here I have attached sample code in online editor. Click Here

You need to check string concatination in php. String Concatination Document

RJParikh
  • 4,096
  • 1
  • 19
  • 36
0
echo "<tr><tr>";
echo "<td><a href='viewproject.php?q='" . $row['pid'] . "'>" . $row['pname'] . "</a></td>";

You need to concat the string with the $_GET variables. Otherwise, the variables will be echoed literally, not the values.

Also, use single quotes for HTML element and double quotes for echo.

Panda
  • 6,955
  • 6
  • 40
  • 55