
Untitled
By: a guest on
May 23rd, 2012 | syntax:
None | size: 1.97 KB | hits: 13 | expires: Never
Using form data as known key value when echoing a multidimensional array
$lettertype = str_split($lettertype);
$lettertype = "'" . implode("','", $lettertype) . "'";
$query = "SELECT * FROM Photos WHERE letter IN ($lettertype)";
$result = mysqli_query($cxn, $query)
or die ("No good");
$alpharray = array();
while($row = mysqli_fetch_assoc($result)){
$alpharray[$row['letter']][] = $row;
}
foreach(str_split($_POST['search_term']) as $alpha){
echo "<img class='clickable' img src='../Letterproject/images/{$alpharray[$alpha][0]['photoPath']}' width='100' height='140'></src>";
echo '<div class="editimages">';
foreach ($alpharray as $tempvar){
foreach($tempvar as $oneletter){
echo "<img class='editable' img src='../Letterproject/images/{$oneletter['photoPath']}' width='100' height='140'></src>";
}
}
echo '</div>';
}
"SELECT * FROM Photos WHERE letter IN ($lettertype)";
$lettertype = str_split($lettertype);
$lettertype = "'" . implode("','", $lettertype) . "'";
$query = "SELECT * FROM Photos WHERE letter IN ($lettertype)";
$result = mysqli_query($cxn, $query)
or die ("No good");
$alpharray = array();
while($row = mysqli_fetch_assoc($result)){
$alpharray[$row['letter']][] = $row;
}
foreach(str_split($_POST['search_term']) as $alpha){
echo "<img class='clickable' img src='../Letterproject/images/{$alpharray[$alpha][0]['photoPath']}' width='100' height='140'></src>";
echo '<div class="editimages">';
foreach ($alpharray[$alpha] as $tempvar){
echo "<img class='editable' img src='../Letterproject/images/{$tempvar['photoPath']}' width='100' height='140'></src>";
}
echo '</div>';
}