Search the Community
Showing results for tags 'formatting'.
-
Ok, so I have some code that takes the records in my database and outputs them in a table, but currently after the first record it starts spacing them incorrectly Here is the code <?php require_once('config.php'); require_once('menu.php'); echo '<h1>View All Alien Interactions</h1>'; echo '<table> <tr>'; foreach($fields AS $label){ echo "<th>{$label}</th>"; } echo '<th>Edit</th><th>Delete</th>'; echo '</tr>'; $fields_str = '`contact_id`, `'.implode(array_keys($fields), '`, `').'`'; $sql = "SELECT {$fields_str} FROM `alien_abduction`"; foreach($dbh->query($sql) as $row) { echo '<tr>'; foreach($fields AS $field=>$value){ echo '<td>'.(isset($row[$field]) && strlen($row[$field]) ? $row[$field] : ' '.'</td>'); } echo '</tr>'; echo '<td><a href="edit.php?contact_id='.$row['contact_id'].'">Edit</a></td>'; echo '<td><a href="delete.php?contact_id='.$row['contact_id'].'">Delete</a></td>'; echo '</tr>'; echo '</table>'; } ?> I just want it to start a new line after importing each record This is a picture of what its curently doing, look at the second row, it just keeps adding all additional entries on this line (I whited out personal info)
-
Hi, I realized that margin:auto only works sometimes for me in centering an item. Other times, it does nothing. Margin:auto especially doesn't work for me a lot when I try to center texts in <p> </p>. But in those times that it doesn't work, I can still use margin-left, margin-top, etc. Are there certain cases where margin:auto doesn't work? Or, are there only specific cases where it works? Best, GreenTea
- 3 replies
-
- styling
- php basics
-
(and 2 more)
Tagged with:
-
Can someone help me with some conditional formatting? I'm an extreme newbie and this is the first code I have ever done, so I apologize for the simplicity. I've googled and couldn't understand what I was reading enough to get it working in the context that I need it to. Here is the php on apache accessing a MS SQL Server. The code as it is works but I want the output text to be bigger and I want a green background unless the returned value is 0, in which case I want the background to be red. Can anyone help? <?php $szQry = "SELECT COUNT (*) From dbo.MHC_LOCATION Where location_status = 'Empty' and locked_flag = 'Unlocked'"; $szDBConn = mssql_connect("madeupservername","bogususer","boguspassword"); mssql_select_db("NGK", $szDBConn); $saResults = mssql_query($szQry, $szDBConn); while($obResults = mssql_fetch_row($saResults)) { // echo $obResults[0]." ".$obResults[1]." Empty Spaces Remaining"; echo $obResults[0]." Empty Spaces Remaining"; } mssql_close($szDBConn);
-
Good morning everyone, I am trying to improve the speed of this website im working on and just improve my code in general. My pages are working, but sometimes I am getting connection errors to the database, database resides on the same server as the site, and I am aslo seeing slow load times. I am just trying to improve my code and learn the proper way to format everything, so if anyone has time please take a lot and leave some suggestions or anything you can to help. The site is www.tlgnewspaper.com if you want to take a look. <?php require_once("_includes/session.php");?> <?php require_once("_includes/connection.php");?> <?php require_once("_includes/functions.php"); ?> <?php include_once("_includes/formFunctions.php");?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>The Lafourche Gazette</title> <link type="text/css" href="_stylesheets/public.css" rel="stylesheet" /> <style type="text/css"> </style> <!--[if lt IE 9]>= <script type="text/javascript" src="_javascripts/modernizer.js"></script> <![endif]--> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type='text/javascript'>//<![CDATA[ $(window).load(function(){ (function() { function createPlayer(jqe, video, options) { var ifr = $('iframe', jqe); if (ifr.length === 0) { ifr = $('<iframe scrolling="no">'); ifr.addClass('player'); } var src = 'http://www.youtube.com/embed/' + video.id; if (options.playopts) { src += '?'; for (var k in options.playopts) { src += k + '=' + options.playopts[k] + '&'; } src += '_a=b'; } ifr.attr('src', src); jqe.append(ifr); } function createCarousel(jqe, videos, options) { var car = $('div.carousel', jqe); if (car.length === 0) { car = $('<div>'); car.addClass('carousel'); jqe.append(car); } $.each(videos, function(i, video) { options.thumbnail(car, video, options); }); } function createThumbnail(jqe, video, options) { var imgurl = video.thumbnails[0].url; var img = $('img[src="' + imgurl + '"]'); var desc; var container; if (img.length !== 0) return; img = $('<img align="left">'); img.addClass('thumbnail'); jqe.append(img); img.attr('src', imgurl); img.attr('title', video.title); img.click(function() { options.player(options.maindiv, video, $.extend(true, {}, options, { playopts: { autoplay: 1 } })); }); desk = $('<p class="yt-descript">' + video.title + '</p>'); jqe.append(desk); desk.click(function() { options.player(options.maindiv, video, $.extend(true, {}, options, { playopts: { autoplay: 1 } })); }); } var defoptions = { autoplay: false, user: null, carousel: createCarousel, player: createPlayer, thumbnail: createThumbnail, loaded: function() {}, playopts: { autoplay: 0, egm: 1, autohide: 1, fs: 1, showinfo: 1 } }; $.fn.extend({ youTubeChannel: function(options) { var md = $(this); md.addClass('youtube'); md.addClass('youtube-channel'); var allopts = $.extend(true, {}, defoptions, options); allopts.maindiv = md; $.getJSON('http://gdata.youtube.com/feeds/users/' + allopts.user + '/uploads?alt=json-in-script&format=5&callback=?', null, function(data) { var feed = data.feed; var videos = []; $.each(feed.entry, function(i, entry) { var video = { title: entry.title.$t, id: entry.id.$t.match('[^/]*$'), thumbnails: entry.media$group.media$thumbnail }; videos.push(video); }); allopts.allvideos = videos; allopts.carousel(md, videos, allopts); allopts.player(md, videos[0], allopts); allopts.loaded(videos, allopts); }); } }); })(); $(function() { $('#player').youTubeChannel({ user: 'tlgnewspaper' }); }); //]]> });//]]> function changeImage(a) { document.getElementById("img").src=a; } </script> <?php $CSS=1; require("calendar/calendar.php"); ?> </head> <body> <?php include("_includes/header.php");?> <section class = "wrapper"> <section class="col1"> <?php include("_includes/leftColumn.php");?> </section> <section class="col2"> <h1>Top News</h1> <?php include("_includes/topArticle.php");?> <?php include("_includes/newArticles.php");?> <section class = "gallery"> <h2>Newest Photos</h2> <h3>Click image to view the Gallery</h3> <div id="thumb_img" style="cursor:pointer"> <ul> <?php list ($title, $path, $description, $category) = getLastPhoto('school');?> <a><li onclick='changeImage("_images/_photo/<?php echo $path; ?>");'>School</li></a> <?php list ($title, $path, $description, $category) = getLastPhoto('clubs');?> <a><li onclick='changeImage("_images/_photo/<?php echo $path; ?>");'>Clubs</li></a> <?php list ($title, $path, $description, $category) = getLastPhoto('sports');?> <a><li onclick='changeImage("_images/_photo/<?php echo $path; ?>");'>Sports</li></a> <?php list ($title, $path, $description, $category) = getLastPhoto('user');?> <a><li onclick='changeImage("_images/_photo/<?php echo $path; ?>");'>User Submitted</li></a> </ul> </div> <div id="main_img" style="width:350px"> <?php list ($title, $path, $description, $category) = getLastPhoto('school');?> <a href="galleryChoice.php"><img id="img" width="350px" src="_images/_photo/<?php echo $path; ?>"></a> </div> </section> <section class = "test"> <h2>Video Gallery</h2> <div id="player"></div> </section> </section> <section class="col3"> <?php include("_includes/rightColumn.php");?> </section> </article> <?php include("_includes/footer.php");?>