jarvis
-
Posts
543 -
Joined
-
Last visited
Posts posted by jarvis
-
-
Hi,
I really hope someone can help.
I've several tables containing various info. I therefore have to join one table to another.
SELECT $table_products.productID, $table_products.code, $table_products.name, $table_products.shortdescription, $table_products.description, $table_products.thumbnail, $table_products.mainimage, $table_products.extrafield1, $table_products.extrafield2, $table_products.extrafield3, $table_products.price1, $table_products.weight, $table_products.scLevel, $table_extrafields_values.content FROM $table_products LEFT JOIN $table_extrafields_values ON $table_products.productID = $table_extrafields_values.productID AND $table_extrafields_values.extraFieldID=4 WHERE ( $table_products.productID BETWEEN 2 And 999999) AND ($table_products.visible = 'Y' or $table_products.allowDirect = 'Y') GROUP BY $table_products.productID ORDER BY $table_products.productID
The above works well, however, I had to add GROUP BY $table_products.productID to prevent multiple items. Although this works great, it's now causing an issue with the results. Before I added GROUP BY, each product would return with multiple values from this column $table_extrafields_values.extraFieldID=4
What I need to do is show one item but with multiple results from here. To help explain, the item results are shows and $table_extrafields_values.extraFieldID=4 is the shoe sizes.
So it was showing
PROD ID = 1
SHOE NAME = DM
SIZE = 7
PROD ID = 1
SHOE NAME = DM
SIZE = 8
PROD ID = 1
SHOE NAME = DM
SIZE = 9
What I need to do is
PROD ID = 1
SHOE NAME = DM
SIZE = 7,8,9
I know it can be done but I can't remember how, I think it's Concat or Group By
Can someone help?
Thanks
-
Hi,
I've setup custom taxonomies called months and years
Months has
dec-jan
feb-mar
apr-may
etc
Years has
2011
2010
2009
I can then assign a post to a month and a year
What I'm trying to do is then get a page to show all posts as follows:
aug - sept 2011
- post 1
- post 2
jun - jul 2011
- another post
- another post
However, I can't get my code to work, here's my query:
$querystr = " SELECT * FROM $wpdb->posts LEFT JOIN $wpdb->term_relationships ON($wpdb->posts.ID = $wpdb->term_relationships.object_id) LEFT JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id) LEFT JOIN $wpdb->terms ON($wpdb->term_taxonomy.term_id = $wpdb->terms.term_id) WHERE $wpdb->posts.post_type = 'post' AND $wpdb->posts.post_status = 'publish' AND $wpdb->term_taxonomy.taxonomy = 'months' ORDER BY $wpdb->term_taxonomy.taxonomy = 'years' DESC ";
I then use:
<?php $pageposts = $wpdb->get_results($querystr, OBJECT); ?> <?php if ($pageposts): ?> <?php global $post; ?> <?php foreach ($pageposts as $post): ?> <?php setup_postdata($post); ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"> <?php the_title(); ?></a><br> <?php endforeach; ?> <?php else : ?> <h2 class="center">Not Found</h2> <p class="center">Sorry, but you are looking for something that isn't here.</p> <?php include (TEMPLATEPATH . "/searchform.php"); ?> <?php endif; ?>
But it just shows a list of posts. It doesn't order them and I can't work out how to add the headings
Can someone help?
Thanks
-
Sorry,
Just wondering if this is on the right lines:
<?php $month = the_time('M'); $year = the_time('Y'); switch (true) { case ($month == 'Aug' && $year == '2011') : $heading = "Aug - Sept 11"; break; case ($month == 'Sept' && $year == '2011') : $heading = "Aug - Sept 11"; break; } ?>
If so, is there a way it can be auto generated? Otherwise I'd need to add a case for all months for the past X years and also cater for all future years?
Or is this miles off?
-
Hi,
I'm using Wordpress but think the priniciple is the same. I wish to get the date of a post for example:
<?php the_time(d M Y') ?>
Once I have the date I then need to list the posts bi-monthly:
Aug - Sept 11
- all posts with a aug - sept date
June - July 11
- all posts with a june - july date
Apr - May 11
Feb - Mar 11
Dec - Jan 11
- all posts with a dec 10 or jan 11 date
Oct - Nov 10
etc
Am at a total loss on how to do this? Is anyone able to point me in the right direction?
I thought I could get the month and year a post, then use a switch/case statement, problem is, I can't see how I would do the year part and equally the fact that it's dec 10 and jan 11
:-(
Any help is very much appreciated.
Thanks
-
Thanks Pikachu2000 but I don't know how else to explain it.
I have this domain:
http://www.domain.com/category/projects/airports
I need to get the projects part of the domain from it. As this may change to something else, like:
http://www.domain.com/category/location/usa
So I can then use the code to get locations. Depending on whether it's location or projects, depends on what I then show on screen.
Does that help?
Thanks
-
Thanks cssfreakie, that put me in the right direction, I needed this:
$array = explode("/", $ref); echo $array[6];
Thanks :-)
-
Hi,
I've the following URL
http://www.domain.com/category/projects/airports
How can I get projects from the URL?
I had something like:
$ref = $_SERVER["REQUEST_URI"]; $array = explode("/", $ref, 2); echo $array[2];
Sadly it didn't work
Anyone able to point me in the right direction?
TIA
-
Hmm, OK I've solved it by adding:
<meta http-equiv="X-UA-Compatible" content="IE=8">
Not sure if this is a suitable solution or not but it has worked!
Thoughts?
Thanks for looking
jarvis
-
Hi all,
I hope some kind soul can help me as I've an issue driving me mad. I've the following block of html:
<ul> <li><a href="#"><span class="selected">Link</span></a></li> <!-- show sub nav --> <ul> <li><a href="#"><span>» Link</span></a></li> <li><a href="#"><span>» Link</span></a></li> <li><a href="#"><span>» Link</span></a></li> </ul> <!-- eof show sub nav --> <li><a href="#"><span>Link</span></a></li> <li><a href="#"><span>Link</span></a></li> <li><a href="#"><span>Link</span></a></li> <li><a href="#" class="back">< Back to X</a></li> </ul>
Which has this rather lengthy block of CSS:
#section_sub_navigation ul { list-style: none; } #section_sub_navigation li { margin: 0px 0px 0px 0px; height: 30px; line-height: 30px; } #section_sub_navigation li a { font-size: 13px; color: #053E77; text-decoration: none; } #section_sub_navigation li a span { font-size: 13px; color: #053E77; text-decoration: none; background: #F2F2F2; border-bottom: 1px solid #E3E3E3; display: inline-block; height: 29px; width: 210px; line-height: 30px; padding: 0px 0px 0px 10px; } #section_sub_navigation li a span.selected { font-size: 13px; color: #053E77; text-decoration: none; background: #EEC52B; border-bottom: 1px solid #E3E3E3; display: inline-block; height: 29px; width: 210px; line-height: 30px; padding: 0px 0px 0px 10px; } #section_sub_navigation li a:hover span { font-size: 13px; color: #053E77; text-decoration: underline; } #section_sub_navigation ul ul li { } #section_sub_navigation ul ul li a span { } /*#section_sub_navigation ul ul li a span { font-size: 13px; color: #FF0000; text-decoration: none; background: #FFF; border-bottom: 1px solid #E3E3E3; display: inline-block; height: 29px; width: 200px; line-height: 30px; padding: 0px 0px 0px 20px; }*/ #section_sub_navigation ul ul li a span { font-size: 13px; color: #FF0000; text-decoration: none; background: #FFF; border-bottom: 1px solid #E3E3E3; display: inline-block; height: 29px; width: 200px; line-height: 30px; padding: 0px 0px 0px 20px; } #section_sub_navigation ul ul li a:hover span { font-size: 13px; color: #FF0000; text-decoration: underline; } #section_sub_navigation li a.back { font-size: 13px; color: #FF0000; text-decoration: none; font-weight: bold; } #section_sub_navigation li a.back:hover { font-size: 13px; color: #FF0000; text-decoration: underline; }
Now, the menu does what it's meant to in Chrome and FF, however, in IE8 it won't show. For Chrome and FF I get this:
Link
> Link
> Link
> Link
Link
Link
Link
In IE8 I just get this:
Link
Link
Link
Link
It simply won't show the sub nav (> Link). What am I missing?
Am developing locally at the mo so not got a link (sorry!)
TIA
jarvis
-
Thanks TeNDoLLA but how do I go about utilising that code?
-
You've been more than helpful, thanks.
Will continue to try & work out what the issue is
-
Thats ok, sorry!
I just can't see why it wont work, especially as you say your one does! Just frustrating as I never thought this would turn out to be such a mare!
I do really appreciate your help though, especially as you're at work! :-)
-
Here's my complete js just incase I've missed something:
//------------------------------------------------- // youtube playlist jquery plugin // Created by dan@geckonm.com // www.geckonewmedia.com // // v1.1 - updated to allow fullscreen // - thanks Ashraf for the request //------------------------------------------------- jQuery.fn.ytplaylist = function(options) { // default settings var options = jQuery.extend( { holderId: 'ytvideo', playerHeight: '258', playerWidth: '399', addThumbs: false, thumbSize: 'small', showInline: false, autoPlay: true, showRelated: true, allowFullScreen: false },options); return this.each(function() { var selector = $(this); var autoPlay = ""; var showRelated = "&rel=0"; var fullScreen = ""; if(options.autoPlay) autoPlay = "&autoplay=1"; if(options.showRelated) showRelated = "&rel=1"; if(options.allowFullScreen) fullScreen = "&fs=1"; //throw a youtube player in function play(optionVars) { var options = optionVars.split('|'); var id = options[0]; var urlType = options[1]; //alert(options); //alert(urlType); var html = ''; html += '<object height="'+options.playerHeight+'" width="'+options.playerWidth+'">'; html += '<param name="movie" value="http://www.'+urlType+'.com/v/'+id+autoPlay+showRelated+fullScreen+'"> </param>'; html += '<param name="wmode" value="transparent"> </param>'; if(options.allowFullScreen) { html += '<param name="allowfullscreen" value="true"> </param>'; } html += '<embed src="http://www.'+urlType+'.com/v/'+id+autoPlay+showRelated+fullScreen+'"'; if(options.allowFullScreen) { html += ' allowfullscreen="true" '; } html += 'type="application/x-shockwave-flash" wmode="transparent" height="'+options.playerHeight+'" width="'+options.playerWidth+'"></embed>'; html += '</object>'; return html; }; //grab a youtube id from a (clean, no querystring) url (thanks to http://jquery-howto.blogspot.com/2009/05/jyoutube-jquery-youtube-thumbnail.html) function youtubeid(url) { var ytid = url.match("[\\?&]v=([^]*)"); var regex = /(facebook|youtube)/i; var type = regex.exec(url); ytid = ytid[1]; return ytid + '|' + type[0]; }; //load inital video var firstVid = selector.children("li:first-child").addClass("currentvideo").children("a").attr("href"); $("#"+options.holderId+"").html(play(youtubeid(firstVid))); //load video on request selector.children("li").children("a").click(function() { if(options.showInline) { $("li.currentvideo").removeClass("currentvideo"); $(this).parent("li").addClass("currentvideo").html(play(youtubeid($(this).attr("href")))); } else { $("#"+options.holderId+"").html(play(youtubeid($(this).attr("href")))); $(this).parent().parent("ul").find("li.currentvideo").removeClass("currentvideo"); $(this).parent("li").addClass("currentvideo"); } return false; }); //do we want thumns with that? if(options.addThumbs) { selector.children().each(function(i){ var replacedText = $(this).text(); if(options.thumbSize == 'small') { var thumbUrl = "http://img.youtube.com/vi/"+youtubeid($(this).children("a").attr("href"))+"/2.jpg"; } else { var thumbUrl = "http://img.youtube.com/vi/"+youtubeid($(this).children("a").attr("href"))+"/0.jpg"; } $(this).children("a").empty().html("<img src='"+thumbUrl+"' alt='"+replacedText+"' />"+replacedText).attr("title", replacedText); }); } }); };
Odd yours works and mine wont so guessing I've not set something perhaps?
-
Hmmm, so where am I going wrong?
The facebook vids I'm using should be ok but I am logged in.
Can I email you the scripts I'm using to see if I've missed something?
-
Sorry, you 've lost me. :-(
The alert wont work if I use it in the current file or a new one
-
Forgot to add, it has a js error:
html is undefined
-
That doesn't do anything either:
<!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=iso-8859-1" /> <title>Untitled Document</title> <script> alert(html); </script> </head> <body> </body> </html>
Appreciate this! I feel such a noob
-
Erm you mean in a new html doc right? On its own with nothing else??
-
Ok created a new js file called temp, added the above. Added it as an include but nothing happens. I'm guessing something should?
Thanks
-
No, no changes. It's odd then as I see what it should do, it should return in the URL that alert, i.e. facebook or youtube.
Pretty cool but odd it won't work. Hmmm....
-
Like so:
var id = options[0]; var urlType = options[1]; //alert(options); alert(urlType);
That returns facebook or youtube without the vid id
-
Sorry, when you say after its definition? Where do you mean :-( embarassed
-
Hi,
It's showing the video ID then facebook or youtube (depending which video I click)
Thanks
-
Thanks Andy-H
I've tried it but to no avail. I notice the embed code has
'+urlType+'
However, I can't see that in your code as a variable. Should it be there?
mysql group by or concat
in MySQL Help
Posted
Ah I think I've sussed it:
I think that does the job I need!