Jump to content

sonicthehedgehog

Members
  • Posts

    50
  • Joined

  • Last visited

Everything posted by sonicthehedgehog

  1. Is there a way I can combine these two queries into one: <?php$sql_select = "SELECT * FROM feeds, product_categories_map WHERE enabled=1 and deleted=0 GROUP BY feeds.id";$sql_select = "SELECT cost as shipping_cost FROM delivery, seller WHERE seller.id=delivery.seller_id and delivery.country_id=".dbstr( $_POST['country'] );?>
  2. I've just realised that I left the 'set' out of the query. Put it back and it works
  3. I'm not sure if I'm doing this the right way but I'm trying to update a field in the database if a checkbox is ticked but it's not working and I'd be grateful for a pair of extra eyes on the code please. This is how I'm updating the table: $query="update feed set name=".dbstr( $_POST['name'] ).", label=".dbstr( $_POST['label'] ).", delivery=".dbstr( $_POST['delivery'] ).", new_release =0, rerelease =0, live =0 where id=".dbstr( $_POST['id'] ); and this is how I'm updating it if the checkboxes are ticked: if ( isset( $_POST['new_release'] ) ) {$query="update feed new_release=1 where id=".dbstr( $_POST['id'] );}if ( isset( $_POST['rerelease'] ) ) {$query="update feed rerelease=1 where id=".dbstr( $_POST['id'] );}if ( isset( $_POST['live'] ) ) {$query="update feed live=1 where id=".dbstr( $_POST['id'] );} What's happening is that it's setting the new_release, rerelease and live fields to 0 every time. I want to be able to change this so need to have it either set to 0 or 1
  4. sorry to be dumb but how do I do that?
  5. It's coming direct from the people who are sending it so I'm not able to get an uncompressed version, the only options I have are ZIP or GZIP. Am I able to uncompress it using php then write the results to the server? I tried adding this to the code but it still comes out as gibberish: curl_setopt($ch, CURLOPT_ENCODING, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  6. I'm trying to parse an XML file to a database but before I do that I need to convert the URL into an XML file. I'm able to create a file on the server but the file it does write is all gibberish. I've attached a screenshot of what I get. This is the code I'm using to write the file: <?phpset_time_limit(0);$fp = fopen ('a.xml', 'w+');$ch = curl_init('http://datafeed.api.productserve.com/datafeed/download/apikey/099640af374a1c61137ad9b60f202215/fid/3712/columns/aw_product_id,merchant_product_id,merchant_category,aw_deep_link,merchant_image_url,search_price,description,product_name,merchant_deep_link,aw_image_url,merchant_name,merchant_id,category_name,category_id,delivery_cost,currency,store_price,display_price,data_feed_id,rrp_price,specifications,condition,promotional_text,warranty,merchant_thumb_url,aw_thumb_url,brand_name,brand_id,delivery_time,valid_from,valid_to,web_offer,pre_order,in_stock,stock_quantity,is_for_sale,product_type,commission_group,upc,ean,mpn,isbn,model_number,parent_product_id,language,last_updated,dimensions,colour,keywords,custom_1,custom_2,custom_3,custom_4,custom_5,saving,delivery_weight,delivery_restrictions,reviews,average_rating,number_stars,number_available,rating,alternate_image,large_image,basket_link/format/xml/dtd/1.4/compression/gzip/adultcontent/1/');// or any url you can pass which gives you the xml filecurl_setopt($ch, CURLOPT_TIMEOUT, 50);curl_setopt($ch, CURLOPT_FILE, $fp);curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);curl_exec($ch);curl_close($ch);fclose($fp);?>
  7. There was a typo in the code, I've corrected it now and it works fine - I'd spelt current without a t
  8. Does anybody know why this isn't working? $FORM[$formid]['field']['category']['type']="select"; $FORM[$formid]['field']['category']['source']=array( "category","name","name" ); $FORM[$formid]['field']['category']['err']['notempty']=true; $FORM[$formid]['field']['category']['default']=$curren[0]['category']; $current[0]['category'] is getting the right value but it's not showing the category as selected. This is the code that should be setting the default: # select input if( $value['type']=="select" ) { if( $value['multiple']==true ) { echo "<select id="".$formid."-".$key."" class="input_select".$autofocus."" name="".$key."[]" style="width: ".( $value['width']+20 )."px; height: ".$value['height']."px;" multiple="multiple" >n"; } else { echo "<select id="".$formid."-".$key."" class="input_select".$autofocus."" name="".$key."" style="width: ".( $value['width']+20 )."px;" >n"; } if( is_array( $GLOBALS[$value['source'][0]] ) ) { foreach( $GLOBALS[$value['source'][0]] as $key2=>$value2 ) { echo "<option value="".$value2[$value['source'][1]]."""; if( is_array( $value['default'] ) ) { foreach( $value['default'] as $key3=>$value3 ) { if( $value2[$value['source'][1]]==$value3 ) { echo " selected="selected""; } } } elseif( isset( $value['default'] ) ) { if( $value2[$value['source'][1]]==$value['default'] ) { echo " selected="selected""; } } echo ">".htmldisplay( $value2[$value['source'][2]] )."</option>n"; } } echo "</select>n"; }
  9. I need to create a very simple comparison website that gives the user the ability to filter the results. Does anybody know if there are any code examples of this or where I can get help with doing this?
  10. I read about this: <meta name="viewport" content="width=device-width, initial-scale=1.0"> but didn't know if it could be used to scale the site?
  11. Is it possible to scale a website down to fit onto a table? I've used @media to style it for phones but want to actual site to be shown on tablets. Not everything is scaling to fit on the tablet and I didn't know if there was a one line quick fix for tablets?
  12. Thank you, yes I did want it to be uppercase, I'd just never come across that before
  13. Thank you, it now works perfectly!! Can I ask though, what does toUpperCase() do?
  14. I did try that but it didn't work. I want to have an additional text field that sends the card type as well as the one that has the cad number
  15. I know I'm probably being dumb but I didn't understand how to adapt it to get it working for a text field
  16. I'm using this to detect the card: http://www.whynot.io/detect-card-js/ and want to send the card type when the form is sent. I thought that the best way of doing this was to have a hidden text field that have the card name as a value when the number if entered in the card number field.
  17. How do I change this so that it updates the value of a text field when particular number (credit card)? $("span#type").removeClass().addClass("card " + card.type).fadeIn('fast'); I want it to change the value of text field with the id payment-card to the card type which is determined by the card number. That bit I've already done but I don't know how to change the text value too. The card types are SOLO VISA AMEX MASTER DINER
  18. Even though I'm using divs with text rather than images?
  19. I'm trying to adapt this so that I can have markers (ideally bullet points) at the bottom so a user can choose which image they want to see. The fading background works no problems but whenever I try to add the markers they don't work. This is what I've got so far but I don't see to be able to get them to work: <style type="text/css" media="screen">#cycler{position:relative;width:984px;height:400px;}#cycler div{position:absolute;z-index:100;background-color:black}#cycler div p{position:absolute;top:200px;right:385px;color:white;margin:0;}#cycler div.active{z-index:300}#cycler img{display:block}</style><div id="cycler" class="cycler"><div class="active" ><a href="/gifts" onclick="return clicktrack( 'fadetab',3,'' );"><h1 class="slide_title"></h1><p class="slide_text"></p><img src="/images/gifts1.jpg" height="400" width="984"/></a></div><div><a href="/products" onclick="return clicktrack( 'fadetab',1,'' );"><h1 class="slide_title">Our Range</h1><p class="slide_text">Want to browse our range? Click here to do so</p><img src="/images/products.jpg" height="400" width="984"/></a></div><div><a href="/contact" onclick="return clicktrack( 'fadetab',2,'' );"><h1 class="slide_title">Get in touch</h1><p class="slide_text">We're here to help you</p><img src="/images/contact.jpg" height="400" width="984"/></a></div> </div><script type="text/javascript">function cycleImages(){ var $active = $('#cycler.active'); var $next = ($active.next().length > 0) ? $active.next() : $('#cycler div:first'); $next.css('z-index',2);//move the next image up the pile $active.fadeOut(1500,function(){//fade out the top image $active.css('z-index',1).show().removeClass('active');//reset the z-index and unhide the image $next.css('z-index',3).addClass('active');//make the next image the top one }); var timer = setTimeout(function(){cycleImages()},7000); container.data('timer',timer);} function pauseSlideshow(container){var timer = setTimeout(function(){cycleImages()}, 7000);container.data('timer',timer);} function resumeSlideshow(container){var timer = setTimeout(function(){cycleImages()}, 7000);container.data('timer',timer); } $(document).ready(function(){ var i = 1;$('#cycler').each(function(){var container = $(this);container.append('<div class="cycler_controls"><a href="#" id="pause_resume" class="active">Pause</a>');for (var j=0;j<=container.find('img').length-1;j++){container.find('.cycler_controls').append('<a class="page" href="#" rel="'+j+'">•</a>');}container.append('</div>').addClass('cycler'+i);var timer = setTimeout(function(){cycleImages()}, 7000);container.data('timer',timer);i++;}); $('.cycler_controls a.page').click(function(){var container = $(this).parents('.cycler');pauseSlideshow();container.find('#cycler').eq($(this).attr('rel')).css('z-index',400).addClass('clicked');//set the clicked image to the topcontainer.find('#cycler.active').not('.clicked').removeClass('active').css('z-index',100);//if the active image is not the clicked image, remove the active class container.find('.clicked').addClass('active').removeClass('clicked');//set the active class on the clicked image ready to resumereturn false;});})</script>
  20. I did do that but it showed 14 results for column1 and then nothing for column2, column3 etc. There's only one column but that has all 14 results. The first result should be on one line, the second should be on line two, the 3rd, 4th and fifth should be on line three etc. I tried this: <?php echo '<pre>';print_r($articles);echo '</pre>';?> and it gave the same results as $i = 1;do { if (isset($GLOBALS['column' . $i])) { $continue = true; print_r($GLOBALS['column' . $i]); } else { $continue = false; } $i++;} while ($continue); so I don't know if I could use something like foreach( $GLOBALS['column1'] as $key=>$value ) but saying: If 1st result display one If 2nd result display one If 3rd - display three results If 6th - show two results (both displayed differently) If 8th - one result If 9th - three results If 12th - three results
  21. I'm really sorry to be a pain but I tried that and it didn't work - I think because there's only one column (with 14 results in it). Is it possible to do something like this: get all results, then for first row show just 1st item. Then second row show 2nd result, for third row show 3rd, 4th and 5th, fourth row show 6th and 7th etc? I'm really grateful for you helping with this. Originally there was more than one column but that's now been changed. I guess the loop is for if the number of columns changes again. I don't know if it helps but this bit of code is what controls the number of columns: # merge into columns $ccols=1; $col=1; if( is_array( $articles ) ) { foreach( $articles as $key=>$value ) { $GLOBALS['column'.$col][]=$articles[$key]; $col++; if( $col>$ccols ) { $col=1; } } }
  22. Sorry to ask such a dumb question but that's the part I'm having problems with. How do I actually get the data into each layout style? I've used divs for each section, but don't know how to dynamically populate it. Using the code you said about gave me an array of each of the items I want but I'm not sure how to get that into each div?
  23. How would I go about doing that? Sorry if it's a really stupid question but I've only been learning php for just over a week now
  24. I originally built a static page to show my boss what it would look like, so yes I've got that part already. Just need to get the info in now
  25. I wonder if somebody could help me please. I'm really new to PHP and have only been working with it for just over a week. My boss has asked to change the appearance of a page on his personal site to make it less formulaic. At the moment all of the information is taken from the database and 'tiled' across the page. I want to change the tiles so that I have six different rows. One with one result, another with two, one with three and so on. I don't know if this is possible or if it is where I would even start so would be grateful for any help at all please. At the moment the code I've got for the current page is: <?php for( $loop=1; $loop<=$ccols; $loop++ ) { ?> <div style="width: 285px; float: left; margin: 0 <?php if( $loop==$ccols ) { echo "0"; } else { echo "30"; } ?>px 35px 0;"> <?php if( is_array( $GLOBALS['column'.$loop] ) ) { $ctr=1; foreach( $GLOBALS['column'.$loop] as $key=>$value ) { ?> <div class="news" style="position: relative;"> <?php if( $value['type']=="video" ) { ?> <div class="news-image"> <div class="player play-button"<?php if( !empty( $value['image'] ) ) { ?> style="background-image: url( /images/<?php echo $value['image'] ?> );"<?php } ?>> <video> <source type="video/flash" src="mp4:<?php echo htmldisplay( $value['video'] ) ?>" /> <source type="video/mp4" src="<?php echo $stream_url_http ?>/<?php echo htmldisplay( $value['video'] ) ?>" /> </video> </div> </div> <?php } elseif( !empty( $value['image'] ) ) { ?> <div class="news-image"> <a href="<?php echo htmldisplay( $value['link'] ) ?>"><img src="/images/<?php echo htmldisplay( $value['image'] ) ?>" alt="<?php echo htmldisplay( $value['title'] ) ?>" title="<?php echo htmldisplay( $value['title'] ) ?>" width="285" height="160" /></a> </div> <?php } ?> <div class="news-text" style="background: none; border: 0; position: relative; top: -30px;height: 160px; padding: 0;"> <?php if( !empty( $value['title'] ) ) { ?> <p class="title"><a href="<?php echo htmldisplay( $value['link'] ) ?>"><?php echo htmldisplay( $value['title'] ) ?></a></p> <?php } ?> <?php if( !empty( $value['subtitle'] ) ) { ?> <p><?php echo htmldisplay( $value['subtitle'] ) ?></p> <?php } ?> <?php if( is_array( $tagmap[$value['id']] ) ) { $cnt=0; ?> <p> Tags: <?php foreach( $tagmap[$value['id']] as $key2=>$value2 ) { ?> <a href="<?php echo $value['section_link'] ?>/<?php echo htmldisplay( $value2 ) ?>"><?php echo htmldisplay( $value2 ) ?></a><?php if( $cnt<count( $tagmap[$value['id']] )-1 ) { ?> | <?php } ?> <?php $cnt++; } ?> </p> <?php } ?> <?php if( $value['type']=="news" || $value['type']=="article" || $value['type']=="video" ) { ?><h4 style="font-size: 12px; color: #FFF; margin-top: 5px;">Uploaded <?php echo date( "j F Y",$value['date'] ) ?></h4><?php } ?> <?php if( $value['type']=="books" ) { ?> <div style="color: #959595; vertical-align: middle;"> <?php if( $htmlver[$value['id']] ) { ?> <a href="/books/<?php echo htmldisplay( $value['linkword'] ) ?>">Read</a><?php if( !empty( $value['pdf'] ) && !empty( $value['pdf_size'] ) ) { ?> | <?php } ?> <?php } ?> <?php if( !empty( $value['pdf'] ) && !empty( $value['pdf_size'] ) ) { ?> <a href="/downlaods/<?php echo $value['pdf'] ?>" rel="nofollow"><img src="/images/pdf.gif" /> Download PDF</a> (<?php echo htmldisplay( bytesize( $value['pdf_size'] ) ) ?>) <?php } ?> </div> <?php } ?> </div> </div> <?php $ctr++; if( $ctr==4 ) { $ctr=1; } } } ?> </div> <?php } ?> I'd be really grateful if somebody could help with this please. Ideally the format I'd like is one main, one medium horizontal (image left text right), three small, two medium vertical (two different coloured backgrounds), one medium horizontal (image right text left) and then two rows of three small ones
×
×
  • Create New...