예제 #1
0
function responseList($id)
{
    $myReturn = '';
    $sql = "select DateAdded, ResponseID from sm15_responses where SurveyID = {$id}";
    #reference images for pager
    $prev = '<img src="' . VIRTUAL_PATH . 'images/arrow_prev.gif" border="0" />';
    $next = '<img src="' . VIRTUAL_PATH . 'images/arrow_next.gif" border="0" />';
    # Create instance of new 'pager' class
    $myPager = new Pager(10, '', $prev, $next, '');
    $sql = $myPager->loadSQL($sql);
    #load SQL, add offset
    # connection comes first in mysqli (improved) function
    $result = mysqli_query(IDB::conn(), $sql) or die(trigger_error(mysqli_error(IDB::conn()), E_USER_ERROR));
    if (mysqli_num_rows($result) > 0) {
        #records exist - process
        if ($myPager->showTotal() == 1) {
            $itemz = "response";
        } else {
            $itemz = "responses";
        }
        //deal with plural
        $myReturn .= '<div align="center">We have ' . $myPager->showTotal() . ' ' . $itemz . '!</div>';
        while ($row = mysqli_fetch_assoc($result)) {
            # process each row
            $myReturn .= '<div align="center"><a href="' . VIRTUAL_PATH . 'surveys/response_view.php?id=' . (int) $row['ResponseID'] . '">' . dbOut($row['DateAdded']) . '</a>';
            $myReturn .= '</div>';
        }
        $myReturn .= $myPager->showNAV();
        # show paging nav, only if enough records
    } else {
        #no records
        $myReturn .= "<div align=center>There are currently no surveys</div>";
    }
    @mysqli_free_result($result);
    //$myReturn .= $id;
    return $myReturn;
}
예제 #2
0
</h3>

<p>This page, along with <b>demo_view_pager.php</b>, demonstrate a List/View web application.</p>
<p>It was built on the mysql shared web application page, <b>demo_shared.php</b></p>
<p>This page is the entry point of the application, meaning this page gets a link on your web site.  Since the current subject is muffins, we could name the link something clever like <a href="<?php 
echo VIRTUAL_PATH;
?>
demo_list_pager.php">Muffins</a></p>
<p>Use <b>demo_list_pager.php</b> and <b>demo_view_pager.php</b> as a starting point for building your own List/View web application!</p> 
<?php 
#reference images for pager
$prev = '<img src="' . VIRTUAL_PATH . 'images/arrow_prev.gif" border="0" />';
$next = '<img src="' . VIRTUAL_PATH . 'images/arrow_next.gif" border="0" />';
# Create instance of new 'pager' class
$myPager = new Pager(10, '', $prev, $next, '');
$sql = $myPager->loadSQL($sql);
#load SQL, add offset
# connection comes first in mysqli (improved) function
$result = mysqli_query(IDB::conn(), $sql) or die(trigger_error(mysqli_error(IDB::conn()), E_USER_ERROR));
if (mysqli_num_rows($result) > 0) {
    #records exist - process
    if ($myPager->showTotal() == 1) {
        $itemz = "survey";
    } else {
        $itemz = "surveys";
    }
    //deal with plural
    echo '<div align="center">We have ' . $myPager->showTotal() . ' ' . $itemz . '!</div>';
    while ($row = mysqli_fetch_assoc($result)) {
        # process each row
        echo '<div align="center"><a href="' . VIRTUAL_PATH . 'surveys/survey_view.php?id=' . (int) $row['SurveyID'] . '">' . dbOut($row['Title']) . '</a>';
예제 #3
0
?>
</h3>

<p>This page demonstrates a List/View/Pager web application.</p>
<p>It adds the <b>Pager</b> class to add pagination to our pages.</p>
<p>Take the code from it to enable paging on your pages!</p>
<?php 
#reference images for pager
$prev = '<img src="' . VIRTUAL_PATH . 'images/arrow_prev.gif" border="0" />';
$next = '<img src="' . VIRTUAL_PATH . 'images/arrow_next.gif" border="0" />';
#Create a connection
# connection comes first in mysqli (improved) function
$iConn = @mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) or die(myerror(__FILE__, __LINE__, mysqli_connect_error()));
# Create instance of new 'pager' class
$myPager = new Pager(2, '', $prev, $next, '');
$sql = $myPager->loadSQL($sql, $iConn);
#load SQL, pass in existing connection, add offset
$result = mysqli_query($iConn, $sql) or die(myerror(__FILE__, __LINE__, mysqli_error($iConn)));
if (mysqli_num_rows($result) > 0) {
    #records exist - process
    if ($myPager->showTotal() == 1) {
        $itemz = "customer";
    } else {
        $itemz = "customers";
    }
    //deal with plural
    echo '<p align="center">We have ' . $myPager->showTotal() . ' ' . $itemz . '!</p>';
    while ($row = mysqli_fetch_assoc($result)) {
        # process each row
        echo '<p align="center">
            <a href="' . VIRTUAL_PATH . 'customer_view.php?id=' . (int) $row['CustomerID'] . '">' . dbOut($row['FirstName']) . '</a>
예제 #4
0
    die('Unable to connect to database [' . $db->connect_error . ']');
}
$firstArrow = "&#x21e4;";
// left arrow with tabstop
$lastArrow = "&#x21e5;";
// left arrow with tabstop
$prevArrow = "&#x2190;";
// left arrow
$nextArrow = "&#x2192;";
// right arrow
$myPager = new Pager(4, $firstArrow, $prevArrow, $nextArrow, $lastArrow);
$sql = <<<SQLSTATEMENT
\t\t\t\t\tSELECT inventoryID, inventoryImagePath, inventoryQuantity, manufacturerName, inventoryProductName FROM inventory
\t\t\t\t\tINNER JOIN manufacturers ON inventory.manufacturer = manufacturers.manufacturerID;
SQLSTATEMENT;
$sql = $myPager->loadSQL($sql, $db);
if (!($result = $db->query($sql))) {
    die('Error searching database [' . $db->error . ']');
}
while ($row = $result->fetch_assoc()) {
    printTableRow(array('<img src="' . htmlspecialchars($baseImgPath . $row['inventoryImagePath']) . '" style="height: 64px" />', '<a href="ingredient_detail.php?id=' . htmlspecialchars($row['inventoryID']) . '">' . htmlspecialchars($row['inventoryProductName']) . "<br /><i>" . htmlspecialchars($row['manufacturerName']) . "</i></a>", $row["inventoryQuantity"]));
    // end printTableRow
}
?>
			</table>
			<?php 
/*mkTable(
			array("Picture", "Item Code", "UPC", "Quantity", "Manufacturer", "Item Name"),
			array(array("[IMG]", "DGLD001", '<img src="upc.php?code=3900449033" /><br>3900449033', "x193", "Wairywold Dairy", "Milk")) //* no rows *
		);*/
/*mkTable(