Jump to content

KevinM1

Moderators
  • Posts

    5,222
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by KevinM1

  1. First, since the original poster is a newbie, I wouldn't recommend using PHP to create new databases and tables. phpMyAdmin is far simpler in that regard. Second, a database connection script typically looks like the following: <?php /* dbconnect.php -- database connection script */ DEFINE ('HOST', 'hostName'); DEFINE ('USER', 'userName'); DEFINE ('PASSWORD', 'password'); DEFINE ('MYDB', 'dbName'); $dbc = mysql_connect(HOST, USER, PASSWORD) or DIE('Could not connect to the database: ' . mysql_error()); mysql_select_db(MYDB, $dbc) or DIE('Could not select the database: ' . mysql_error()); ?> For security reasons, you should stick this script outside of your public_html folder. You can access it by simply doing the following: require('../dbconnect.php'); You should only include it when you're going to be accessing the database.
  2. At first glance, it looks like this works...thanks! EDIT: d'oh! Now I'm getting repeated rows (ironically, the Microsoft keyboard/mouse combo that I referenced in the post above).
  3. Both queries give me 0 rows, but I know I have rows in different tables with the same name: SELECT peripherals_id, name, availability FROM peripherals WHERE peripherals_id=13; peripherals_id name availability 13 Microsoft Black PS/2 Keyboard Optical Mo y SELECT gaming_peripherals_id, name, availability FROM gaming_peripherals WHERE gaming_peripherals_id=1; gaming_peripherals_id name availability 1 Microsoft Black PS/2 Keyboard Optical Mo y As an aside, is there any way to have phpMyAdmin print out query results in the ASCII format you used? It'd no doubt look better than my mangled attempt, and it'd make it easier to display all of my table info at once.
  4. Is there any way you can contact the person who wrote the pdf class? Maybe the output method has known problems (and hopefully a fix) you're not aware of.
  5. Unfortunately, changing it to gaming_peripherals.name yields me 0 returned rows, which is obviously not right. I'm thinking I may just delete the redundancies and do a simpler join.
  6. I believe your problem is your statement. From what I've seen, that streams the pdf in question to the browser.
  7. I know this is a really late follow-up, but I'm getting a 1054 error when trying this query. Namely, it says "#1054 - Unknown column 'peripherals.name' in 'on clause' " Unfortunately, phpMyAdmin doesn't give any more error information than that. I double checked my peripherals table and, yes, there is a name column, so this error is a mystery to me.
  8. You probably have to do something with http headers. Take a look at the following link: http://www.daniweb.com/code/snippet75.html Remember, if all else fails, use Google.
  9. Bumpbump. Can anyone else suggest something non-AJAX for me to do with this issue? Am I right in thinking that the table cells stretch because the HTML is rendered before the JS is applied, thereby causing the HTML (and attached CSS) to not recognize that the info written in the cells by the JS exists? Calling Dr. Fenway...
  10. Try something like: <?php function usernamecheck($username){ if(eregi("^[a-zA-Z ]*$", $username)){ return true; } else{ return false; } } ?>
  11. I figured it out! Since I'm using a sticky form, the $_GET values weren't being set when the script was refreshed because the $_GET values were passed by the referring script only. Simply putting a hidden input in the form and an extra elseif conditional fixed it. Hooray!
  12. Right, but since I'm using an if/else conditional to specify which header info I want to send, I shouldn't be running into any problems, right? That's why I'm so stumped on this -- I'm only sending one header, which is determined by the if/else conditions.
  13. I might try that if I can't get the PHP version to work. Are header redirects in PHP just generally troublesome? I mean, almost every time I try having two different redirects in a script, one will work and the other won't, even though the syntax is correct. Case in point: I'm currently trimming down some of my other scripts. I have two back buttons -- one to the previous page, one to the index. The button that brings the user to the index works fine. The other button doesn't, as it also brings the user back to the index. (the code is: <?php if(isset($_GET['cat']) && isSafe($_GET['cat'])){ $tableName = $_GET['cat']; } . . . if(isset($_POST['back'])){ $_SESSION['ip'] = urlencode(serialize($ip)); $_SESSION['myCart'] = urlencode(serialize($myCart)); header("Location: http://www.thinkingmachinestore.com/viewcat2.php?cat=$tableName"); exit(); } if(isset($_POST['restart'])){ $_SESSION['ip'] = urlencode(serialize($ip)); $_SESSION['myCart'] = urlencode(serialize($myCart)); header("Location: http://www.thinkingmachinestore.com/"); exit(); } ?> . . . <form name="iteminfo" action="<?php echo $_SERVER[php_SELF]; ?>" method="post" style="margin-left: auto; margin-right: auto; text-align: center;"> <input type="submit" name="back" value="Go Back" /> <input type="submit" name="restart" value="Go Back to the Beginning" /> </form> ) Does PHP not allow two different redirects in one script? Or does its header handling abilities more or less stink? I honestly at a loss when it comes to this.
  14. This is actually an old problem that I've brought up here before, but no one was able to help me solve it. I have a "Go Back" form button in a script that I want to redirect the user back to the index page in most cases, but to a different page if they came from that different page. I've tried using $_SERVER[HTTP_REFERER] and checking for the values passed by $_GET (inventory categories/database table names), and neither method works. Instead, I always get redirected back to the index page. My code is below: <?php #viewcat.php script session_start(); ob_start(); include('../php_config/config.php'); include('../dbconnect.php'); include('../templates/sub_header.inc'); include('../templates/isSafe.php'); if(isset($_GET['cat']) && isSafe($_GET['cat'])){ $tableName = $_GET['cat']; } else{ $_SESSION['ip'] = urlencode(serialize($ip)); $_SESSION['myCart'] = urlencode(serialize($myCart)); header("Location: http://www.thinkingmachinestore.com/"); exit(); } //This is the offending block of code ---------------------------- if(isset($_POST['submit'])){ if($_SERVER[HTTP_REFERER] == "http://www.thinkingmachinestore.com/thinkingmachine.php"){ $_SESSION['ip'] = urlencode(serialize($ip)); $_SESSION['myCart'] = urlencode(serialize($myCart)); error_reporting(0); //someone told me that putting an error_reporting statement may help. I dunno why, but unsurprisingly, it didn't. header("Location: http://www.thinkingmachinestore.com/thinkingmachine.php"); exit(); } //-------------------------------------------------------------- else{ $_SESSION['ip'] = urlencode(serialize($ip)); $_SESSION['myCart'] = urlencode(serialize($myCart)); header("Location: http://www.thinkingmachinestore.com/"); exit(); } } $query = "SELECT * FROM $tableName WHERE availability='y' ORDER BY price ASC"; $result = mysql_query($query); echo "<div style='margin-left: auto; margin-right: auto; text-align: center;'><a href='viewcart.php'><img src='images/store/storefront_02.jpg' alt='' /></a><img src='../images/store/{$tableName}_banner.jpg' alt='' style='margin-top: 5px;' /><a href='checkout.php'><img src='../images/store/storefront_02a.jpg' alt='View Cart' /></a>\n<br /><br />\n"; if(mysql_num_rows($result) == 0){ echo "All items of this category are currently out of stock. Please check here again at a later time for product availability.<br />We apologize for any inconvenience this may cause."; } else{ $count = 0; while($row = mysql_fetch_assoc($result)){ $id = $row["$tableName" . "_id"]; $pic = $row["pic_url"]; echo "<a href='viewitem.php?cat=$tableName&id=$id'><img src='$pic' alt='' /></a>"; $count++; if($count == 2){ echo "<hr /><br />\n"; $count = 0; } } } ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <input type="submit" name="submit" value="Go Back" /> </form></div> <?php include('../templates/sub_footer.inc'); ?> Please help.
  15. What you're describing is 1) way out of my league. I really don't want to deal with a three or four dimensional array if I can help it, let alone all of the AJAX stuff that I don't know how to do. 2) is too complicated/involved for what I'm trying to do...I'm not designing an intranet calender application, just something quick and dirty that works. 3) not related to my problem in any event. I'm merely trying to get each table's <td> to be rendered in a consistant size throughout. If you actually looked at my CSS, you'd see that I do set an explicit width and height for my <td> elements (76px x 76px), as well as set their overflow to auto. It doesn't work. I'm thinking that the problem is that the CSS cannot see the text within the cells, since they're filled after the page is rendered via my JS script, so it doesn't know to apply the correct overflow value. I originally had everything written to the calender via innerHTML, but that left me with cells of different sizes. I switched to the W3C-approved createWhatever/appendChild method, as you can see above, and that still didn't fix my cell size issue. Short of switching to a server-side option (which would be difficult as my host doesn't have PHP, and I'm pretty damned rusty when it comes to Perl or C++), is there anything - within reason - that I can do to enforce consistantly sized cells, or will I just have to make do with what I have?
  16. Unfortunately, createElement, createTextNode, and appendChild didn't fix my problem. Here's a more detailed rundown of what's happening and what I want. I have a calender in which appointments can be entered and the color of the day chosen depending on what's entered into the script. It's not an elegant solution, but it works well enough. Each calender month is a table, which is hard-coded right into the HTML. The script populates these tables with the appropriate dates, apppointments, and background colors. Unfortunately, my appointment text causes the calender's table cells to stretch, both horizontally and vertically, making the days without any appointments look squished. I've tried setting the cells' width, height, and overflow properties in the hopes of getting a more uniform shape, but nothing has worked. Is it impossible to keep the calendars looking uniform, given that they're populated by JavaScript? Or am I going about it the wrong way? Below is my code. HTML: <table class="calendar" id="January" cellspacing="0" cellpadding="5" style="display: none;"> <tr> <th colspan="7">January</th> </tr> <tr> <th>Sun</th><th>Mon</th><th>Tue</th><th>Wed</th><th>Thu</th><th>Fri</th><th>Sat</th> </tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> </table> <table class="calendar" id="February" cellspacing="0" cellpadding="5" style="display: none;"> <tr> <th colspan="7">February</th> </tr> <tr> <th>Sun</th><th>Mon</th><th>Tue</th><th>Wed</th><th>Thu</th><th>Fri</th><th>Sat</th> </tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> </table> <table class="calendar" id="March" cellspacing="0" cellpadding="5" style="display: none;"> <tr> <th colspan="7">March</th> </tr> <tr> <th>Sun</th><th>Mon</th><th>Tue</th><th>Wed</th><th>Thu</th><th>Fri</th><th>Sat</th> </tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> </table> <table class="calendar" id="April" cellspacing="0" style="display: auto;"> <tr> <th colspan="7">April</th> </tr> <tr> <th>Sun</th><th>Mon</th><th>Tue</th><th>Wed</th><th>Thu</th><th>Fri</th><th>Sat</th> </tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> </table> <table class="calendar" id="May" cellspacing="0" cellpadding="5" style="display: auto;"> <tr> <th colspan="7">May</th> </tr> <tr> <th>Sun</th><th>Mon</th><th>Tue</th><th>Wed</th><th>Thu</th><th>Fri</th><th>Sat</th> </tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> </table> <table class="calendar" id="June" cellspacing="0" cellpadding="5" style="display: auto;"> <tr> <th colspan="7">June</th> </tr> <tr> <th>Sun</th><th>Mon</th><th>Tue</th><th>Wed</th><th>Thu</th><th>Fri</th><th>Sat</th> </tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> </table> <table class="calendar" id="July" cellspacing="0" cellpadding="5" style="display: none;"> <tr> <th colspan="7">July</th> </tr> <tr> <th>Sun</th><th>Mon</th><th>Tue</th><th>Wed</th><th>Thu</th><th>Fri</th><th>Sat</th> </tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> </table> <table class="calendar" id="August" cellspacing="0" cellpadding="5" style="display: none;"> <tr> <th colspan="7">August</th> </tr> <tr> <th>Sun</th><th>Mon</th><th>Tue</th><th>Wed</th><th>Thu</th><th>Fri</th><th>Sat</th> </tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> </table> <table class="calendar" id="September" cellspacing="0" cellpadding="5" style="display: none;"> <tr> <th colspan="7">September</th> </tr> <tr> <th>Sun</th><th>Mon</th><th>Tue</th><th>Wed</th><th>Thu</th><th>Fri</th><th>Sat</th> </tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> </table> <table class="calendar" id="October" cellspacing="0" cellpadding="5" style="display: none;"> <tr> <th colspan="7">October</th> </tr> <tr> <th>Sun</th><th>Mon</th><th>Tue</th><th>Wed</th><th>Thu</th><th>Fri</th><th>Sat</th> </tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> </table> <table class="calendar" id="November" cellspacing="0" cellpadding="5" style="display: none;"> <tr> <th colspan="7">November</th> </tr> <tr> <th>Sun</th><th>Mon</th><th>Tue</th><th>Wed</th><th>Thu</th><th>Fri</th><th>Sat</th> </tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> </table> <table class="calendar" id="December" cellspacing="0" cellpadding="5" style="display: none;"> <tr> <th colspan="7">December</th> </tr> <tr> <th>Sun</th><th>Mon</th><th>Tue</th><th>Wed</th><th>Thu</th><th>Fri</th><th>Sat</th> </tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> </table> CSS: .calendar{ margin: 0 0 2px 0; width: 525px; } .calendar th{ padding: 5px; width: 76px; border: 1px solid #000000; text-align: center; } .calendar td{ border: 1px solid #000000; padding: 5px; width: 76px; height: 76px; overflow: auto; text-align: right; } JavaScript: var W3CDOM = (document.createElement && document.getElementsByTagName); var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; var numDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; //Number of days in each month...be sure to make February equal to 29 on leap years var firstDays = [2, 5, 5, 1, 3, 6, 1, 4, 7, 2, 5, 7]; //1 = Sunday, 2 = Monday, etc. var apps = [ [16, 4, 16, 4, "AMITY I 8:30 - 11:30", "amity"], [16, 4, 16, 4, "Word II 6:00 - 9:00", "amity"], [17, 4, 17, 4, "Excel II 9:00 - 4:00", "microsoft"], [17, 4, 17, 4, "PowerPoint II 6:00 - 9:00", "microsoft"], [18, 4, 18, 4, "PowerPoint I 9:00 - 4:00", "microsoft"], [18, 4, 18, 4, "Word II 6:00 - 9:00", "microsoft"], [19, 4, 19, 4, "AMITY II 8:30 - 11:30", "amity"], [19, 4, 19, 4, "PowerPoint II 9:00 - 4:00", "amity"], [20, 4, 20, 4, "Access III 9:00 - 4:00", "microsoft"], [21, 4, 21, 4, "Into to Vista 9:00 - 11:00", "microsoft"], [23, 4, 23, 4, "Excel II 6:00 - 9:00", "microsoft"], [24, 4, 24, 4, "Access II 6:00 - 9:00", "microsoft"], [25, 4, 25, 4, "Excell II 6:00 - 9:00", "microsoft"], [26, 4, 26, 4, "BOSC 9:00 - 4:00", "bosc"], [26, 4, 26, 4, "Access II 6:00 - 9:00", "bosc"], [28, 4, 28, 4, "Intro to Vista 9:00 - 11:00", "microsoft"], [30, 4, 30, 4, "AMITY I 8:30 - 11:30", "amity"], [30, 4, 30, 4, "Word I 9:00 - 4:00", "amity"], [30, 4, 30, 4, "Word I 6:00 - 9:00", "microsoft"], [1, 5, 1, 5, "Excel III 9:00 - 4:00", "microsoft"], [1, 5, 1, 5, "PowerPoint I 6:00 - 9:00", "microsoft"], [2, 5, 2, 5, "Powerpoint II 9:00 - 4:00", "microsoft"], [2, 5, 2, 5, "Word I 6:00 - 9:00", "microsoft"], [3, 5, 3, 5, "AMITY II 8:30 - 11:30", "amity"], [3, 5, 3, 5, "BOSC 9:00 - 4:00", "amity"], [3, 5, 3, 5, "PowerPoint I 6:00 - 9:00", "amity"], [4, 5, 4, 5, "Access I 9:00 - 4:00", "microsoft"], [5, 5, 5, 5, "Intro to Vista 9:00 - 11:00", "microsoft"], [7, 5, 7, 5, "Word II 9:00 - 4:00", "microsoft"], [7, 5, 7, 5, "Excel I 6:00 - 9:00", "microsoft"], [8, 5, 8, 5, "Excel I 9:00 - 4:00", "microsoft"], [8, 5, 8, 5, "Access I 6:00 - 9:00", "microsoft"], [9, 5, 9, 5, "PowerPoint III 9:00 - 4:00", "microsoft"], [9, 5, 9, 5, "Excel I 6:00 - 9:00", "microsoft"], [10, 5, 10, 5, "BOSC 9:00 - 4:00", "bosc"], [10, 5, 10, 5, "Access I 6:00 - 9:00", "bosc"], [11, 5, 11, 5, "Access II 9:00 - 4:00", "microsoft"], [12, 5, 12, 5, "Intro to Vista 9:00 - 11:00", "microsoft"], [14, 5, 14, 5, "Word III 9:00 - 4:00", "microsoft"], [14, 5, 14, 5, "Word II 6:00 - 9:00", "microsoft"], [15, 5, 15, 5, "Excel II 9:00 - 4:00", "microsoft"], [15, 5, 15, 5, "PowerPoint II 6:00 - 9:00", "microsoft"], [16, 5, 16, 5, "PowerPoint I 9:00 - 4:00", "microsoft"], [16, 5, 16, 5, "Word II 6:00 - 9:00", "microsoft"], [17, 5, 17, 5, "BOSC 9:00 - 4:00", "bosc"], [17, 5, 17, 5, "PowerPoint II 6:00 - 9:00", "bosc"], [18, 5, 18, 5, "Access III 9:00 - 4:00", "microsoft"], [19, 5, 19, 5, "Intro to Vista 9:00 - 11:00", "microsoft"], [21, 5, 21, 5, "Excel II 6:00 - 9:00", "microsoft"], [22, 5, 22, 5, "Access II 6:00 - 9:00", "microsoft"], [23, 5, 23, 5, "Excel II 6:00 - 9:00", "microsoft"], [24, 5, 24, 5, "BOSC 9:00 - 4:00", "bosc"], [24, 5, 24, 5, "Access II 6:00 - 9:00", "bosc"], [26, 5, 26, 5, "Intro to Vista 9:00 - 11:00", "microsoft"], [28, 5, 28, 5, "Word I 9:00 - 4:00", "microsoft"], [28, 5, 28, 5, "Word I 6:00 - 9:00", "microsoft"], [29, 5, 29, 5, "Excel III 9:00 - 4:00", "microsoft"], [29, 5, 29, 5, "PowerPoint I 6:00 - 9:00", "microsoft"], [30, 5, 30, 5, "PowerPoint II 9:00 - 4:00", "microsoft"], [30, 5, 30, 5, "Word I 6:00 - 9:00", "microsoft"], [31, 5, 31, 5, "BOSC 9:00 - 4:00", "bosc"], [31, 5, 31, 5, "PowerPoint I 6:00 - 9:00", "bosc"], [1, 6, 1, 6, "Access I 9:00 - 4:00", "microsoft"], [2, 6, 2, 6, "Intro to Vista 9:00 - 11:00", "microsoft"], [4, 6, 4, 6, "Word II 9:00 - 4:00", "microsoft"], [4, 6, 4, 6, "Excel I 6:00 - 9:00", "microsoft"], [5, 6, 5, 6, "Excel I 9:00 - 4:00", "microsoft"], [5, 6, 5, 6, "Access I 6:00 - 9:00", "microsoft"], [6, 6, 6, 6, "PowerPoint III 9:00 - 4:00", "microsoft"], [6, 6, 6, 6, "Excel I 6:00 - 9:00", "microsoft"], [7, 6, 7, 6, "BOSC 9:00 - 4:00", "bosc"], [7, 6, 7, 6, "Access I 6:00 - 9:00", "bosc"], [8, 6, 8, 6, "Access II 9:00 - 4:00", "microsoft"], [9, 6, 9, 6, "Intro to Vista 9:00 - 11:00", "microsoft"], [11, 6, 11, 6, "Word III 9:00 - 4:00", "microsoft"], [11, 6, 11, 6, "Word II 6:00 - 9:00", "microsoft"], [12, 6, 12, 6, "Excel II 9:00 - 4:00", "microsoft"], [12, 6, 12, 6, "PowerPoint II 6:00 - 9:00", "microsoft"], [13, 6, 13, 6, "PowerPoint I 9:00 - 4:00", "microsoft"], [13, 6, 13, 6, "Word II 6:00 - 9:00", "microsoft"], [14, 6, 14, 6, "BOSC 9:00 - 4:00", "bosc"], [14, 6, 14, 6, "PowerPoint II 6:00 - 9:00", "bosc"], [15, 6, 15, 6, "Access III 9:00 - 4:00", "microsoft"], [16, 6, 16, 6, "Intro to Vista 9:00 - 11:00", "microsoft"], [18, 6, 18, 6, "Excel II 6:00 - 9:00", "microsoft"], [19, 6, 19, 6, "Access II 6:00 - 9:00", "microsoft"], [20, 6, 20, 6, "Excel II 6:00 - 9:00", "microsoft"], [21, 6, 21, 6, "BOSC 9:00 - 4:00", "bosc"], [21, 6, 21, 6, "Access II 6:00 - 9:00", "bosc"], [23, 6, 23, 6, "Intro to Vista 9:00 - 11:00", "microsoft"], [25, 6, 25, 6, "Word I 9:00 - 4:00", "microsoft"], [25, 6, 25, 6, "Word I 6:00 - 9:00", "microsoft"], [26, 6, 26, 6, "Excel III 9:00 - 4:00", "microsoft"], [26, 6, 26, 6, "PowerPoint I 6:00 - 9:00", "microsoft"], [27, 6, 27, 6, "PowerPoint II 9:00 - 4:00", "microsoft"], [27, 6, 27, 6, "Word I 6:00 - 9:00", "microsoft"], [28, 6, 28, 6, "BOSC 9:00 - 4:00", "bosc"], [28, 6, 28, 6, "PowerPoint I 6:00 - 9:00", "bosc"], [29, 6, 29, 6, "Access I 9:00 - 4:00", "microsoft"], [30, 6, 30, 6, "Intro to Vista 9:00 - 11:00", "microsoft"] ]; // Format is: Appt start day, appt start month, appt end day, appt end month, appt description, appt category function init(){ if(!W3CDOM) return; printCalendar(); } function printCalendar(){ for(var i = 0; i < 12; i++){ printMonth(i); } } function printMonth(monthNum){ var month = document.getElementById(months[monthNum]); var days = month.getElementsByTagName('td'); var date = 1; var start = firstDays[monthNum] - 1; var dayText; var dayInfo; var tmpText; for(var i = 0; i < days.length; i++){ //To make the bottom row look pretty if its cells are empty days[i].innerHTML = " "; } for (i = start; date <= numDays[monthNum]; i++){ dayInfo = checkDate(monthNum, date); days[i].style.backgroundColor = dayInfo[0]; days[i].style.color = dayInfo[1]; days[i].setAttribute("title", dayInfo[2]); var span = document.createElement('span'); dayText = date++; span.style.fontWeight = 'bold'; span.appendChild(document.createTextNode(dayText)); days[i].appendChild(span); days[i].appendChild(document.createElement('br')); days[i].appendChild(document.createElement('br')); for(var j = 0; j < dayInfo[2].length; j++){ tmpText = dayInfo[2][j]; days[i].appendChild(document.createTextNode(tmpText)); days[i].appendChild(document.createElement('br')); days[i].appendChild(document.createElement('br')); } } } function checkDate(monthNum, dayNum){ var output = new Array(); var desc = new Array(); var bgColor = ""; var color = ""; var index = 0; for(var i = 0; i < apps.length; i++){ if((monthNum + 1) >= apps[i][1] && (monthNum + 1) <= apps[i][3]){ //if we're in the range of the appointment's months if(apps[i][1] == apps[i][3]){ // if the appointment takes place in just one month if(dayNum >= apps[i][0] && dayNum <= apps[i][2]){ // setting the range of dates in that month desc[index++] = apps[i][4]; bgColor = apps[i][5]; } } else if((monthNum + 1) == apps[i][1]){ //if we're in the first month of an appointment that goes over the end of the start month if(dayNum >= apps[i][0]){ // if the date is greater or equal to the starting date of the appointment desc[index++] = apps[i][4]; bgColor = apps[i][5]; } } else if((monthNum + 1) == apps[i][3]){ // if we're in the last month of an appointment that goes over the end of the start month if(dayNum <= apps[i][2]){ // if the date is less than or equal to the ending date of the appointment desc[index++] = apps[i][4]; bgColor = apps[i][5]; } } else{ // if we're somewhere in between a multi-month appointment desc[index++] = apps[i][4]; bgColor = apps[i][5]; } } } if(bgColor == "microsoft"){ bgColor = "#284DBF"; color = "#FFFFFF"; } else if(bgColor == "amity"){ bgColor = "#D10000"; color = "#FFFFFF"; } else if(bgColor == "bosc"){ bgColor = "#000000"; color = "#FFFFFF"; } else{ bgColor = "white"; } output[0] = bgColor; output[1] = color; output[2] = desc; return output; } window.onload = init;
  17. I currently have a calender script in which the dates of the month and whatever appointments it has are displayed using innerHTML. Unfortunately, this method makes it so my external CSS file can't 'see' that info, so no styling can be applied to it. Would changing innerHTML to a createTextNode/appendChild combo make it so my CSS file could style the calender's information? Or would I have to go another route?
  18. Yeah, yeah, I know. I thought I had it figured out, too. To recap: my problem is that I want to print out all rows from three tables where the availability column of each table is equal to 'y' and, in the case of rows of two or more tables having the same value in their name columns, only one of them should be returned. Admittedly, this would be far simpler if my databases were normalized. Unfortunately, this project has mutated throughout its lifespan, so normalization was ignored in favor of "do it...now." That being said, when given the opportunity, I will normalize this database, but I digress. My tables have the following format, with the value 'table_name_id' as a stand-in for gaming_peripherals_id, office_peripherals_id, and peripherals_id respectively: table_name_id TINYINT(3) NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(40) NOT NULL, price FLOAT, availability CHAR(1), description TEXT, pic_url TEXT Unfortunately, MySQL syntax is a weak point for me, so I'm at a loss on how to retrieve the information I want in the way specified above. From my research, a NATURAL JOIN looks like it would do the trick (more or less, any way), but it's not available in my version of MySQL (4.1.92, I believe). I got an INNER JOIN to work, but it was based on the id numbers of each table. Unfortunately, this limits my results to the lowest number of rows found in the collection of tables. And to be honest, LEFT/RIGHT JOINS are a bit...frightening with their syntax. Any help would be greatly appreciated. Thanks.
  19. Damned cross joins....topic solved!
  20. Unfortunately, it looks like I can't edit my previous post, so forgive this bump. It appears as though my joins are multiplying the number of rows from one table with another. In other words, when I try a simple join like: Instead of getting 23 rows back (14 from the first table, 9 from the second), I get 126 back (14 x 9).
  21. That removed my syntax error, but now I have a rather large logic error. I've modified my query to be: Instead of removing duplicate entries, I have each item in the tables represented dozens of times. So, for instance, the keyboard/mouse combo we offer, which only has, at most, two entries in the entire database (one in gaming_peripherals, one just in peripherals), is displayed over 30 times as the result of this join. Any ideas on where I'm going wrong? Because I figure my 'AND' conditions would limit what should be shown, not increase what is shown. EDIT: This is odd...I've used a test query that just says Now, I'd think it would just return the 46 total items that are in those tables. Instead, I get 2,898 items returned to me. What the heck??
  22. I'm trying to do an inner join with three tables. Each contain computer peripherals, but they all represent a different category of peripheral. Unfortunately, as I've been building the database as I go, there are some duplicates across tables, which makes printing out the entire list slightly more complicated than it should be. I figured the easiest way for me to exclude the duplicates would be to just not include the items that have the same name across tables (although, thinking about it more, I dunno if that would actually work). Unfortunately, I'm getting a PHP error stating that my query isn't generating a valid MySQL resource to work with. My table structure is the following (same for all three tables, with the exception of their respective id names): table_name_id: TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY name: VARCHAR(40) NOT NULL price: FLOAT availability: CHAR(1) description: TEXT pic_url: TEXT The query I'm trying to execute is: <?php $query = "SELECT * FROM gaming_peripherals AS gp, office_peripherals AS op, peripherals AS p WHERE gp.name != p.name AND op.name != p.name AND availability='y' ORDER BY price ASC"; $result = mysql_query($query); //HTML output for a few lines here if(mysql_num_rows($result) == 0){ echo "All items of this category are currently out of stock. Please check here again at a later time for product availability.<br />We apologize for any inconvenience this may cause."; } ?> And the error message is: Is my syntax valid? Or could I be missing something else? This is the only query I make to the database, so there's no cross-contamination, so to speak.
  23. I knew it had to be something simple. Thanks!
  24. I have one of those classic "my site looks different in IE than it does in FF" problems. In IE7, my site looks perfect. In FF...not so much. In FF, the site is not centered, despite using "margin-left: auto; margin-right: auto; text-align: center;" on the containing block. Also, the top margin I apply to my navigation menu isn't being applied by FF. My site can be found at: http://www.nightslyr.com/helga/index.html. Please help me. Thanks
  25. Sorry for the delay in responding, but I just tried this and it didn't work either. Any other ideas?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.