flexxall Posted August 24, 2009 Share Posted August 24, 2009 I am trying to output this data resutls onto my web page using <div> tags or something instead of just outputting on a blank php page. any ideas ? Heres the info i want to output if(!empty($arr_hdd_files)) { foreach($arr_hdd_files as $k => $v) { <li>$v</li> } echo '</ul>'; } else { echo '<li>None</li></ul>'; } echo '<p>Files in Database</p><ul>'; if(!empty($arr_db_files)) { foreach($arr_db_files as $k => $v) { <li>$v</li> } echo '</ul>'; } else { echo '<li>None</li></ul>'; } echo '<p>Files inserted to DB</p><ul>'; if(!empty($arr_insert_files)) { foreach($arr_insert_files as $k => $v) { <li>$v</li> } echo '</ul>'; } else { echo '<li>None</li></ul>'; } Quote Link to comment https://forums.phpfreaks.com/topic/171587-how-to-display-this-output-in-tags/ Share on other sites More sharing options...
purencool Posted August 24, 2009 Share Posted August 24, 2009 You will need to echo the li in your foreach loop =). echo "<li>" .$v. "</li>"; Quote Link to comment https://forums.phpfreaks.com/topic/171587-how-to-display-this-output-in-tags/#findComment-904831 Share on other sites More sharing options...
flexxall Posted August 24, 2009 Author Share Posted August 24, 2009 ok so im not having any luck with that. Heres my page code to see if theres something im just not putting in the right spot. I also noticed that I had added the incorrect code in the first place too much confusion today hehe. So heres what I got and want to display in the <div> the results of each. <!-- INCLUDE overall_header.html --> <p class="{S_CONTENT_FLOW_END}<!-- IF S_USER_LOGGED_IN --> rightside<!-- ENDIF -->"><!-- IF S_USER_LOGGED_IN -->{LAST_VISIT_DATE}<!-- ELSE -->{CURRENT_TIME}<!-- ENDIF --></p> <!-- IF U_MCP --><p>{CURRENT_TIME} <br />[ <a href="{U_MCP}">{L_MCP}</a> ]</p><!-- ELSEIF S_USER_LOGGED_IN --><p>{CURRENT_TIME}</p><!-- ENDIF --> <html> <head> <?php $Dir = './images/'; mysql_connect('localhost', 'xxx', 'xxx'); mysql_select_db('pets'); $arr_hdd_files = array(); $arr_db_files = array(); $arr_insert_files = array(); //get files in db $query = "SELECT * FROM image"; $result = mysql_query($query) or die("Could not execute query ".mysql_error()); $row_result = mysql_fetch_assoc($result); if($row_result) { do { $arr_db_files[] = $row_result['name']; } while($row_result = mysql_fetch_assoc($result)); } //check files on disk foreach (glob("$Dir/*.{jpg,gif,png}", GLOB_BRACE) as $filename) { $pathinfo = pathinfo($filename); $name = basename($filename); $ext = $pathinfo['extension']; $arr_hdd_files[] = $name; $size = filesize($filename); $thePath=dirname($_SERVER['PHP_SELF']) . substr($filename, 1); //check hdd filename against array of db filenames if ( !in_array($name,$arr_db_files) ) { $query1 = "INSERT INTO image SET name='$name', size='$size', type='$ext', path='$thePath'"; // or uncomment to use blob // $blob = addslashes(file_get_contents($filename)); // $query = "INSERT INTO images SET name='$name', size='$size', type='$ext', content='$blob'"; $result1 = mysql_query($query1); if($result) { $arr_insert_files[] = $name; } } } //show results echo "<h2>Results</h2>\n"; echo '<p>Files on Disk</p><ul>'; if(!empty($arr_hdd_files)) { foreach($arr_hdd_files as $k => $v) { echo "<li>$v</li>"; } echo '</ul>'; } else { echo '<li>None</li></ul>'; } echo '<p>Files in Database</p><ul>'; if(!empty($arr_db_files)) { foreach($arr_db_files as $k => $v) { echo "<li>$v</li>"; } echo '</ul>'; } else { echo '<li>None</li></ul>'; } echo '<p>Files inserted to DB</p><ul>'; if(!empty($arr_insert_files)) { foreach($arr_insert_files as $k => $v) { echo "<li>$v</li>"; } echo '</ul>'; } else { echo '<li>None</li></ul>'; } ?> <div class="panel"> <div class="inner"><span class="corners-top"><span></span></span> <h1>Files on Disk</h1> echo "<li>".$v."</li>"; <span class="corners-bottom"><span></span></span></div> </div> <!-- INCLUDE overall_footer.html --> Quote Link to comment https://forums.phpfreaks.com/topic/171587-how-to-display-this-output-in-tags/#findComment-904851 Share on other sites More sharing options...
flexxall Posted August 24, 2009 Author Share Posted August 24, 2009 Anyone ? Quote Link to comment https://forums.phpfreaks.com/topic/171587-how-to-display-this-output-in-tags/#findComment-905178 Share on other sites More sharing options...
mikesta707 Posted August 24, 2009 Share Posted August 24, 2009 just wrap what you want to echo in the foreach with the div tags? assuming you want to wrap whats inside the following code block in a div tag //show results echo "<h2>Results</h2>\n"; echo '<p>Files on Disk</p><ul>'; if(!empty($arr_hdd_files)) { foreach($arr_hdd_files as $k => $v) { echo "<li>$v</li>"; } echo '</ul>'; } else { echo '<li>None</li></ul>'; } echo '<p>Files in Database</p><ul>'; if(!empty($arr_db_files)) { foreach($arr_db_files as $k => $v) { echo "<li>$v</li>"; } echo '</ul>'; } else { echo '<li>None</li></ul>'; } echo '<p>Files inserted to DB</p><ul>'; if(!empty($arr_insert_files)) { foreach($arr_insert_files as $k => $v) { echo "<li>$v</li>"; } echo '</ul>'; } else { echo '<li>None</li></ul>'; } ?> just echo div tags around them... echo "<div id='something'>"; //show results echo "<h2>Results</h2>\n"; echo '<p>Files on Disk</p><ul>'; if(!empty($arr_hdd_files)) { foreach($arr_hdd_files as $k => $v) { echo "<li>$v</li>"; } echo '</ul>'; } else { echo '<li>None</li></ul>'; } echo '<p>Files in Database</p><ul>'; if(!empty($arr_db_files)) { foreach($arr_db_files as $k => $v) { echo "<li>$v</li>"; } echo '</ul>'; } else { echo '<li>None</li></ul>'; } echo '<p>Files inserted to DB</p><ul>'; if(!empty($arr_insert_files)) { foreach($arr_insert_files as $k => $v) { echo "<li>$v</li>"; } echo '</ul>'; } else { echo '<li>None</li></ul>'; } echo "</div>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/171587-how-to-display-this-output-in-tags/#findComment-905180 Share on other sites More sharing options...
flexxall Posted August 24, 2009 Author Share Posted August 24, 2009 That didnt seem to work Quote Link to comment https://forums.phpfreaks.com/topic/171587-how-to-display-this-output-in-tags/#findComment-905203 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.