blind-computing / blind-computing-archive

A website devoted to exposing facts and information about computing in the blind/vi world
https://blindcomputing.org
GNU Lesser General Public License v3.0
9 stars 1 forks source link

Fix syntax error in includes/functions.inc.php in create_contributer_list function #12

Closed mcb2003 closed 6 years ago

mcb2003 commented 6 years ago

I've started work on creating a contributers.php file (seen in commit 1818bb3377e639d7b17be4538fd8b0b528eb2fd2 ). To do this, I've created a function: create_contributer_list() that lists all of the contributers to the site with an optional search term. It looks like this

/**
 * Generates HTML for a list of contributers with an optional search term.
 *
 * @param string $searchTerm
 * @return string
 */
function create_contributer_list($searchTerm = "") {
    global $db;
    $output = '';
    if($searchTerm === '') {
        $sql = "select username, fullName, imguri from contributers;";
        $results = $db->prepare($sql);
        $results->execute();
    } else {
        $sql = "select username, fullName, imguri from contributers where username like '%?%' or fullName like '%?%';";
        $results = $db->prepare($sql);
        $results->execute([$searchTerm,$searchTerm]);
    }
    if($results->rowCount) {
        $output = $output.'<table class="contributer-list">';
        while($row = $results->fetchObject()) {
            $output = $output.'<tr><td>';
            if($row->imguri == NULL) {
                $output = $output.'</td>';
            } else {
                $output = $output.'<image src="'.$row->imguri.'" class="profile-img-small"></td>';
            }
            $output = $output.
                '<td>'.
                $row->username.
                '</td><td>';
            if($row->fullName == NULL) {
                $output = $output.'</td>';
            } else {
                $output = $output.$row->fullName.'</td>';
            }
            $output = $output.'</tr>';
        }
        $output = $output.'</table>';
    } else {
        £$output = '<h3>No Results Match Your Search</h3><p>Woops, we couldn\'t find any contributers matching your search term. Please try again with a different search term, or remove your search completely.</p>';
    }
    return $output;
}

This function was introduced in commit bca9a0ebf15e0ad0f2af4d0d406639a22f9fb7d1 . Problem is ... I have no idea where the error is!

Any help would be appreciated

Mikey

mcb2003 commented 6 years ago

I’ve completely re-done this function and it’s working fine now, so this issue is not needed anymore.