Jump to content

oliveralden

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

oliveralden's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. That's helpful, so much appreciated, and it got rid of the syntax error. Also I think I've figured out why my query is only showing 143 instead of 152 items returned. Looks like I've been counting the number of rows in the database using one field, but echoing another field, and although they're very similar, they don't match up exactly. Back to the drawing board for me then, but thanks again.
  2. Hmm. Okay. Well, if I read you correctly & use table prefixes like so: SELECT count(*) FROM `cpLinkedProducts` as A left join `cpProductsValues` as B ON (A.id_product = B.id_product) WHERE `A.id_category` = '21' AND `B.id_productfield` = '2' AND (`B.value` LIKE 'a%' OR `B.value` LIKE 'b%' OR `B.value` LIKE 'c%'); then I get a mysql error, so no number at all rather than the wrong one. I do definitely want to call columns from both tables (hence the join). Is there a more syntactically appropriate way to do so?
  3. Sorry, didn't finish and it posted accidentally. Try again: My statement: SELECT count(*) FROM `cpLinkedProducts` as A left join `cpProductsValues` as B ON (A.id_product = B.id_product) WHERE `id_category` = '21' AND `id_productfield` = '2' AND (`value` LIKE 'a%' OR `value` LIKE 'b%' OR `value` LIKE 'c%'); table #1 cpLinkedProducts: id_linked id_category id_product modified created 30 26 5 2006-09-04 11:26:26 2006-09-04 11:26:26 8535 50 2799 2008-01-03 17:32:08 2008-01-03 17:32:08 8534 21 2799 2008-01-03 17:32:08 2008-01-03 17:32:08 13986 21 4496 2008-06-07 14:28:51 2008-06-07 14:28:51 63 22 15 2006-09-07 06:59:37 2006-09-07 06:59:37 1257 128 3 2007-01-08 05:06:43 2007-01-08 05:06:43 table #2 cpProductsValues id_productvalue id_productfield id_product value 52 2 5 Nelson, Willie 53 3 5 The Ghost, Part 1 54 4 5 Masked Weasel 56 8 5 http://www.amazon.com/gp/music/clipserve/B000ARG27... 48 3 3 The Ghost, Part 3 25087 8 5053 http What's supposed to happen: The result should be a #, and the # represents a list of each artist (artists turn up every 7th value, always during id_productfield 2), but only the ones in category 21 ('rock'), and only the ones beginning with letters a, b, & c. There should be 152 items in the list. What's actually happening: I get a list of 143. Some items I didn't expect to turn up are there (like the artist '13th Floor Elevators', and also 'Brian Eno', even though I checked, and the artist field is stored in the database as 'Eno, Brian'). Also, some things which should be there are missing ('Current 93' is one- I checked the database entry and it has all 3 values: id_category=21, id_productfield=2, value starts with 'C'). Any ideas where I've gone wrong? Thanks for your time.
  4. Hoping someone here can help me figure out what's wrong with my statement. FYI: Mysql version 5.0.51a-community The statement: SELECT * FROM `cpLinkedProducts` as A left join `cpProductsValues` as B ON (A.id_product = B.id_product) WHERE `id_category` = '21' AND `id_productfield` = '2' AND `value` LIKE 'c%'; The 2 tables in question: cpProductsValues: id_productvalue id_productfield id_product value 52 2 5 Nelson, Willie 53 3 5 The Ghost, Part 1 54 4 5 Masked Weasel 56 8 5 http://www.amazon.com/gp/music/clipserve/B000ARG27... 48 3 3 The Ghost, Part 3 25087 8 5053 http
  5. Ooh, I should clarify.  I referred to the rows I want in two different ways above.  Each time the B.values I want to sort by come up in the table, two things are true: C.display=Artist and C.id_productfield=7 Again, thanks & hope that's helpful.
  6. Okay.  Here's three sample displays: A Woman Under the Influence vhs $ 6.00 VHS 1999/1974 M-/M- Brian Eno Here Come the Warm Jets lp $ 10.00 LP 1973 M-/M- Byrds Preflyte lp $ 10.00 LP 1973/1964 VG+/EX Those are displays of three columns: A.name A.price B.value where C.id_productfield = '7' I'd like to sort by B.value where C.id_productfield = '2'.  The resulting display would be the same, but would sorted in alphabetical order by artist.  Which would look like this: Byrds Preflyte lp $ 10.00 LP 1973/1964 VG+/EX A Woman Under the Influence vhs $ 6.00 VHS 1999/1974 M-/M- Brian Eno Here Come the Warm Jets lp $ 10.00 LP 1973 M-/M- The reason those displays would show up in that order is that B.value where C.id_productfield = '2' would equal Byrds, Cassavetes, and Eno, respectively. Is that helpful?  Thanks for your time & any help you can give me.
  7. Hi there.  I've got a rather complicated select statement with multiple joins.  In the final display, I need to order by SOME of the rows in one of the columns.  I'm not sure how to begin tackling this problem.  Could I make an array out of one column & then assign a variable to every 3rd key & sort by the variable?  Can I write a select statement within a select statement?  Should I populate a new table of some kind?  I've tried using group by without results. Here's the select statement as it stands: $queryjustin = "SELECT * FROM `cpProducts` as A " . "left join `cpProductsValues` as B ON (A.id_product = B.id_product) " . "left join `cpProductsFields` as C on (B.id_productfield=C.id_productfield) where (C.display='Artist' or C.display='format') and " . "DATE_SUB(CURDATE(),INTERVAL 7 DAY) <= A.created order by XXXXXX"; $resultjustin = mysql_query($queryjustin) or die(mysql_error()); I need to fill the XXXXXX with some rows from the B.value column, but only the rows where C.display=Artist.  Any ideas?
  8. But of course.  In the interim, I realized that it must be where the problem is after all: <?php $host = 'localhost'; $user = 'weirdore'; $pass = 'smitty'; $name = 'weirdore_catalog'; $db = &new MySQL($host,$user,$pass,$name); ?> Thanks.
  9. Well, I *think* I understand what you're saying.  However, it doesn't seem to matter what order I use for those 3 include files, I still get the same error message.  The global.inc.php, by the way, just uses $ to define host, user, pass, dbname.  So I don't think the error is within that file.  Any other ideas from anyone?  Thanks.
  10. Hi there.  I'm fairly new to PHP, and am trying to integrate a shopping cart code with my template.  I seem to have a header problem which I can't quite solve. Here's the error: Fatal error: Cannot instantiate non-existent class: mysql in /home/weirdore/public_html/cartjune/cart-demo/inc/global.inc.php on line 6 And here's the code, up to the end of the header & title: ----------------------------------------------------------------------------------------------------- <?php session_start(); require_once('http://www.weirdorecords.com/cartjune/functions.inc.php'); require_once('http://www.weirdorecords.com/cartjune/global.inc.php'); require_once('http://www.weirdorecords.com/cartjune/mysql.class.php'); $cart = $_SESSION['cart']; $action = $_GET['action']; switch ($action) { case 'add': if ($cart) { $cart .= ','.$_GET['id']; } else { $cart = $_GET['id']; } break; case 'delete': if ($cart) { $items = explode(',',$cart); $newcart = ''; foreach ($items as $item) { if ($_GET['id'] != $item) { if ($newcart != '') { $newcart .= ','.$item; } else { $newcart = $item; } } } $cart = $newcart; } break; case 'update': if ($cart) { $newcart = ''; foreach ($_POST as $key=>$value) { if (stristr($key,'qty')) { $id = str_replace('qty','',$key); $items = ($newcart != '') ? explode(',',$newcart) : explode(',',$cart); $newcart = ''; foreach ($items as $item) { if ($id != $item) { if ($newcart != '') { $newcart .= ','.$item; } else { $newcart = $item; } } } for ($i=1;$i<=$value;$i++) { if ($newcart != '') { $newcart .= ','.$id; } else { $newcart = $id; } } } } } $cart = $newcart; break; } $_SESSION['cart'] = $cart; ?><!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"><!-- InstanceBegin template="/Templates/frontpage.dwt" codeOutsideHTMLIsLocked="false" --> <head><meta name="description" content="Weirdo records sells experimental recordings on lp, cd, cdr, & cassette.  We love noise kids, psychedelic freaks, retards banging on kitchen pots, ultra-snobby longhairs & many other types of record collecting nerds."> <meta name="keywords" content="weirdo records werido weird noise cd lp cds lps rock psychedelic avant garde wolf eyes lightning bolt improv experimental volcanic forced music sounds recordings"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <!-- InstanceBeginEditable name="doctitle" --> <title>Welcome to Weirdo Records</title> ------------------------------------------------------------------------------------------------------ I'm using Dreamweaver & Windows xp, & a webhosting server.  The code does work without the template, but whenever I try to patch them together I've run into this problem.  Any suggestions would be greatly appreciated.  Thanks for your time. -Oliver Alden
×
×
  • 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.