function selectParamQuery($sqlStr) { $db = initiateDb(); $numOfParam = substr_count($sqlStr, '?'); $artistId = getArtistId(); $workId = getWorkId(); try { $results = $db->prepare($sqlStr); if (intval($workId)) { $results->bindParam(1, $workId); } elseif (intval($artistId)) { $results->bindParam(1, $artistId); } $results->execute(); } catch (Exception $e) { echo $e->getMessage(); die; } $artist = $results->fetchAll(PDO::FETCH_ASSOC); if ($artist == FALSE) { echo "Our Appologies No Artist was Found with the Provided Id"; } return $artist; }
<?php $page = "work"; $subPage = "work"; require_once $_SERVER["DOCUMENT_ROOT"] . "/php/includes/config.php"; require_once ROOT_PATH . 'php/functionList.php'; include ROOT_PATH . 'php/displayLargePreview.php'; include ROOT_PATH . 'php/ignoreList.php'; $urlArtistId = getArtistId(); $urlWorkId = getWorkId(); if (in_array($urlArtistId, $ukranians)) { $artWorks = selectQuery('select * from art_works where ' . printUkranians($ukranians) . ' ORDER BY availability, media'); } elseif (in_array($urlArtistId, $change_order)) { $artWorks = selectParamQuery('select * from art_works where `artist`=' . $urlArtistId . ' ORDER BY availability desc, category, media desc'); } else { $artWorks = selectParamQuery('select * from `art_works` where `artist`=' . $urlArtistId . ' ORDER BY availability, media'); } $artistN = selectParamQuery('select artist_name from artists where artist_id =' . $urlArtistId); $artistFullName = $artistN[0]["artist_name"]; $title = $artistFullName . ", "; $keywords = $artistFullName . " ,"; $description = "Detailed view of art works by " . $title . " available at the Sloane Gallery of Art, Denver CO"; $mainContentHTML = ""; foreach ($artWorks as $artWork) { $artistN = selectParamQuery('select artist_name from artists where artist_id =' . $artWork["artist"]); $keywords .= str_replace('"', '', $artWork["title"]) . " , "; if (setArtWork($artWork) && !in_array($artWork["work_id"], $ignoreListArtWorks)) { $mainContentHTML .= largePreviewContainer($artWork, $artistFullName, $urlArtistId); } } include ROOT_PATH . 'php/includes/header.php';
<?php include ROOT_PATH . 'php/functionList.php'; $workId = getWorkId(); if (is_numeric($workId)) { $artWork = selectQuery('select * from `art_works` WHERE work_id=' . $workId); $artistName = selectQuery('select artist_name from artists WHERE artist_id=' . $artWork[0]["artist"]); } function parseArtWork($artWork, $artistName) { $detailsList = "Hello, "; $detailsList .= "I am interested in a work by " . $artistName . ". "; $workDetails = ""; foreach ($artWork[0] as $key => $value) { if ($key != "work_id" && $key != "artist" && $value != "" && $key != "exception") { if ($key === "size") { $workDetails .= $value . ' in | (' . valueToCm($value) . ')' . ' .'; } elseif ($key === "image" || $key === "category" || $key === "availability") { continue; } else { $workDetails .= ucwords($value) . ' , '; } } } return $detailsList . $workDetails; } ?> <div id="contact-form"> <div class='container'> <form id="form" method="POST" action="<?php htmlspecialchars($_SERVER["PHP_SELF"]);