문제

I have a table for users already created so for example I will run a query which will SELECT * FROM users WHERE accType='1' and I am looking to run a foreach loop on the results and put each result into this element

<div class="title-desc-wrap col-xs-12 col-md-8">
<div class="title-wrap "><h4><a href="LINK TO USERS PROFILE">User Name</a></h4></div> 
<div class="excerpt-wrap">PROFILE PICTURE</div>
</div>

I want to restrict the page to only show 8 users on each page. How would I go about structuring this foreach loop in PHP?

도움이 되었습니까?

해결책

Not too sure on foreach but for a for loop, if you are placing the results into an array, you could;

<?php
for($count = 0; $count < 8; $count++) {
$holder = $array_name['$count'];
echo "<a href=LINK TO USERS PROFILE>". $holder['userName'] ."</a>";
echo "<div class=excerpt-wrap>". $holder['ProfilePic'] ."</div>";
}

then for the next page;

<?php
for($count = 8; $count < 16; $count++) {
$holder = $array_name['$count'];
echo "<a href=LINK TO USERS PROFILE>". $holder['userName'] ."</a>";
echo "<div class=excerpt-wrap>". $holder['ProfilePic'] ."</div>";
}

and so on, bit basic but it should work.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top