Forum Moderators: coopster

Message Too Old, No Replies

Dynamic php using Variables

whats the problems

         

nanat

9:02 am on Oct 27, 2009 (gmt 0)

10+ Year Member



i really dont get it i have my codes

else if ($globalTask == 'new')
{
$addMenu = mssql_query("select * from UAccessform");
$existA = mssql_num_rows($addMenu);

if($existA > 0)
{
for($r=0; $r< $existA; $r++)
{
$AccessID = mssql_result($addMenu,$r,"AccessID");
$DisplayName = mssql_result($addMenu,$r,"DisplayName");

$divStageUser = '<div id="addFacilDiv" style="padding: 4px 4px 4px 4px; border: 1px #D7D7D7 dashed;" align=center>
<form name="facilForm" method="POST" action="userAction.php">
<table border=0 cellpadding=2 cellspacing=2 width=80%>
<tr>
<td colspan=2 class=title>
Add Menu User
</td>
</tr>
<tr>
<td>Fullname</td>
<td>
<input type="hidden" id=fid name="fid" value="0">
<input type="text" id="fname" name="fname" value="'.$UserID.'">
</td>
</tr>
<tr>
<td>User Level</td>
<td>
<select name="DisplayName">
<option value='.$AccessID.'>'.$DisplayName.'</option>
</select>
</td>
</tr>

<tr>
<td>&nbsp; </td>
<td>
<div id=divFacilBtns>
<input type="submit" name="fail" value="Save">
<input type="button" value="Close" onClick="showhideAddFacilitator(0);">
</div>
</td>
</tr>
</table>
</form>
</div>';
}
}
else
{
echo '<font>NO Menu Available Yet</font>';
}



i echo $DisplayName it loops

but inside the my variable $divStageUser it doesnt work? whats wrong with my code?

nanat

9:12 am on Oct 27, 2009 (gmt 0)

10+ Year Member



nah i get it ^^ tnx...

TheMadScientist

9:15 am on Oct 27, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The only thing I see that seems to be at all wrong is the missing quotes:
<option value="'.$AccessID.'">'.$DisplayName.'</option>

Other than those, you'll probably have to be more specific about doesn't work.

nanat

11:34 am on Oct 27, 2009 (gmt 0)

10+ Year Member



even if i change <option value="'.$AccessID.'"> it doesnt work

its seems replacing echo with a variable $divStageUser dont accept it with for loops it only allow static data.. :(

StoutFiles

11:45 am on Oct 27, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<option value='

Once it hits the ' it stops reading values into the variable.

$example = 'hi'hello';

All you will get is hi into example, and then an error. Use \' to fix the problem.

$fixed = 'hi\'hello';