ifis Posted January 5, 2008 Share Posted January 5, 2008 I have an array that dispalys information a specific user has inputed into the table. I want the users to be able to update the passed field if it is blank. So I want to add an if statement that says if Passed == 'null' {echo "form..."} else echo ". $row['Passed?'] . " How would I do it? Here is the code I currently have. $sql = "SELECT * FROM Endorsementlog WHERE Username= '{$_SESSION['myusername']}'"; $result=mysql_query($sql); echo "<h3>Endorsement Log:</h3>"; echo "<table border='0'> <tr> <th>Date</th> <th>Student</th> <th>Endorsement</th> <th>Passed</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['Date'] . "</td>"; echo "<td>" . $row['Student'] . "</td>"; echo "<td>" . $row['Endorsement'] . "</td>"; if ( $row['Passed?'] .== 'null') echo"<form id='elog' name='form2' method='post' action=''> <select name='Passed?' id='Passed?'> <option>Yes</option> <option>No</option> </select> </form>"; else echo "<td>" . $row['Passed?'] . "</td>"; echo "</tr>"; } echo "</table>"; ?> Any suggestions? Thanks Quote Link to comment Share on other sites More sharing options...
papaface Posted January 5, 2008 Share Posted January 5, 2008 You have no {} on your if/else statement. Quote Link to comment Share on other sites More sharing options...
ifis Posted January 5, 2008 Author Share Posted January 5, 2008 I added the {, but am getting the message:"Parse error: parse error, unexpected '.' " if I take out the '.', will it still sequence to the next row? Here is the current code. while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['Date'] . "</td>"; echo "<td>" . $row['Student'] . "</td>"; echo "<td>" . $row['Endorsement'] . "</td>"; if (. $row['Passed?']== 'null') { echo"<form id='elog' name='form2' method='post' action=''> <select name='Passed?' id='Passed?'> <option>Yes</option> <option>No</option> </select> </form>"; } else { echo "<td>" . $row['Passed?'] . "</td>"; } echo "</tr>"; echo "</table>"; Quote Link to comment Share on other sites More sharing options...
revraz Posted January 5, 2008 Share Posted January 5, 2008 Remove all those periods. Quote Link to comment Share on other sites More sharing options...
papaface Posted January 5, 2008 Share Posted January 5, 2008 Should be: while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['Date'] . "</td>"; echo "<td>" . $row['Student'] . "</td>"; echo "<td>" . $row['Endorsement'] . "</td>"; if ($row['Passed?']== 'null') { echo"<form id='elog' name='form2' method='post' action=''> <select name='Passed?' id='Passed?'> <option>Yes</option> <option>No</option> </select> </form>"; } else { echo "<td>" . $row['Passed?'] . "</td>"; } echo "</tr>"; echo "</table>"; Quote Link to comment Share on other sites More sharing options...
ifis Posted January 5, 2008 Author Share Posted January 5, 2008 Thanks, i got to that code. But I am still getting the error message:"Parse error: parse error, unexpected $ in ... on line 233." Line 233 is after the last line of the code. I think this means I probably have an undefined variable somewhere. Quote Link to comment Share on other sites More sharing options...
revraz Posted January 5, 2008 Share Posted January 5, 2008 Means you have a open bracket some where } ] ) Quote Link to comment Share on other sites More sharing options...
ifis Posted January 5, 2008 Author Share Posted January 5, 2008 Just found that missed }. Thanks for the help! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.