2011-08-09 3 views
0
나는 기능으로 내가 하나 하나 개의 항목을 사용하고 테이블을 가지고

하는 값 = 그 중 1 개 나머지 값은 = 0업데이트 및 제거

이 목록

<table cellspacing="0" cellpadding="0"> 
<form action="" method="POST"> 

<tr> 
    <th width="6%" >Featured</th> 
    <th width="35%">Job Title</th> 
    <th width="24%">Category</th> 
    <th width="15%">Location</th> 
    <th width="10%">Status</th> 
    <th width="10%">Action</th> 
</tr> 
<?php 
while($row = mysql_fetch_array($result)) 
{ 
?> 
<tr> 
    <td width="6%" align="center"> 
     <input type="radio" name="featured" value="<?php echo $row['job_id']; ?>" 
     <?php echo ($row['featured'] == 1?'checked':'')?>/> 
    </td> 
    <td width="35%"><?php echo $row['job_title']; ?></td> 
    <td width="24%"><?php echo $row['category_name'] ?></td> 
    <td width="15%"><?php echo $row['job_location']; ?></td> 
    <td width="10%"><?php echo $row['status'] ?></td> 
    <td width="10%"><a href="job_edit.php?id=<?php echo $row['job_id']; ?>">Edit</a></td> 
</tr> 
<?php 
} 
?> 
</tr> 
<tr class="box_foot"> 

    <td colspan='6'><div class="save_b"><input type="submit" class="button_save buttons" name="submit" value="Continue"></div></td> 
</form> 
</table> 
</div> 

I입니다 기능을 갖춘해야 할 값을 선택 = 그 나머지는

+4

질문에 대한 호흡을 기다리고 있습니다. –

+0

발견 된 솔루션 mysel ' /> ' 가이 '와 같은 실행 그 후 $ 제출 = $ _POST [ 'submit']; 경우가 { \t ($ 제출)을 ($ I = 0; $ I 횟수 ($가 _ POST는 [ '추천']) "; $ 난 ++) \t { \t $가 = $ _ POST는 [ '추천'] [$ 변경 나는]; \t mysql_query ("UPDATE 작업 SET 기능 = '0'"); \t \t $ sql = "UPDATE jobs SET 기능 = '1'WHERE job_id = '$ change'"; \t $ result1 = mysql_query ($ sql); \t} } – Muhammed

답변

2

만 featur 하나 개의 항목에 표 = 0 기능을해야 하나, 나는이처럼 $ already_featured 변수를 사용한다 :

<?php 
$already_featured = FALSE; 
while($row = mysql_fetch_array($result)) 
{ 
?> 
<tr> 
    <td width="6%" align="center"> 
     <input type="radio" name="featured" value="<?php echo $row['job_id']; ?>" 
     <?php if ($row['featured'] == 1 AND !$already_featured) {echo 'checked'; $already_featured = TRUE;} ?>/> 
관련 문제