Created
September 12, 2016 17:50
-
-
Save brucenorton/df87dd28acb18375788601674e91e6e2 to your computer and use it in GitHub Desktop.
hypertext select join statement
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>php mySQLi prepared statments</title> | |
</head> | |
<body> | |
<!doctype html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>php mySQLi prepared statments</title> | |
</head> | |
<body> | |
<?php | |
include '_includes/connect.php'; | |
//define table | |
$tbl = "items";//change to your table i.e. John_app | |
$tbl2 = "photos"; | |
//write query | |
$query = "SELECT $tbl.itemID, $tbl.title, $tbl.description, $tbl.price, $tbl2.src FROM $tbl, $tbl2 WHERE $tbl.itemID = $tbl2.itemID"; | |
//prepare statement, execute, store_result | |
if($displayStmt = $mysqli->prepare($query)){ | |
$displayStmt->execute(); | |
$displayStmt->store_result(); | |
$numrows = $displayStmt-> num_rows; | |
echo("<br>results: $numrows"); | |
} | |
//bind results | |
$displayStmt->bind_result($itemIDResult, $titleResult, $descriptionResult, $priceResult, $srcResult); | |
//fetch results | |
while($displayStmt->fetch()){ | |
echo("<br>results: $itemIDResult, $titleResult, $descriptionResult, $priceResult, $srcResult<br>"); | |
echo ("<img src=\"images/$srcResult\"><br>"); | |
} | |
?> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment