Prev: Script to add domain users to local groups on remotemachines
Next: DOMDocument throws Unexpected end tag error when loading valid HTML
From: David Mehler on 5 Jun 2010 19:54 Hello, I've got a while loop outputting values from a database. Briefly it looks like this: while($row = mysql_fetch_array($result3)) { echo "<tr>"; echo "<td>" . $row['name'] . "</td>"; echo "<td>" . $row['type'] . "</td>"; echo "<td>" . $row['startdate'] . "</td>"; if (!empty($row['EndDate'])) { echo "<td>" . $row['enddate'] . "</td>"; } else { exit(); } echo "<td>" . $row['location'] . "</td>"; echo "<td>" . $row['summary'] . "</td>"; echo "<td>" . $row['description'] . "</td>"; echo "</tr>"; } That's not the whole code, but it is the problem code. Some output has the ending date set, one or two records i can't remember how many i entered with one, most do not, i want the echo to be conditional. The output stops right before the if statement, echoes startdate and that's it, comment out the if block and it works fine. Thanks. Dave.
From: Karl DeSaulniers on 5 Jun 2010 20:05 Could the exit() be terminating it? Do you need this exit() as the else for that if statement? Try deleting just the else {}. JAT Karl Sent from losPhone On Jun 5, 2010, at 6:54 PM, David Mehler <dave.mehler(a)gmail.com> wrote: > Hello, > I've got a while loop outputting values from a database. Briefly it > looks like this: > > while($row = mysql_fetch_array($result3)) > { > echo "<tr>"; > echo "<td>" . $row['name'] . "</td>"; > echo "<td>" . $row['type'] . "</td>"; > echo "<td>" . $row['startdate'] . "</td>"; > if (!empty($row['EndDate'])) { > echo "<td>" . $row['enddate'] . "</td>"; > } else { > exit(); > } > echo "<td>" . $row['location'] . "</td>"; > echo "<td>" . $row['summary'] . "</td>"; > echo "<td>" . $row['description'] . "</td>"; > echo "</tr>"; > } > > That's not the whole code, but it is the problem code. Some output has > the ending date set, one or two records i can't remember how many i > entered with one, most do not, i want the echo to be conditional. The > output stops right before the if statement, echoes startdate and > that's it, comment out the if block and it works fine. > Thanks. > Dave. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >
From: David Mehler on 5 Jun 2010 20:43 Hi, Thanks. I took out the entire else section including the exit call, it now all processes, however $row['enddate'] is not displayed on the two records where it is set. Thanks. Dave. On 6/5/10, Karl DeSaulniers <karl(a)designdrumm.com> wrote: > Could the exit() be terminating it? Do you need this exit() as the > else for that if statement? Try deleting just the else {}. > > JAT > > Karl > > Sent from losPhone > > On Jun 5, 2010, at 6:54 PM, David Mehler <dave.mehler(a)gmail.com> wrote: > >> Hello, >> I've got a while loop outputting values from a database. Briefly it >> looks like this: >> >> while($row = mysql_fetch_array($result3)) >> { >> echo "<tr>"; >> echo "<td>" . $row['name'] . "</td>"; >> echo "<td>" . $row['type'] . "</td>"; >> echo "<td>" . $row['startdate'] . "</td>"; >> if (!empty($row['EndDate'])) { >> echo "<td>" . $row['enddate'] . "</td>"; >> } else { >> exit(); >> } >> echo "<td>" . $row['location'] . "</td>"; >> echo "<td>" . $row['summary'] . "</td>"; >> echo "<td>" . $row['description'] . "</td>"; >> echo "</tr>"; >> } >> >> That's not the whole code, but it is the problem code. Some output has >> the ending date set, one or two records i can't remember how many i >> entered with one, most do not, i want the echo to be conditional. The >> output stops right before the if statement, echoes startdate and >> that's it, comment out the if block and it works fine. >> Thanks. >> Dave. >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
From: Karl DeSaulniers on 5 Jun 2010 21:07 So your code looks like this? while($row = mysql_fetch_array($result3)) { echo "<tr>"; echo "<td>" . $row['name'] . "</td>"; echo "<td>" . $row['type'] . "</td>"; echo "<td>" . $row['startdate'] . "</td>"; if (!empty($row['EndDate'])) { //This should probably be $row ['enddate'] echo "<td>" . $row['enddate'] . "</td>"; } echo "<td>" . $row['location'] . "</td>"; echo "<td>" . $row['summary'] . "</td>"; echo "<td>" . $row['description'] . "</td>"; echo "</tr>"; } Not to mention, you have a $row['EndDate'] and a $row['enddate']. Probably need to choose one or the other. HTH, Karl On Jun 5, 2010, at 7:43 PM, David Mehler wrote: > Hi, > Thanks. I took out the entire else section including the exit call, it > now all processes, however $row['enddate'] is not displayed on the two > records where it is set. > Thanks. > Dave. > > > On 6/5/10, Karl DeSaulniers <karl(a)designdrumm.com> wrote: >> Could the exit() be terminating it? Do you need this exit() as the >> else for that if statement? Try deleting just the else {}. >> >> JAT >> >> Karl >> >> Sent from losPhone >> >> On Jun 5, 2010, at 6:54 PM, David Mehler <dave.mehler(a)gmail.com> >> wrote: >> >>> Hello, >>> I've got a while loop outputting values from a database. Briefly it >>> looks like this: >>> >>> while($row = mysql_fetch_array($result3)) >>> { >>> echo "<tr>"; >>> echo "<td>" . $row['name'] . "</td>"; >>> echo "<td>" . $row['type'] . "</td>"; >>> echo "<td>" . $row['startdate'] . "</td>"; >>> if (!empty($row['EndDate'])) { >>> echo "<td>" . $row['enddate'] . "</td>"; >>> } else { >>> exit(); >>> } >>> echo "<td>" . $row['location'] . "</td>"; >>> echo "<td>" . $row['summary'] . "</td>"; >>> echo "<td>" . $row['description'] . "</td>"; >>> echo "</tr>"; >>> } >>> >>> That's not the whole code, but it is the problem code. Some >>> output has >>> the ending date set, one or two records i can't remember how many i >>> entered with one, most do not, i want the echo to be conditional. >>> The >>> output stops right before the if statement, echoes startdate and >>> that's it, comment out the if block and it works fine. >>> Thanks. >>> Dave. >>> >>> -- >>> PHP General Mailing List (http://www.php.net/) >>> To unsubscribe, visit: http://www.php.net/unsub.php >>> >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > Karl DeSaulniers Design Drumm http://designdrumm.com
From: Mari Masuda on 5 Jun 2010 21:50
Could it be that you are not using the same variable name? In the if statement you are using $row['EndDate'] and when attempting to print you are using $row['enddate']. I think you need to be consistent about which capitalization you use (and make sure it matches what is in the db). >>> if (!empty($row['EndDate'])) { >>> echo "<td>" . $row['enddate'] . "</td>"; >>> } On Jun 5, 2010, at 5:43 PM, David Mehler wrote: > Hi, > Thanks. I took out the entire else section including the exit call, it > now all processes, however $row['enddate'] is not displayed on the two > records where it is set. > Thanks. > Dave. > > > On 6/5/10, Karl DeSaulniers <karl(a)designdrumm.com> wrote: >> Could the exit() be terminating it? Do you need this exit() as the >> else for that if statement? Try deleting just the else {}. >> >> JAT >> >> Karl >> >> Sent from losPhone >> >> On Jun 5, 2010, at 6:54 PM, David Mehler <dave.mehler(a)gmail.com> wrote: >> >>> Hello, >>> I've got a while loop outputting values from a database. Briefly it >>> looks like this: >>> >>> while($row = mysql_fetch_array($result3)) >>> { >>> echo "<tr>"; >>> echo "<td>" . $row['name'] . "</td>"; >>> echo "<td>" . $row['type'] . "</td>"; >>> echo "<td>" . $row['startdate'] . "</td>"; >>> if (!empty($row['EndDate'])) { >>> echo "<td>" . $row['enddate'] . "</td>"; >>> } else { >>> exit(); >>> } >>> echo "<td>" . $row['location'] . "</td>"; >>> echo "<td>" . $row['summary'] . "</td>"; >>> echo "<td>" . $row['description'] . "</td>"; >>> echo "</tr>"; >>> } >>> >>> That's not the whole code, but it is the problem code. Some output has >>> the ending date set, one or two records i can't remember how many i >>> entered with one, most do not, i want the echo to be conditional. The >>> output stops right before the if statement, echoes startdate and >>> that's it, comment out the if block and it works fine. >>> Thanks. >>> Dave. >>> >>> -- >>> PHP General Mailing List (http://www.php.net/) >>> To unsubscribe, visit: http://www.php.net/unsub.php >>> >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > |