Jump to content

nodirtyrockstar

Members
  • Posts

    108
  • Joined

  • Last visited

Everything posted by nodirtyrockstar

  1. Oh hey Jessica, sorry, I didn't see your reply. What I meant is that I have one ID that should only appear in one row in one of my two tables. The query I posted above seems to work. Thank you!
  2. Alrighty, I tried a number of different approaches and came up with this: SELECT * FROM `records` WHERE id = 'ccr-01-001' UNION SELECT * FROM `merch` WHERE id = 'ccr-01-001';
  3. I tried this and it is saying my field name is ambiguous.
  4. Am I making this too hard? Can I just write: SELECT * FROM tbl1, tbl2 WHERE id = tmpId; ??
  5. I am a beginner with MySQL and was wondering what method advanced users would recommend to perform the simple task of looking through two tables to find one row. I don't need code from you, just a general idea of what type of query is best for this situation. If you can offer an explanation of why you like the method, that's even better. Thanks!
  6. Yeah, something about that font I was using just wouldn't go. The font-kits at font squirrel are working. Thanks
  7. I am having a problem with a webfont I got from Google. It only works in IE, which I found amusing. Here is the CSS font-face declaration: @font-face { font-family:BerkshireSwash-Regular; src: url('../font/BerkshireSwash-Regular.eot'); src: url('../font/BerkshireSwash-Regular.eot?#iefix') format('embedded-opentype'), url('../font/BerkshireSwash-Regular.otf') format('opentype'), url('../font/BerkshireSwash-Regular.woff') format('woff'), url('../font/BerkshireSwash-Regular.ttf') format('truetype'), url('../font/BerkshireSwash-Regular.svg#BerkshireSwash-Regular'), format('svg'); font-weight: normal; font-style: normal; } h1, h2, h3, h4, h5, h6 { font-family: 'BerkshireSwash-Regular', 'Times New Roman', serif; text-align: center; } I checked it in the newest version of the top five browsers: Opera, FF, IE, Chrome, and Safari. As I said, IE is the only one that's correctly interpreting the font files. I have all the sources uploaded to my server as well, eot, ttf, woff, ttf, and svg. I also made sure to add all the MIME types to my .htaccess. AddType "application/vnd.ms-fontobject" .eot AddType "application/x-font-opentype" .otf AddType "application/x-font-truetype" .ttf AddType "application/x-font-ttf" .ttf AddType "application/x-font-woff" .woff AddType "image/svg+xml" .svg Does anyone have any suggestions? Let me know if you need more information.
  8. @Muddy Funster, I think you're right. The functionality is already there to do it without JS (load the pages with a $_GET request). I'll just drop the links in the <noscript> area. Since there aren't many, it won't look suspicious to have a little gap before the footer.
  9. Generally speaking, I have a love/hate relationship with Javascript. That said, I am trying to clean up my website for a new job and would like to demonstrate that I can use JS without giving up functionality. I have a page that demonstrates the websites in my portfolio. There are submenus under the main navigation. When you are on the webs page, switching between submenu items is done with Javascript. I would like to make that content available to users with JS disabled. I had the bright idea to stick it inside the <noscript> tags, but that stretches out my page container with invisible content even if you are using JS. Has anyone gone through this before? Does anyone have any thoughts about how to make this content available for JS disabled users without removing the Javascript? Thanks in advance!
  10. Yessssssss! @Requinix, totally worked! Thank you!
  11. I am not sure what is meant by "the result of this link." That said, it is not too hard to evaluate a boolean and render a variable image based on the results. Still, if you want help in here you are going to need to be more specific. Someone could write you a function, but they're going to need to see some code.
  12. I think I know the answer to this, but am hoping someone can help me. Here is the button code: <form action='writing.php' method='get'><input type='submit' class='sbmt' value='Journalism' name='lnk' /></form> I want the button value to be "Journalism," but I would like it if the text sent in the $_GET request was shortened to four letters, for example 'jour'. I have other links like this one that have spaces in the text and I don't want that in my links. My goal is to have a link that loads a new script and specifies a single four letter variable. I could use $_POST, but thought I would check with the experts and see if anyone had a suggestion that would work given the current set up. Can anyone think of a way to make that happen?
  13. This is what finally did it for me: #tabmenu { width: 985px; margin: 0 auto 10px; height: 40px; border-bottom: 1px #fff solid; position: relative; } #tabmenu ul { float: right; } #tabmenu a{ background-color: #000; color: #fff; width:150px; height:40px; line-height: 40px; float: right; text-align:center; text-decoration: none; display: block; } #tabmenu a:hover { color: #999; opacity: 0.7; filter: alpha(opacity=70); -khtml-opacity: 0.7; -moz-opacity: 1; } #tabmenu a.active{ background-color: #fff; color:#000; } #tabmenu li { position: relative; display: block; float: left; } #tabmenu ul ul { visibility: hidden; position: absolute; left: 0; top: 100%; } #tabmenu ul ul > li { float: none; } #tabmenu li:hover > ul { visibility: visible; }
  14. Hello fellow coders! I am trying to use tutorials to understand how to make dropdown menus with CSS3. So far so good, except for one little snag. Let me begin by showing you my HTML: <nav id='tabmenu'> <ul> <li><h2><a href='about.php' class='inactive'tabindex='4'>About</a></h2></li> <li><h2><a href='flash.php' class='inactive'tabindex='4'>Flash</a></h2></li> <li><h2><a href='writing.php' class='inactive'tabindex='4'>Writing</a></h2> <ul> <li> <a href='#' class='inactive' id='tech' onclick='toggleWritingType(this)' tabindex='10'>Technical</a> <a href='#' class='inactive' id='jour' onclick='toggleWritingType(this)'' tabindex='9'>Journalism</a> </li> </ul> </li> <li><h2><a href='design.php' class='inactive'tabindex='4'>Design</a></h2></li> <li><h2><a href='webs.php' class='active' tabindex='4'>Webs</a></h2> <ul> <li><a href='#' class='active' id='cobra' onclick='toggleSShots(this)' tabindex='9'>Cobra Cabana</a></li> <li><a href='#' class='inactive' id='hughes' onclick='toggleSShots(this)' tabindex='10'>Hughes, PhD</a></li> <li><a href='#' class='inactive' id='rasche' onclick='toggleSShots(this)' tabindex='11'>Rasche</a></li> </ul> </li> </ul> </nav> So, as you can see I have two submenus, and potentially one more if I can get this working. The tuts I found online created an absolute position for one submenu, which does not apply well to the second menu since they should not be in the exact same location. I think I now have a good understanding about how to use CSS3 to make submenus appear and reappear, but I'm not so clear on the placement. Is there a way to write one rule that applies to any submenu to appear beneath (relative to) it's parent <ul>? Here is my CSS for the nav: #tabmenu { width: 985px; margin: 0 auto 10px; height: 40px; border-bottom: 1px #fff solid; } #tabmenu a{ background-color: #000; color: #fff; width:150px; height:40px; line-height: 40px; float: right; text-align:center; text-decoration: none; } #tabmenu a.inactive:hover { color: #999; opacity: 0.7; filter: alpha(opacity=70); -khtml-opacity: 0.7; -moz-opacity: 1; } #tabmenu a.active, #tabmenu ul a.active { background-color: #fff; color:#000; } #tabmenu ul ul { display: none; } #tabmenu li:hover > ul { //This is the major area of concern, I believe. display: block; top: 40px; position: relative; height: 120px; width: 150px; } I made a fiddle: http://jsfiddle.net/cTcVT/ Thanks!
  15. What if all I want is a list of all of the IDs? SELECT `id` FROM products UNION SELECT `id` FROM merch; ??
  16. Merch contains one type of product, and products contains another type of product. (I need to rename it, I know...) CREATE TABLE `products` (\ `img` varchar(20) NOT NULL default '../img/albumArt2.gif', `id` varchar(20) NOT NULL, `artist` varchar(30) NOT NULL, `title` varchar(30) NOT NULL, `label` varchar(30) NOT NULL, `year` year(4) NOT NULL, `price` decimal(11,2) unsigned NOT NULL, `qty` int(11) unsigned NOT NULL, `desc` varchar(255) NOT NULL, `agedOff` tinyint(1) unsigned NOT NULL default '0', PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 CREATE TABLE `merch` ( `img` varchar(20) NOT NULL default '../img/albumArt2.gif', `id` varchar(20) NOT NULL, `title` varchar(30) NOT NULL, `size` varchar(3) NOT NULL, `color` varchar(10) NOT NULL, `sex` varchar(6) NOT NULL default 'Unisex', `price` decimal(11,2) unsigned NOT NULL, `qty` int(11) unsigned NOT NULL, `desc` varchar(255) NOT NULL, `agedOff` tinyint(1) unsigned NOT NULL default '0', PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 What I would like to do is just get a list of all the product IDs in both tables.
  17. BTW, session variables allow you to persist memory on the server for the duration of the session. You can create new ones by assigning new variables, like I did above. It's pretty basic stuff.
  18. I recommend that your "next" field be a HTML <input /> tag with type "image." You will set the source, etc. It will need to be contained within a form tag and the action (should you decide to go with PHP) will just be to reload the script. You will need to add a check in the script to identify if that button was clicked, and thus trigger the update. You can do so by adding a name attribute to your input. The result will be something like this: <form action='reload_current_page.php' method='post'><input alt='Advance one month' type='image' src='filepath_to_your_image' name='next' title='Advance one month' /></form> As for the check in the script, you can write: if (!empty($_POST['next'])) { $_SESSION['today']['month'] = $_SESSION['today']['month']++ //(you will assign this differently depending on how you define your date variable. I used the increment operator to signify adding on one month) //This is where you would manipulate the variables if the key is pressed. } Of course, this does not cover any aspect of security, other than avoiding the pitfalls of using $_GET...
  19. Can anyone help me understand why the following query: SELECT products.id, merch.id FROM products, merch; Would return the results from the product table two times, and the results from the merch table three times? Right now there is just dummy content in my tables (two products in one, and three in the other), and there is no duplication. Let me know if you need more information. I am sure (hoping) it is something simple that I am doing wrong.
  20. When a user browses through my client's merchandise, they should be able to click on a product image at any time to retrieve a description, details, and larger image(s), of the product. Given the way the site is constructed, it will require a query to the database, and I would like for it to open in a new window so that the shopper does not lose their place. I have a general plan for how to accomplish this. Each product will need a dynamically generated link/submit button. It will open in a new window by using the target='_blank' attribute. I can use either post or get to query the product ID which will allow the new script to query the DB and echo the results to the page. My question is, are there any security risks? This website is generally pretty secure as the only customer input is unsigned integers, and all the get/post requests are validated. Since this is my first cart I just wanted to see if there are any recommended best practices or potential vulnerabilities for which I should plan.
  21. This was extremely helpful for learning some new things! Here's the final snippet that really nailed it down perfectly: $meta = $stmt->result_metadata(); while ($field = $meta->fetch_field()) { $params[] = &$row[$field->name]; } if (!call_user_func_array(array($stmt, 'bind_result'), $params)) { echo "Binding results failed: (" . $stmt->errno . ") " . $stmt->error; } while ($stmt->fetch()) { $x = array(); foreach ($row as $key => $val) { $x[$key] = $val; if ($key === 'id') { $id = $val; } } $prodDetail[$id] = $x;
  22. Thank you for jumping in. I think Barand was trying to get at something similar to what you were saying previously, but I did not understand how. First, I took your advice about modifying the query. Since I already have the search keys in the post array, I don't have to bind my parameters at call time. I thus edited the query string and tested it, and I know it works with the new changes. Now I should have one set of results for all the products a user adds to their cart. As for processing the results, this is where I still need help. If I do this: if (!$stmt = $mysqli->prepare($query)) { echo "Prepare failed: (" . $mysqli->errno . ") " . $mysqli->error; } if (!$stmt->execute()) { echo "Execute failed: (" . $stmt->errno . ") " . $stmt->error; } if (!call_user_func_array(array($stmt, 'bind_result'), $columns)) { echo "Binding results failed: (" . $stmt->errno . ") " . $stmt->error; } while ($stmt->fetch()) { $prodDetail[$id] = $columns; if($_POST['cart'][$id] > $prodDetail[$id]['qty']) { echo "You requested " . $_POST['cart'][$id] . " copies of $title, and we only have $qty in stock. We put our remaining stock into your cart.<br /><br />"; $prodDetail[$id]['reqQty'] = $qty; } else { $prodDetail[$id]['reqQty'] = $_POST['cart'][$id]; } } I still end up with the same referencing problem. I am copying pointers, instead of values, to my $prodDetail array, which results in my entire array being populated with copies of the last result row from the query. I am trying to think of what you mean by this:
  23. That did not work for me. I think a key difference between my code and yours is that my $columns arrays don't contain anything. They are initialized as arrays with keys that have no values set yet.
  24. I have gotten this far with it: function prodArr() { if (!empty($_POST['cart'])) { global $dbType; $prodDetail = array(); $columns = array(); $data = array(); $img = ''; $artist = ''; $title = ''; $label = ''; $year = null; $color = ''; $size = ''; $sex = ''; $qty = 0; $price = 0.00; //check for database type and set up $results (array) and $tbl (string) accordingly if ($dbType === 'distro') { $columns = array('img' => $img, 'artist' => $artist, 'title' => $title, 'label' => $label, 'year' => $year, 'price' => $price, 'qty' => $qty); $tbl = 'products'; } elseif ($dbType === 'releases') { $columns = array('img' => $img, 'artist' => $artist, 'title' => $title, 'year' => $year, 'price' => $price, 'qty' => $qty); $tbl = 'products'; } elseif ($dbType === 'merch') { $columns = array('img' => $img, 'title' => $title,'size' => $size, 'color' => $color, 'sex' => $sex, 'price' => $price, 'qty' => $qty); $tbl = 'merch'; } $mysqli = Database::getInstance(); $query = 'SELECT '; $query .= '`'.implode('`, `', array_keys($columns)).'`'; $query .= ' FROM ' . $tbl . ' WHERE (`id` = ?) AND (`qty` > 0) AND (`agedOff` <> 1);'; //query for each item in post array foreach ($_POST['cart'] as $key => $reqQty) { if (!$stmt = $mysqli->prepare($query)) { echo "Prepare failed: (" . $mysqli->errno . ") " . $mysqli->error; } if (!$stmt->bind_param('s', $key)) { echo "Binding parameters failed: (" . $stmt->errno . ") " . $stmt->error; } if (!$stmt->execute()) { echo "Execute failed: (" . $stmt->errno . ") " . $stmt->error; } $results = array(); foreach ($columns as $colKey => $col) { $results[] = &$data[$colKey][$col]; } if (!call_user_func_array(array($stmt, 'bind_result'), $results)) { echo "Binding results failed: (" . $stmt->errno . ") " . $stmt->error; } if (!$stmt->fetch()) { echo "Fetching results failed: (" . $stmt->errno . ") " . $stmt->error; } $prodDetail[$key] = $results; printArray($prodDetail); I would like for my original array keys in the original $columns array to appear in the final $prodDetail array, and I am having trouble doing that with your example. I tried a couple variations of this line: $results[] = &$data[$colKey][$col]; //this duplicates the reference AND omits the keys from the original $columns array $results[$colKey] = &$data[$colKey][$col]; //this duplicates the reference, I think $results[$key] = &$data[$colKey][$col]; //this completely confuses the result binding } How do you recommend that I keep my array keys, which, like the original array variables, are generated dynamically?
×
×
  • 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.