My code below is returning the results twice. Not like a,b,c,a,b,c but a,a,b,b,c,c. Any ideas?
Code: Select all
<?php
class NewProject{
protected $pid;
protected $query;
protected $errorMsg="";
public function __construct(){
$this->pid=$_GET['id'];
}
public function projectQuery(){
$this->query="SELECT project_id, project_name, project_des
FROM project
WHERE project_id='$this->pid'";
return $this->query;
}
public function queryResults(){
$result=mysql_query($this->query) or die (mysql_error());
if($result){
$row=mysql_fetch_array($result);
}else{
$this->errorMsg="Sorry, this project does not exist";
}
return $row;
}
}
//Test Class
$project=new NewProject();
$project->projectQuery();
$thing=$project->queryResults();
foreach ($thing as $key => $value) {
echo $value."<br />";
}
?>