Forum Moderators: coopster
$id=mysql_result($result,$i,"id");
$name=mysql_result($result,$i,"name");
$phone=mysql_result($result,$i,"phone");
$email=mysql_result($result,$i,"email");
?>
<td width="6025" rowspan="3" align="left"><p class="style1">Target:
<select name="select">
<? echo "<option value='$id'>$name</option>";?> <--------(want to add option here)
</select>
<td width="6025" rowspan="3" align="left"><p class="style1"Delete Target:
<select name="select">
<? echo "<option value='$id'>$name</option>";?> <--------(want to add option here)
</select>
##end of code
Lets say with every line of results I draw out from MySQL and processed into variables with PHP.
How can I actively add a '<option value ='$id'> $name </option>' in the 2 places I want to everytime the loop hooks up?
I tried the above code which I written but it even loops echoes the HTML text. How can I skip the 2nd part of the HTML text?
Errors:
You left td, p unclosed.
Small fixes is there in between. The code is as follows:
<td width="6025" rowspan="3" align="left">
<p class="style1">
Target:
<select name="select">
<?php echo "<option value='$id'>$name</option>";?>
</select>
</p>
</td>
<td width="6025" rowspan="3" align="left">
<p class="style1">
Delete Target:
<select name="select">
<?php echo "<option value='$id'>$name</option>";?>
</select>
</p>
</td>
Habtom
?>
<td width="6025" rowspan="3" align="left"><p class="style1">Target:
<select name="select">
<? echo "<option value='$id'>$name</option>";?> <--------(want to add option here)
</select>
<td width="6025" rowspan="3" align="left"><p class="style1"Delete Target:
<select name="select">
<? echo "<option value='$id'>$name</option>";?> <--------(want to add option here)
</select>
<?
$i++;
}
?>
##end of code
Sorry this should be the actual code. During the $i++ which helps to move the loop, the php works well.. yes. It loops till all the <option> $names </option> are out. But it also loops and echos the <select name="select"> many time.
How can I bypass the HTML echoing? Sorry for the misunderstanding
<td width="6025" rowspan="3" align="left">
<p class="style1">
Target:
<select name="select">
<?
$i=0;
while ($i < $num) {
$id=mysql_result($result,$i,"id");
$name=mysql_result($result,$i,"name");
$phone=mysql_result($result,$i,"phone");
$email=mysql_result($result,$i,"email");
?>
<? echo "<option value='$id'>$name</option>";?>
<?php }?>
</select>
You do the same thing for the other loop. Or assign this:
$new_variable = "<option value='$id'>$name</option>";
to a variable and just echo in the other select box.
I hope this helps.
Habtom
Of course not; everyone deserves to be welcomed here. It does not matter who is pulling the wagon ;)
and yes, welcome kennyg! :)