Jump to content

StateRd84

Members
  • Posts

    8
  • Joined

  • Last visited

Everything posted by StateRd84

  1. Can you change the engine on an existing database?
  2. I would like to be able to show the post that no longer has a related category. Remember that the id in the categories table no longer exists, however the related cat_id in the posts table is still there. Here is the relevent code the first is the function used to get the posts: function get_posts($id = null, $cat_id = null) { $posts = array(); $query = "SELECT `posts`.`id` AS `post_id`, `categories`.`id` AS `category_id`, `title`, `content`, `date_posted`, `categories`.`name` FROM `posts` INNER JOIN `categories` ON `categories`.`id` = `posts`.`cat_id`"; if ( isset($id) ) { $id = (int) $id; $query .= " WHERE `posts`.`id` = '{$id}'"; echo mysql_error(); } if ( isset($cat_id) ) { $cat_id = (int) $cat_id; $query .= " WHERE `categories`.`id` = '{$cat_id}'"; } $query .= " ORDER BY `post_id` DESC"; $query = mysql_query($query); while ( $row = mysql_fetch_assoc($query) ) { $posts[] = $row; } return $posts;} The next is the page used to display the posts: <?php include_once('resources/init.php'); $posts = ( isset($_GET['id']) ) ? get_posts($_GET['id']) : get_posts();?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head> <style> ul { list-style-type: none; } li { display: inline; margin-right: 20px; } </style> <title>My Big Blog</title></head><body> <div> <ul> <li><a href="index.php"> Index </a></li> <li><a href="add_post.php"> Add Post </a></li> <li><a href="add_category.php"> Add Category </a></li> <li><a href="category_list.php"> Category List </a></li> </ul> </div><!--End of Nav division--> <div> <h1>My Big Blog</h1> <?php foreach ( $posts as $post ) { ?> <h2><a href="index.php?id=<?php echo $post['post_id']; ?>"><?php echo $post['title']; ?></a></h2> <p>Posted On: <?php echo date('m-d-Y h:i:s', strtotime($post['date_posted']) ); ?> in <a href="category.php?id=<?php echo $post['category_id']; ?>"><?php echo $post['name']; ?></a></p> <div> <?php echo nl2br($post['content']); ?> </div> <div> <ul> <li><a href="delete_post.php?id=<?php echo $post['post_id']; ?>">Delete This Post</a></li> <li><a href="edit_post.php?id=<?php echo $post['post_id']; ?>">Edit This Post</a</li> </ul> </div> <?php } ?> </div></body></html>
  3. I am still very new to php, so keep this in mind. This example comes from a tutorial. I have a database with two tables: categories table; 2 fields: `id` and `name`.posts table; 5 fields: `id`, `cat_id`, `title`, `content` and `post_date`. If I have a post entered that uses, for example, category id: 3, name: fun. I then delete that category from the categories table. The post remains with the cat_id of 3 (since it's relational). Since the id column in the categories table is auto-increment the id of 3 is never used again, so does not exist in the categories table. The problem is that that record cannot be accessed with the current code.
  4. Got it!! It worked perfect. Thanks for the advice Yes I did take the time with the Box Model.
  5. So, do not use any positioning at all? Rely on margin and padding? That's why they call it learnin', right? Thank you.
  6. I am having an issue between browsers when using absolute positioning along with percentage values. I want the elements to be able to resize along with the window size. I have attached pictures to show the results in Opera and Safari. Below is my HTML and CSS. Please help. Thanks. HTML: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>PLJ New Layout</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><link href="demo.css" rel="stylesheet" type="text/css" /></head><body><div id="header"><div id="sitebranding"></div><!--end of sitebranding division(H1)--></div><!--end of header division--><div id="tagline"></div><!--end of tagline division--><div id="bodyContainer"><div id="sidebar"></div><!--end of sidebar division--></div><!--end of container division--><div id="content"></div><!--end of content division--></body></html> CSS: /*Demo purposes only for cross browser issue*/* { padding: 0; margin: 0;}#header { position: absolute; border: 3px solid #000; background: blue; height: 15%; width: 75%; margin-top: 1%; margin-left: 12%;}#bodyContainer { position: absolute; border: 3px solid #000; background: blue; height: 80%; width: 75%; margin-top: 17%; margin-left: 12%;}
  7. The differences are with the layout of my divisions. When using absolute positioning with percentage values there are big differences in IE, Firefox and Opera. This is most prevelent with margin-top. I suppose I should switch over to the CSS forum to continue this. I have tried using pixels and there seems to be no problem. I appreciate the responses, thank you.
  8. I use Safari on a Mac to check my code. I am running into a problem with my CSS layout not rendering the same in different browsers. My solution was to create stylesheets for each browser and use a JavaScript to detect and switch stylesheets. It works great on all browsers but Firefox. Chrome works great, Opera's app.name is opera, but Firefox's app.name is netscape (same as Safari, so it chooses the Safari stylesheet). Below is my code. Please any suggestions. Oh yea, I am new here. so "Hello World"! if ((navigator.appName).indexOf("Microsoft")!=-1) { document.write('<link rel="stylesheet" href="FileName_IE.css" type="text/css">');}else if ((navigator.appName).indexOf("Firefox")!=-1) { document.write('<link rel="stylesheet" href="FileName_fox.css" type="text/css">');}else if ((navigator.appName).indexOf("Opera")!=-1) { document.write('<link rel="stylesheet" href="FileName_opera.css" type="text/css">');}else { document.write('<link rel="stylesheet" href="FileName.css" type="text/css">');}
×
×
  • Create New...