php-mysql页面上没有显示[关闭]

Hi the following is not sowing any thing on the webpage. Where I went wrong?

The following is a link to profile.php
?>
<a href="profile.php?id=<?php echo $id ?>"><?php echo $id;?></a>
<?PHP

======================================= This is the linked php file profile.php

<html>

<body bgcolor='#4c5865'>

<p style="position: absolute ; top: 0; text-align: left><font face="geneva" size='1' color="#ccc"><a href="cbs.php" ><b><font color="white">Home</font></p></a>
<?php

include("db1.php");
$id=$_GET['id'];

$result = $mysql_query ("select agt,dvd FROM agttot where agt='$id'");

// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
$ac =$row[0];
$dc =$row[1];
$bc =$row[2];

 //   echo "<tr bgcolor='#a9a9a9'><td align='right'>";
    print $ac;
 //   echo "</td><td align='right'><b>"; 
    print $dc;
}
?>
</body>
</html>

You didn't add ; after $id in this line:

<a href="profile.php?id=<?php echo $id ?>"><?php echo $id;?></a>

mysql_query() is a function (also don't use mysql_* functions anymore, they're deprecated!) so it shouldn't be called with a $ in front here:

$result = $mysql_query ("select agt,dvd FROM agttot where agt='$id'");

You should be escaping the '$id' before it gets put into your SQL.

Your mysql_query contains an extra $, before the function name:

$result = **$**mysql_query ("select agt,dvd FROM agttot where agt='$id'"); 

should be

$result = mysql_query ("select agt,dvd FROM agttot where agt='$id'"); 

PS, avoid the mysql_ set of functions, they are/will be deprecated very soon. Use mysqli_ or PDO.

I'm not 100% sure what your problem is. There are a few area in question I'd check:

  1. Is $id set? Does it have an integer value?

  2. Syntax error here:

    <a href="profile.php?id=<?php echo $id ?>"><?php echo $id;?></a>
    

    need a semi-colon (;) column 39. (not 100% sure if needed in this case but always be sure)

  3. Is there records in the database?

  4. Where is the connection sequence?

  5. Have you selected a database?

  6. Should you still be using mySQL?

Seeing as mySQL is now depreciated here is a mySQLi example (procedural):

$con=new mysqli_connect('location','user','password','database');
$query=mysqli_prepare('SELECT agt,dvd FROM agttot WHERE agt=?',$con);
mysqli_stmt_bind_param(, $query, 'i', intval($_GET['id']));
mysqli_stmt_execute($query);
mysqli_stmt_bind_result($query,$agt,$dvd);

while(mysqli_stmt_fetch($query)){
    $result[]='<tr><td>'.$agt.'</td><td>'.$dvd.'</td></tr>';
}

mysqli_stmt_close($query);
mysqli_close($con);

echo(isset($result))?$result:$_GET['id'].' < is this a valid record?';

try this

   <html>

  <body bgcolor='#4c5865'>

  <p style="position: absolute ; top: 0; text-align: left><font face="geneva" size='1' color="#ccc"><a href="cbs.php" ><b><font color="white">Home</font></p></a>
 <?php

 include("db1.php");
 $id=$_GET['id'];

$result = $mysql_query ("select agt,dvd FROM agttot where agt='$id'");

// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
$ac =$row['agt'];
$dc =$row['dvd'];  // you dont have to make numbers here but the column names as it saids in your query
$bc =$row[2];    // you dont have to make numbers here but the column names as it saids in your query

//   echo "<tr bgcolor='#a9a9a9'><td align='right'>";
echo $ac.'<br />';
//   echo "</td><td align='right'><b>"; 
echo  $dc.'<br />';
}
?>
</body>
</html>