저는이 등급의 코드를 사용하여 별표 평가 시스템의 데이터베이스에있는 ID의 수와 같습니다.PHP foreach 에코 문제
이 코드는 나는 각각의 ID에 대해 투표 한 5 성을 생성하지만, 문제는 div에서 특별히 생성해야하는 반면 div에서 모두 생성한다는 것입니다. 이제 내가있어 각각의 안주인에 대한 DIV 정보에 인쇄 가정하자, 내가 다음 코드를 사용하여 자신의 사진과 이름 출력 : 이제
$sql =" select * from hostess";
$query = mysql_query($sql);
while ($row = mysql_fetch_array($query)) {
echo "<div id='photo'>";
echo "<div id='picture'>";
echo "<div id='scotch'><img src='images/Scotch.png'></div>";
echo "<td> <img src=foto/photo1/".$row['photo'] . "></td>";
echo "</div>";
echo "<div id='text'>";
echo '<td><a href="hostess.php?id='.$row['id'].'">'. $row['first_name_en']." ". $row['family_name_en']."</a></td>";
echo "</div>";
echo "</div>";
echo "<div id='photo2'>";
echo "<div id='picture'>";
echo "<div id='notes'>";
echo '<form action="index.php" method="post" >';
echo "<label>Notes</label></br><textarea>".$row['courrent_occupation'] . "</textarea></br>";
echo '<input type="submit" value="edit" name="edit"></div>';
echo "</div>";
echo "<div id='notes'>";
echo "<label>profile</label></br><textarea>".$row['profile_en'] . "</textarea>";
echo "</div>";
echo "</div>";
}
?>
</div>
을, 나는 나를 생성이 다른 PHP있어 모든 모든 여주인 ID의 별표 평점
<?php
// include update.php
include_once 'update.php';
// get all data from tabel
$arr_star = fetchStar();
?>
<?php
// start looping datas
foreach($arr_star as $star){ ?>
<h2>Star Rater - <?php echo $star['id'];?></h2>
<ul class='star-rating' id="star-rating-<?php echo $star['id'];?>">
<?php /* getRating($id) is to generate current rating */?>
<li class="current-rating" id="current-rating-<?php echo $star['id'];?>" style="width:<?php echo getRating($star['id'])?>%"><!-- will show current rating --></li>
<?php
/* we need to generate 'id' for star rating.. this 'id' will identify which data to execute */
/* we will pass it in ajax later */
?>
<span class="ratelinks" id="<?php echo $star['id'];?>">
<li><a href="javascript:void(0)" title="1 star out of 5" class="one-star">1</a></li>
<li><a href="javascript:void(0)" title="1 star and a half out of 5" class="one-star-half">1.5</a></li>
<li><a href="javascript:void(0)" title="2 stars out of 5" class="two-stars">2</a></li>
<li><a href="javascript:void(0)" title="2 star and a half out of 5" class="two-star-half">2.5</a></li>
<li><a href="javascript:void(0)" title="3 stars out of 5" class="three-stars">3</a></li>
<li><a href="javascript:void(0)" title="3 star and a half out of 5" class="three-star-half">3.5</a></li>
<li><a href="javascript:void(0)" title="4 stars out of 5" class="four-stars">4</a></li>
<li><a href="javascript:void(0)" title="4 star and a half out of 5" class="four-star-half">4.5</a></li>
<li><a href="javascript:void(0)" title="5 stars out of 5" class="five-stars">5</a></li>
</span>
</ul>
<?php } ?>
내가 필요한 것은 각 호스트 프로필에 시스템 등급을 인쇄하는 것입니다. 첫 번째 스크립트 안에 foreach를 삽입하려고 시도하지만 모든 프로필이 아니라 하나의 프로필 만 표시합니다.
fetchstar() 코드는 다음과 같습니다
는function fetchStar(){
$sql = "select * from `hostess`";
[email protected]_query($sql);
while($rs = @mysql_fetch_array($result,MYSQL_ASSOC)){
$arr_data[] = $rs;
}
return $arr_data;
}
에 대한 중첩 사용하는 것이 당신이 할 수 있도록, 다음 오류가 억제되지 않습니다 무슨 일이 일어나는지 보아라. – Brad
똑같은 코드를 http://stackoverflow.com/q/11331423/687262와 똑같은 코드로 게시하면 똑같은 코드를 게시 할 수 없습니다. – BugFinder
안녕하세요 Bugfinder, 죄송합니다. , 그것은 동일한 코드입니다! –