سلام این کد رو در قالب حلقه while پیاده سازی کردم که دوستان در کنار حلقه foreach این سینتکس از کد رو هم داشته باشن (صرفا جهت کمک)
کدهای html , php
html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>Products Table [PHP]title>
head>
<body>
$users = [
[
'id'=>1,
'proname'=>'Iphone 13 pro max',
'price'=>43000000,
'cusname'=>'Mohammad Hossein',
'cusfamily'=>'Hjian'
],
[
'id'=>2,
'proname'=>'Iphone 13 pro',
'price'=>40000000,
'cusname'=>'Mohammad Javad',
'cusfamily'=>'Hjian'
],
[
'id'=>3,
'proname'=>'Iphone 12',
'price'=>35000000,
'cusname'=>'Mehdi',
'cusfamily'=>'Hjian'
],
[
'id'=>4,
'proname'=>'Iphone 8',
'price'=>12000000,
'cusname'=>'Amir Ali',
'cusfamily'=>'Nabavian'
],
]
?>
<section class="table">
<div class="headings">
<div>Product ID
کدهای مربوط به style
---------------------------
body{
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.table{
width: 80%;
padding: 10px;
border-radius: 10px;
box-shadow: 0px 0px 10px #e2e2e2;
background-color: #fff;
border: 1px solid #e2e2e2;
}
.headings{
display: flex;
justify-content: space-between;
font-size: 17px;
font-weight: bold;
font-family: Arial, Helvetica, sans-serif;
border-bottom: 1px solid #e2e2e2;
padding-bottom: 10px;
align-items: center;
margin-bottom: 10px;
}
.headings div{
width: 20%;
padding-left: 3px;
}
.products{
display: flex;
justify-content: space-between;
font-size: 14px;
font-family: Arial, Helvetica, sans-serif;
margin-bottom: 10px;
border-bottom: 1px solid #e2e2e2;
padding-bottom: 10px;
}
.products div{
width: 20%;
border: 1px solid #e2e2e2 ;
padding-left: 3px;
padding: 10px;
border-radius: 5px;
margin-right: 5px;
cursor: pointer;
}
.products div:last-child{
margin-right:0;
}