I used phpCodeGenie to generate some php code to work with a MySQL database. Mostly, I just want to learn php, so the goal is to pick apart what it generates and learn from dissecting it. I have had trouble finding a resource which knows anything about phpCodeGenie ... it's not that sophisticated, but what do you want for free?
I get a series of errors on a page which lists all of the entries in a table:
Notice: Undefined index: startLimit in c:\inetpub\ on line 9
Notice: Undefined index: rows in c:\inetpub\ on line 10
Notice: Undefined index: sortBy in c:\inetpub\ on line 11
Notice: Undefined index: sortOrder in c:\inetpub\ on line 12
Notice: Undefined variable: orderByQuery in c:\inetpub\ on line 39
Notice: Undefined index: startLimit in c:\inetpub\ on line 61
... Then I get the output as expected ...
Notice: Undefined index: startLimit in c:\inetpub\ on line 129
Thanks in advance,
Linda
**************************
Here's the code:
I get a series of errors on a page which lists all of the entries in a table:
Notice: Undefined index: startLimit in c:\inetpub\ on line 9
Notice: Undefined index: rows in c:\inetpub\ on line 10
Notice: Undefined index: sortBy in c:\inetpub\ on line 11
Notice: Undefined index: sortOrder in c:\inetpub\ on line 12
Notice: Undefined variable: orderByQuery in c:\inetpub\ on line 39
Notice: Undefined index: startLimit in c:\inetpub\ on line 61
... Then I get the output as expected ...
Notice: Undefined index: startLimit in c:\inetpub\ on line 129
Thanks in advance,
Linda
**************************
Here's the code:
Code:
<?php
include_once("../common/dbConnection.php");
include_once("../common/header.php");
?>
<?
$initStartLimit = 0;
$limitPerPage = 10;
$startLimit = $_REQUEST['startLimit'];
$numberOfRows = $_REQUEST['rows'];
$sortBy = $_REQUEST['sortBy'];
$sortOrder = $_REQUEST['sortOrder'];
if ($startLimit=="")
{
$startLimit = $initStartLimit;
}
if ($numberOfRows=="")
{
$numberOfRows = $limitPerPage;
}
if ($sortOrder=="")
{
$sortOrder = "DESC";
}
if ($sortOrder == "DESC") { $newSortOrder = "ASC"; } else { $newSortOrder = "DESC"; }
$limitQuery = " LIMIT ".$startLimit.",".$numberOfRows;
$nextStartLimit = $startLimit + $limitPerPage;
$previousStartLimit = $startLimit - $limitPerPage;
if ($sortBy!="")
{
$orderByQuery = " ORDER BY ".$sortBy." ".$sortOrder;
}
$sql = "SELECT * FROM MM_Hours".$orderByQuery.$limitQuery;
$result = MYSQL_QUERY($sql);
$numberOfRows = MYSQL_NUM_ROWS($result);
?>
<?
if ($numberOfRows==0) {
?>
Sorry. No records found !!
<?
}
else if ($numberOfRows>0) {
$i=0;
?>
<br>
<?
if ($_REQUEST['startLimit'] != "")
{
?>
<a href="<? echo $_SERVER['PHP_SELF']; ?>?startLimit=<? echo $previousStartLimit; ?>&limitPerPage=<? echo $limitPerPage; ?>&sortBy=<? echo $sortBy; ?>&sortOrder=<? echo $sortOrder; ?>">Previous <? echo $limitPerPage; ?> Results</a>....
<? } ?>
<?
if ($numberOfRows == $limitPerPage)
{
?>
<a href="<? echo $_SERVER['PHP_SELF']; ?>?startLimit=<? echo $nextStartLimit; ?>&limitPerPage=<? echo $limitPerPage; ?>&sortBy=<? echo $sortBy; ?>&sortOrder=<? echo $sortOrder; ?>">Next <? echo $limitPerPage; ?> Results</a>
<? } ?>
<br><br>
<TABLE CELLSPACING="0" CELLPADDING="3" BORDER="0" WIDTH="100%">
<TR>
<TD>
<a href="<? echo $PHP_SELF; ?>?sortBy=KeyID&sortOrder=<? echo $newSortOrder; ?>&startLimit=<? echo $startLimit; ?>&rows=<? echo $limitPerPage; ?>">
<B>KeyID</B>
</a>
</TD>
<TD>
<a href="<? echo $PHP_SELF; ?>?sortBy=Date&sortOrder=<? echo $newSortOrder; ?>&startLimit=<? echo $startLimit; ?>&rows=<? echo $limitPerPage; ?>">
<B>Date</B>
</a>
</TD>
<TD>
<a href="<? echo $PHP_SELF; ?>?sortBy=Accomplishments&sortOrder=<? echo $newSortOrder; ?>&startLimit=<? echo $startLimit; ?>&rows=<? echo $limitPerPage; ?>">
<B>Accomplishments</B>
</a>
</TD>
<TD>
<a href="<? echo $PHP_SELF; ?>?sortBy=Hours&sortOrder=<? echo $newSortOrder; ?>&startLimit=<? echo $startLimit; ?>&rows=<? echo $limitPerPage; ?>">
<B>Hours</B>
</a>
</TD>
</TR>
<?
while ($i<$numberOfRows)
{
if (($i%2)==0) { $bgColor = "#FFFFFF"; } else { $bgColor = "#C0C0C0"; }
$thisKeyID = MYSQL_RESULT($result,$i,"KeyID");
$thisDate = MYSQL_RESULT($result,$i,"Date");
$thisAccomplishments = MYSQL_RESULT($result,$i,"Accomplishments");
$thisHours = MYSQL_RESULT($result,$i,"Hours");
?>
<TR BGCOLOR="<? echo $bgColor; ?>">
<TD><? echo $thisKeyID; ?></TD>
<TD><? echo $thisDate; ?></TD>
<TD><? echo $thisAccomplishments; ?></TD>
<TD><? echo $thisHours; ?></TD>
<TD><a href="editMM_Hours.php?KeyIDField=<? echo $thisKeyID; ?>">Edit</a></TD>
<TD><a href="confirmDeleteMM_Hours.php?KeyIDField=<? echo $thisKeyID; ?>">Delete</a></TD>
</TR>
<?
$i++;
} // end while loop
?>
</TABLE>
<br>
<?
if ($_REQUEST['startLimit'] != "")
{
?>
<a href="<? echo $_SERVER['PHP_SELF']; ?>?startLimit=<? echo $previousStartLimit; ?>&limitPerPage=<? echo $limitPerPage; ?>&sortBy=<? echo $sortBy; ?>&sortOrder=<? echo $sortOrder; ?>">Previous <? echo $limitPerPage; ?> Results</a>....
<? } ?>
<?
if ($numberOfRows == $limitPerPage)
{
?>
<a href="<? echo $_SERVER['PHP_SELF']; ?>?startLimit=<? echo $nextStartLimit; ?>&limitPerPage=<? echo $limitPerPage; ?>&sortBy=<? echo $sortBy; ?>&sortOrder=<? echo $sortOrder; ?>">Next <? echo $limitPerPage; ?> Results</a>
<? } ?>
<br><br>
<?
} // end of if numberOfRows > 0
?>
<?php
include_once("../common/footer.php");
?>