I'm fetching data from a website with Json Objects and I will show it in table as the last images (check it bottom) but I'm really complicated with luckNumber and productName because I will create 5 column for this table and insert value to each Draw types.
Here is Json data
object(stdClass)[5]
public 'luckNumber' => string '78087' (length=5)
public 'productJson' =>
object(stdClass)[4]
public 'luckDrawDesc' => string 'DRAW3' (length=5)
public 'validPeriod' => int 2
public 'productName' => string 'DRAW3' (length=5)
object(stdClass)[5]
public 'luckNumber' => string '78087' (length=5)
public 'productJson' =>
object(stdClass)[4]
public 'luckDrawDesc' => string 'DRAW4' (length=5)
public 'validPeriod' => int 2
public 'productName' => string 'DRAW4' (length=5)
object(stdClass)[5]
public 'luckNumber' => string '78087' (length=5)
public 'productJson' =>
object(stdClass)[4]
public 'luckDrawDesc' => string 'DRAW3' (length=5)
public 'validPeriod' => int 2
public 'productName' => string 'DRAW3' (length=5)
object(stdClass)[3]
public 'luckNumber' => string '78087' (length=5)
public 'productJson' =>
object(stdClass)[2]
public 'luckDrawDesc' => string 'DRAW2' (length=5)
public 'validPeriod' => int 2
public 'productName' => string 'DRAW2' (length=5)
object(stdClass)[1]
public 'luckNumber' => string '78087' (length=5)
public 'productJson' =>
object(stdClass)[0]
public 'luckDrawDesc' => string 'DRAW1' (length=5)
public 'validPeriod' => int 2
public 'productName' => string 'DRAW1' (length=5)
This is PHP function to select all that data and generate tables
Function description:
luckNumber Contain a defference value depend on productName (DRAW1,DRAW2,DRAW3,DRAW14).
public function det_data() {
$c_arr = json_decode($this->urlData);
$i = 0;
$html = '<table>';
$html .= '<thead>';
$html .= '<th>Date</th>';
$html .= '<th>Draw1</th>';
$html .= '<th>Draw2</th>';
$html .= '<th>Draw3</th>';
$html .= '<th>Draw4</th>';
$html .= '</thead>';
$html .='<tbody>';
foreach ($c_arr as $items) {
if ($i == 30)
break;
{
$html .= '<tr>';
if ($items->productName =='DRAW1') {
$html .= '<td>' . $items->createTime . '</td>';
$html .= '<td>' . $items->luckNumber . '</td>';
}
if ($items->productName =='DRAW2') {
$html .= '<td>' . $items->luckNumber. '</td>';
}
if ($items->productName =='DRAW3') {
$html .= '<td>' . $items->luckNumber. '</td>';
}
if ($items->productName =='DRAW4') {
$html .= '<td>' . $items->luckNumber. '</td>';
}
$html .= '</tr>';
$i++;
}
}
$html .='</tbody>';
$html .= '</table>';
return $html;
}
The result that I want to get 78087 This number for example only