Hi all,
I can't seem to get this loop working properly.
Here is the script:
It almost works except that the text input field and there values display 4 times (therefore if $total equaled 4 the results overall display 16 times over)
Any ideas how to get it to display the $total amount of times with the corresponding $category_id associated to it?
Cheers,
camcim
I can't seem to get this loop working properly.
Here is the script:
Code:
<?
$sql = "SELECT * FROM company_categories WHERE company_id='$id'";
$result = mysql_query($sql);
$total = mysql_num_rows($result);
while($row = mysql_fetch_array($result)){
$comp_cat_id = $row["comp_cat_id"];
$company_id = $row["company_id"];
$category_id = $row["category_id"];
$num = 1;
while ($num <= $total){
?>
<tr>
<td>
<input name="comp_cat_id<? echo $num ?>" type="hidden" value="<? echo $comp_cat_id ?>">
<input name="company_id<? echo $num ?>" type="hidden" value="<? echo $company_id ?>">
<input name="category_id<? echo $num ?>" type="text" size="16" maxlength="16" value="<? echo $category_id ?>">
</td>
</tr>
<?
$num++;
}
}
?>
It almost works except that the text input field and there values display 4 times (therefore if $total equaled 4 the results overall display 16 times over)
Any ideas how to get it to display the $total amount of times with the corresponding $category_id associated to it?
Cheers,
camcim