Data science. Due tonight!!! LAB EXERCISE Query Which table to query. projecl Wh
ID: 3598526 • Letter: D
Question
Data science. Due tonight!!!
LAB EXERCISE Query Which table to query. projecl What attributes to query (3eperated by-): Project-lame, Departme Modiiy query-php, allowing to speciry attributes - If no input for attributes, show the table - If some input for attributes, show the selected columns - Example: http://my.up.ist.psu.edu/jxw394/query_attr.php 8 mrr.up.istPsuedu/2uirgery.attr.php Query Which table to query: projac What attributes to qery (repe Sumit uery ÷rry.up.ntplu..du/sul1Uqu.ry.attr.php Query Query SELECT FrojectamDepatment FROM project rated b SubmitO PrujectNane 2010 Q3 Froduct Flan 2010 Q3 Porttobo Analysis Frece 2010 Q3 Tax Freparaticn Accouting 2010 Q4 Froduct FMar 2010 Q4 Porttolio Analysis Fre 2005 Q4 Tax FrepartinAccountine Which table to que? Query QSELECT FROM proje keting StartDate 10 3 Prodt En 13 102010 1200AMTei 15 2010 1200 10010 3 Poatfabo Aa 10 1200ad 01200A Oct1 0 1200AN 3010 4 Prodact Flon 150.00 Aag 2010 12:00A4 |Srp tS 2010 t20AM What attrbutes to query (sceratedby J 054 Tu Frepn30e1000 1200A lach table to query Submit Query hat atrb to query (separated by HELP eed to modify these two parts action= ." method= " post"> ich table to query: type="text " name=" table" /> You need to have a new input for attribute names epare SQL query y = "SELECT * FROM $table"; Now, you need to query given attributes not the whole table.What query you should generate? Also, when there is no input for attributes, you need to show all the results. So think about using IF-ELSEExplanation / Answer
Hi ,
Query.php should contain the following code, to meet your conditions.
Please find the same!
<!DOCTYPE html>
<html>
<body>
<form method="post" action="">
<h2>Which table to query: </h2>
<input type="text" name="tablename">
<h2> Which attributes to query: </h2>
<input type="text" name="attributes">
<input type="submit" value="Submit Query" name="send" id="send">
</form>
<?php
if (isset($_POST["send"])){
$tablename = $_POST['tablename'];
$attributes= $_POST['attributes'];
echo "<br>";
if (empty($attributes))
$query="select * from $tablename;";
else
$query=" select ".$attributes." from $tablename;";
echo $query;
}
?>
</body>
</html>
Thanks and Regards,
Hema.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.