Example #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;
}
Example #2
0
$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>';
        echo '</div>';
    }
    echo $myPager->showNAV();
    # show paging nav, only if enough records
} else {
    #no records
    echo "<div align=center>There are currently no Surveys.  Would you like to create a survey?</div>";
}
@mysqli_free_result($result);
get_footer();
#defaults to theme footer or footer_inc.php
$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 = "workout";
    } else {
        $itemz = "workouts";
    }
    //deal with plural
    echo '<p align="center"><b>We have ' . $myPager->showTotal() . ' ' . $itemz . '!</b></p>';
    while ($row = mysqli_fetch_assoc($result)) {
        # process each row
        echo '<p align="center">';
        echo 'Workout Name: <b>' . $row['WorkoutName'] . '</b> ';
        echo 'Workout Type: <b>' . $row['WorkoutType'] . '</b> ';
        echo '<a href="' . VIRTUAL_PATH . 'workout_view.php?id=' . (int) $row['WorkoutID'] . '">' . dbOut($row['WorkoutName']) . '</a>';
        echo '</p>';
    }
    //the showNAV() method defaults to a div, which blows up in our design
    //echo $myPager->showNAV();//show pager if enough records
    //the version below adds the optional bookends to remove the div design problem
    echo $myPager->showNAV('<p align="center">', '</p>');
} else {
    #no records
    echo "<p align=center>Currently no workouts available</p>";
}
@mysqli_free_result($result);
@mysqli_close($iConn);
include 'includes/footer.php';