-3

第6行有错误。这个profile.php文件可以请任何人帮助我

<?php
require_once('../connect.php');

$id = $_GET['id']; //getting the param

$row = mysql_fetch_array(mysql_query("SELECT * FROM student WHERE roll_no =" . $id));
//echo $id;
echo "<div class='profile'><h4>Student Profile</h4><h5>Name: </h5><p>" . $row['name'] . "</p>";
echo "<h5>Roll no: </h5><p>" . $row['roll_no'] . "</p>";
echo "<h5>Program: </h5><p>" . $row['program'] . "</p>";
echo "<h5>Branch: </h5><p>" . $row['branch'] . "</p>";       
echo "<h5>Agg. marks: </h5><p>" . $row['agg_marks'] . "</p>";
echo "<h5>Phone no. </h5><p>" . $row['phone'] ."</p>";
echo "<img src='imgsize.php?w=100&h=100&img=ajax/img_student/" . $row['roll_no'] ."." . $row['imgext'] . "'" . "width =100 height = 100 /></div>";

?>

4

2 回答 2

0

您在某些行有语法错误,这是更正的答案。认为你和我一样是初学者。

<?php
require_once('../connect.php');

$id = $_GET['id']; //getting the param

$row = mysql_fetch_array(mysql_query("SELECT * FROM student WHERE roll_no ='". $id."'     
"));
//echo $id;
echo "<div class='profile'><h4>Student Profile</h4><h5>Name: </h5><p>" . $row['name'] .     
"</p>";
echo "<h5>Roll no: </h5><p>" . $row['roll_no'] . "</p>";
echo "<h5>Program: </h5><p>" . $row['program'] . "</p>";
echo "<h5>Branch: </h5><p>" . $row['branch'] . "</p>";       
echo "<h5>Agg. marks: </h5><p>" . $row['agg_marks'] . "</p>";
echo "<h5>Phone no. </h5><p>" . $row['phone'] ."</p>";
echo "<img src='imgsize.php?w=100&h=100&img=ajax/img_student/" . $row['roll_no'] ."." .    
$row['imgext'] . "'" . "width =100 height = 100 /></div>";

?>
于 2013-09-30T10:35:33.727 回答
0

更改您的代码:

$sql="SELECT * FROM student WHERE roll_no =" . $id;
$result =mysql_query($sql);

while($row =mysql_fetch_array($result))
{
    print_r($row);
}

代替

$row = mysql_fetch_array(mysql_query("SELECT * FROM student WHERE roll_no =" . $id));
于 2013-09-30T10:35:39.913 回答