This might be one easy question.
I have this table:
bairro = neighborhood / preco = price
This is a reference table with prices.
I'm trying to print a table with the neighborhood and the price, but it's not happening as I'd like:
As you guys can see, each value is being printed 3 times!
The code is this:
function getInfo()
{
$this->sql = "SELECT * FROM deliverypricestable";
$this->query = $this->mysqli->query($this->sql);
while($this->result = $this->query->fetch_assoc())
{
foreach ($this->result as $key)
{
echo "<tr><td>".$this->result["bairro"]."</td>";//neighborhood
echo "<td>".$this->result["preco"]."</td></tr>";//price
}
}
I know this problem is probably related with the numbers of column on the deliverypricestable, but I'm just learning to code, and lil lost, please help me!