Hi people. I'm a total beginner trying to put together a small project, required to be done in MVC. I have a dropdown (in fact I have two, but I'm trying to tackle down this one first). This dropdown gets its options from the database (which I've managed to get it working just fine). So, the idea is to execute an sql query when the button is pressed... nothing fancy really, but since I have all this code scattered through all these files, it's just a mess altogether.
This is the code I have now related to this:
This function it's inside class TCars from cars.php file:
public function selectCitizen()
{
$this->abd->query("UPDATE car SET nCitizen = '1000' WHERE ID = (SELECT MIN(ID) FROM car)");
$this->abd->close_query();
}
This function it's in the class TControl, in the controller.php file:
public function selectCitizen($citizen)
{
echo "please work";
$citizen = new TCitizen("", "", "", "", "", $citizen, $this->host, $this->user, $this->pass, $this->db);
}
And this is the case for this particular submit button in view.php:
case "Rent":
if (isset($_POST["citizen"]))
{
$ciudadano = $_POST["citizen"];
$c = new TControl();
$res = $c->selectCitizen($citizen);
if ($res)
{
echo ('<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<body>
<center>
<h1>Selected Citizen succesfully: <br>'.$ciudadano.' <br></h1>
<br> <br>');
echo ($res);
echo ('<br><a href="index.html"> Back to index </a></center></body></html>');
}
else
{
showError("Citizen couldn't be selected: $ciudadano");
}
}
break;
The more I've managed until now has been to get showError to show, beyond that it's just a lot of undefined, fatal and warning errors, as expected. I'd really appreciate any insight on this.
Thank you for reading me.