I want to retrieve the mikrotik PPPoE server service name list by using the mikrotik API and loop through all of the service names over a select menu. I have done the code myself. The code looks like below:
$ctype =$this->uri->segment('3');
if($ctype=='PPP')
{
if ($this->routerosapi->connect('1.1.1.1', 'xxx', 'xxx'))
{
$this->routerosapi->write('/interface/pppoe-server/getall');
$READ = $this->routerosapi->read(false);
$mktserver= $this->routerosapi->parseResponse($READ);
$this->routerosapi->disconnect();
}
}
elseif($ctype=='HSP')
{
if ($this->routerosapi->connect('xxx', 'xxx', 'xxx'))
{
$this->routerosapi->write('/ip/hotspot/server/getall');
$READ = $this->routerosapi->read(false);
$mktserver= $this->routerosapi->parseResponse($READ);
$this->routerosapi->disconnect();
}
}
<p>
<label for="simple-required">Server</label>
<select name="server" id="server" class="full-width">
<?php foreach($mktserver as $item):?>
<option value="<?php echo $item['service-name'];?>"><?php echo $item['service-name'];?></option>
<?php endforeach;?>
</select>
</p>
What am I doing wrong?
Note:
Please be specific on your answer. I don't want any basic answer. I want you to read the code very carefully and understand it and finally answer it. For your concern I want both list iteration of PPPoE and Hotspot of Mikrotik.