Daily Archives

Articles indexed Sunday November 18 2012

Page 3/14 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • How to deal with Character body parts from Design to Cocos2d

    - by Edwin Soho
    I'm trying to figure out the pattern the game developers use together with game designers: See the picture below with the independent parts: Questions: 1) Should I create different image parts from different body parts or keep frame by frame animaton? (I know both can be used, but I'm trying to figure what is commonly used in the industry) 2) If I'm going to generate different image parts from different body parts (which is I thing is more logical) how would I export that to Cocos2d (Vector or Bitmap)?

    Read the article

  • How to apply programatical changes to the Terrain SplatPrototype

    - by Shivan Dragon
    I have a script to which I add a Terrain object (I drag and drop the terrain in the public Terrain field). The Terrain is already setup in Unity to have 2 PaintTextures: 1 is a Square (set up with a tile size so that it forms a checkered pattern) and the 2nd one is a grass image: Also the Target Strength of the first PaintTexture is lowered so that the checkered pattern also reveals some of the grass underneath. Now I want, at run time, to change the Tile Size of the first PaintTexture, i.e. have more or less checkers depending on various run time conditions. I've looked through Unity's documentation and I've seen you have the Terrain.terrainData.SplatPrototype array which allows you to change this. Also there's a RefreshPrototypes() method on the terrainData object and a Flush() method on the Terrain object. So I made a script like this: public class AStarTerrain : MonoBehaviour { public int aStarCellColumns, aStarCellRows; public GameObject aStarCellHighlightPrefab; public GameObject aStarPathMarkerPrefab; public GameObject utilityRobotPrefab; public Terrain aStarTerrain; void Start () { //I've also tried NOT drag and dropping the Terrain on the public field //and instead just using the commented line below, but I get the same results //aStarTerrain = this.GetComponents<Terrain>()[0]; Debug.Log ("Got terrain "+aStarTerrain.name); SplatPrototype[] splatPrototypes = aStarTerrain.terrainData.splatPrototypes; Debug.Log("Terrain has "+splatPrototypes.Length+" splat prototypes"); SplatPrototype aStarCellSplat = splatPrototypes[0]; Debug.Log("Re-tyling splat prototype "+aStarCellSplat.texture.name); aStarCellSplat.tileSize = new Vector2(2000,2000); Debug.Log("Tyling is now "+aStarCellSplat.tileSize.x+"/"+aStarCellSplat.tileSize.y); aStarTerrain.terrainData.RefreshPrototypes(); aStarTerrain.Flush(); } //... Problem is, nothing gets changed, the checker map is not re-tiled. The console outputs correctly tell me that I've got the Terrain object with the right name, that it has the right number of splat prototypes and that I'm modifying the tileSize on the SplatPrototype object corresponding to the right texture. It also tells me the value has changed. But nothing gets updated in the actual graphical view. So please, what am I missing?

    Read the article

  • The purpose of using invert and transpose

    - by user699215
    In openGl ES and the World of 3D - why use the invers matrix? The thing is that I dont have any intuition to, why it is used, therefore please correct me: As fare as I understand, it is used in shaders - and can help you to figure out the opposite direction of the normals? Invers in ordinary numbers is like; The product of a number and its multiplicative inverse is 1. Observe that 3/5 * 5/3 = 1. In a matrix this will give you the Identity Matrix, which is the base coordinate system or the orion of the World space - right. But the invers is - some other coordinate system? You can use the transpose(Row-major order to Column-major order) of a square matrix to find the inverted matrix, as calculating the invers is process heavy - and the transpose is giving you the inverted matrix as a bi product? Again, I am looking for getting some intuition of this - and therefore be able to use it as intended. Thank you for any reply that will guide me in the right direction. Regards

    Read the article

  • Doctrine2 use of criteria inside the entity class

    - by Piotr Kowalczuk
    They try to write a method whose task would be to return only selected elements of the collection of items associated with a particular entity. /** * @ORM\OneToMany(targetEntity="PlayerStats", mappedBy="summoner") * @ORM\OrderBy({"player_stat_summary_type" = "ASC"}) */ protected $player_stats; public function getPlayerStatsBySummaryType($summary_type) { if ($this->player_stats->count() != 0) { $criteria = Criteria::create() ->where(Criteria::expr()->eq("player_stat_summary_type", $summary_type)); return $this->player_stats->matching($criteria)->first(); } return null; } but i get error: PHP Fatal error: Cannot access protected property Ranking\CoreBundle\Entity\PlayerStats::$player_stat_summary_type in /Users/piotrkowalczuk/Sites/lolranking/vendor/doctrine/common/lib/Doctrine/Common/Collections/Expr/ClosureExpressionVisitor.php on line 53 any idea how to fix this?

    Read the article

  • How to change position of inherited items in an Inherited user control

    - by Yalda
    I have used a user control as a base class (let's call it BaseUC) with 3 labels (in 3 lines) on it (they are set as protected). And there is another user control that inherits from it (InheritedUC). I have added two more labels in InheritedUC, which are positioned between the base's labels (so there are 5 lines). Everything is fine is Visiual Studio's design UI view. But when I run the application, labels on BaseUC overlap with the ones in InheritedUC and I can't see the ones on the inherited control. Any ideas to fix this? Thank you very much

    Read the article

  • Picture Box and Form Transparency

    - by Qu1nncunxIV
    Maybe I am missing something, but is it the case that when you set a pictureboxes background to transparent, all it really does is set it to the same color as the forms background? What I am trying to do is draw an animation for the benefit of this, a bouncing ball - which I paint on the form, then overlay that with a picture frame. End result should be a bouncing ball in a picture frame, I should mention that the picture frame does not have a straight edge, so it is not possible to arrange 4 picture boxes in a frame. The ball needs to vanish behind the frame to change color and then magically bounce back out. I have tried: 1.Setting the picture box background to pink and then key out the same pink, this basically cuts away everything, including that which is behind the picture box 2.Setting the picture box to transparent, this just displays the picture box background as the same color as the forms background. 3.I have tried painting the image in a rectangle, this had the same effect as drawing it in a picture box. I am not sure what I am doing wrong, I am wondering if there is any other ways I could try or if someone has made a custom control or library that supports transparency?

    Read the article

  • How to put log in box in a website to ensure one user can vote once only?

    - by shah
    I have a school project to do which requires us to develop an online voting website. how do i ensure one user has voted once only? the website is supposed to be in booths in public places which means i cannot use ip addresses or cookies. i was planning to use fb login id or maybe some other email id but i cannot find relevant codes/links. i just want people to go through the procedure of entering the log in id but not go to fb directly. my website cannot be published online. could you please suggest how i can achieve this? it is a bit urgent, thank you!

    Read the article

  • Missing styles. Is the correct theme chosen for this layout?

    - by user1820007
    Missing styles. Is the correct theme chosen for this layout? Use the Theme combo box above the layout to choose a different layout, or fix the theme style references. Failed to find style 'mapViewStyle' in current theme. I tried every solutions available to solve this problem. But nothing seems to work. I have included library in the manifest file. I even created style is styles.xml. I have chosen Google Apis build target as well. Can somebody please give me a solution. Thank you in advance for your valuable time... here is my xml file: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" style="@style/AppTheme" android:layout_width="fill_parent" android:layout_height="fill_parent" > <com.google.android.maps.MapView android:id="@+id/themap" style="@style/mapViewStyle" android:layout_width="fill_parent" android:layout_height="fill_parent" android:apiKey="here i have my key" android:clickable="true" android:enabled="true" /> </RelativeLayout> ` Here is my manifest snippet: <uses-library android:name="com.google.android.maps" /> <activity android:name=".MainActivity" android:label="@string/title_activity_main" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".Second" /> <acttiviy android:name=".Third" android:theme="@android:style/Theme.Black" /> </application> here is my style.xml file <style name="mapViewStyle" parent="@android:style/Theme.Black"> </style> </resources>

    Read the article

  • IOS: How to uplaod a file to specific google drive folder using google drive sdk library

    - by loganathan
    I integrated google drive sdk with my ios app. But i do not know how to upload a file to google drive specific folder. Here the code am using to upload the file. But this one uploading the file to my google drive root folder. Any one share a code to upload a file to google drive specific folder?. My Code: -(void)uploadFileToGoogleDrive:(NSString*)fileName { GTLDriveFile *driveFile = [[[GTLDriveFile alloc]init] autorelease]; driveFile.mimeType = @"application/pdf"; driveFile.originalFilename = @"test.doc"; driveFile.title = @"test.doc"; NSString *filePath = [LocalFilesDetails getUserDocumentFullPathForFileName:fileName isSignedDocument:YES]; GTLUploadParameters *uploadParameters = [GTLUploadParameters uploadParametersWithData:[NSData dataWithContentsOfFile:filePath] MIMEType:@"application/pdf"]; GTLQueryDrive *query = [GTLQueryDrive queryForFilesInsertWithObject:driveFile uploadParameters:uploadParameters]; [self.driveService executeQuery:query completionHandler:^(GTLServiceTicket *ticket, GTLDriveFile *updatedFile, NSError *error) { if (error == nil) { NSLog(@"\n\nfile uploaded into google drive\\<my_folder> foler"); } else { NSLog(@"\n\nfile uplod failed google drive\\<my_folder> foler"); } }]; }

    Read the article

  • PHP While loop seperating unique categories from multiple 'Joined' tables

    - by Hob
    I'm pretty new to Joins so hope this all makes sense. I'm joining 4 tables and want to create a while loop that spits out results nested under different categories. My Tables categories id | category_name pages id | page_name | category *page_content* id | page_id | image_id images id | thumb_path My current SQL join <?php $all_photos = mysql_query(" SELECT * FROM categories JOIN pages ON pages.category = categories.id JOIN image_pages ON image_pages.page_id = pages.id JOIN images ON images.id = image_pages.image_id ");?> The result I want from a while loop I would like to get something like this.... Category 1 page 1 Image 1, image 2, image 3 page 2 Image 2, image 4 Category 2 page 3 image 1 page 4 image 1, image 2, image 3 I hope that makes sense. Each image can fall under multiple pages and each page can fall under multiple categories. at the moment I have 2 solutions, one which lists each category several times according to the the amount of pages inside them: eg. category 1, page 1, image 1 - category 1, page 1, image 2 etc One that uses a while loop inside another while loop inside another while loop, resulting in 3 sql queries. <?php while($all_page = mysql_fetch_array($all_pages)) { ?> <p><?=$all_page['page_name']?></p> <?php $all_images = mysql_query("SELECT * FROM images JOIN image_pages ON image_pages.page_id = " . $all_page['id'] . " AND image_pages.image_id = images.id"); ?> <div class="admin-images-block clearfix"> <?php while($all_image = mysql_fetch_array($all_images)) { ?> <img src="<?=$all_image['thumb_path']?>" alt="<?=$all_image['title']?>"/> <?php } ?> </div> <?php } } ?

    Read the article

  • unable to calculate textfield values

    - by user1726508
    i am trying to change the input field when users changes the quantity of items in a text field. Here i am iterating my list from my database. Now i have to make invoice for customer. In my code , if i am changing quantity of a single item, then it is effecting all the other items in the list. I want to change only to the specific items,where its quantity has been change. Below code is giving me error. It is changing all the items value on single change of item quantity. my code; <script type="text/javascript"> $(document).ready(function(){ $(function() { $('input[name="quantity"]').change(function() { var unitprice = $('input[name^="unitprice"]').val(); $(this).parents('tr').find('input[name^="price"]').val($(this).val() * unitprice); }); }); }); </script> <tr> <td height="65%" valign="top" width="100%"> <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"> <s:iterator value="#session.BOK" status="userStatus"> <tr style="height: 10px;"> <td width="65%" align="left"><s:property value="bookTitile"/></td> <td width="10%" align="left"><s:textfield name="unitprice" value="%{price}" size="4"/></td> <td width="10%" align="center"><s:textfield name="quantity" value="%{quantity}" size="2"/></td> <td width="15%" align="center"><s:textfield name="price" size="6"></s:textfield> </td> </tr> </s:iterator> </table> </td> </tr> output looks like this image...

    Read the article

  • Concatinate integer arrays iteratively

    - by Ojtwist
    I have a methode in2.getImagesOneDim() which gives me an array of integers, to be more precise the pixel values of an image. Now i want to create one big array with all the pixel values of all the images. Therefore I have to call this method several times. Now I would like to concatenate the previous output to the current output until all images are read. In some kind of pseudo code, where the + is a concatination ... : for (int i = 1; i < 25; i++) { ConArray = ConArray + in2.getImagesOneDim("../images/"+i); } How would I do this in java ?

    Read the article

  • Displaying a message after adding duplicate records in database

    - by user1770370
    I wrote program in C# winforms and SQL server and LINQ to SQL. I use user control instead of form. In my user control, I put 3 textbox, txtStartNumber, txtEndNumber, txtQuantity. user define value of textboxes, when clicked button, it will insert some records according to the value of txtQuantity. I want to when duplicate number is created, it won't add to database and display message. how do i do? I must write code in code behind or server side? i must set this in store procedure or trigger? private void btnSave_Click(object sender, EventArgs e) { long from = Convert.ToInt64(txt_barcode_f.Text); long to = Convert.ToInt64(txt_barcode_t.Text); long quantity = Convert.ToInt64(to - from); int card_Type_ID=Convert.ToInt32(cmb_BracodeType .SelectedValue); long[] arrCardNum = new long[(to - from)]; arrCardNum[0]=from; for (long i = from; i < to; i++) { for(int j=0; j<(to-from) ;j++) { arrCardNum[j]=from+j; string r = arrCardNum[j].ToString(); sp.SaveCards(r, 2, card_Type_ID, SaveDate, 2); } } } Stored Procedure code. ALTER PROCEDURE dbo.SaveCards @Barcode_Num int ,@Card_Status_ID int ,@Card_Type_ID int ,@SaveDate varchar(10) ,@Save_User_ID int AS BEGIN INSERT INTO [Parking].[dbo].[TBL_Cards] ([Barcode_Num] ,[Card_Status_ID] ,[Card_Type_ID] ,[Save_User_ID]) VALUES (@Barcode_Num ,@Card_Status_ID ,@Card_Type_ID ,@Save_User_ID) END

    Read the article

  • C - dns query to structure

    - by Bibo
    I have these structures: typedef struct dnsQuery { char header[12]; struct dnsQuerySection *querySection; } TdnsQuery; typedef struct dnsQuerySection { unsigned char *name; struct dnsQueryQuestion *question; } TdnsQuerySection; typedef struct dnsQueryQuestion { unsigned short qtype; unsigned short qclass; } TdnsQueryQuestion; and I have dns query in byte array from recvfrom. I am trying to get structure from byte array like this: TdnsQuery* dnsQuery = (TdnsQuery*)buf; When I tried to access qtype like this: printf("%u", dnsQuery->querySection->question.qtype); I get seg fault 11. Can someone help me with these structures? What´s wrong with them? I tried to add structure: typedef struct udpPacket { char header[8]; structr dnsQuery query; } and mapped this structure from byte array but it didn´t help. Can someone help me with these structures? How they should look like for dns query with udp protocol?

    Read the article

  • Ruby on rails 2 level model

    - by jony17
    I need some help creating a very simple forum in a existing model. What I want in a Game page, have a mini forum, where is possible create some topics and some comments to this topics. In the beginning I'm only implement topics. This is the error I have: Mysql2::Error: Column 'user_id' cannot be null: INSERT INTO `topics` (`game_id`, `question`, `user_id`) VALUES (1, 'asd', NULL) This is my main model: game.rb class Game < ActiveRecord::Base attr_accessible :name validates :user_id, presence: true validates :name, presence: true, length: { maximum: 50 } belongs_to :user has_many :topics, dependent: :destroy end topic.rb class Topic < ActiveRecord::Base validates_presence_of :question validates_presence_of :game_id attr_accessible :question, :user_id validates :question, length: {maximum: 50}, allow_blank: false belongs_to :game belongs_to :user end topic_controller.rb def create @game = Game.find(params[:game_id]) @topic = @game.topics.create(params[:topic]) @topic.user_id = current_user.id respond_to do |format| if @topic.save format.html { redirect_to @game, notice: 'Topic was successfully created.' } else format.html { render action: "new" } end end end game/show.html.erb <h2>Topics</h2> <% @game.topics.each do |topic| %> <p> <b>Question:</b> <%= topic.question %> </p> <% end %> <h2>Add a topic:</h2> <%= form_for([@game, @game.topics.build]) do |f| %> <div class="field"> <%= f.label :question %><br /> <%= f.text_field :question %> </div> <div class="actions"> <%= f.submit %> </div> <% end %> Thanks ;)

    Read the article

  • Do I need to specify a return type for an anonymous function in javascript / typescript?

    - by Anne
    I have the following function: $('td:eq(' + iColumn + ') input', oSettings.oApi._fnGetTrNodes(oSettings)) .each(function () { aData.push(this.value); }); In typescript I am getting a message saying: Error 3 Function declared a non-void return type, but has no return expression Why am I getting this message? I can resolve the message by saying "return true". Should I always specify a return type for this?

    Read the article

  • Git graph with ref logs

    - by Francisco Garcia
    I am trying to improve my custom git log format string. I have almost everything I want except the ref names. I can already get a log similar to what I want: > git log --all --source --pretty=oneline --graph * b7c7ad3855b54e94ad7ac03f2d2e5b96d6e5ac1d refs/heads/b1 na | * 695e1482622a79230fa1d83afb8d70e86847334a refs/heads/master Merge branch 'b1' | |\ | |/ |/| * | ec21f370f82096c0208f43b390da234d92e8c74a refs/heads/b1 beta * | c6bc1f55ab3b1bd568493a5de4298dfcb4f66d8d refs/heads/b1 alfa * | 762dd868ae87753afc1cbf9803744c76f9a9e121 refs/heads/b1 tango | * 57fb27bff06ee9bb569f93ba815e9dcd69521c13 refs/heads/master little last post commit |/ | * 8d613d09b43152a7263b6e02d47ec8a4304f54be refs/heads/b3 the other commit | * e1f32b7cb86633351df06e37c2c58ef3f9fafc40 refs/heads/b3 something |/ | * 01b5c6728cf25dd576733211ce75dd3ecc29c7ba refs/heads/b2 this time a I am fighting to get a customized output with my own format string like this: > git log --pretty=format:'%h - %gD %s' --source -g b7c7ad3 - HEAD@{0} na ec21f37 - HEAD@{1} beta 01b5c67 - HEAD@{2} this time a 01b5c67 - HEAD@{3} this time a 695e148 - HEAD@{4} Merge branch 'b1' 57fb27b - HEAD@{5} little last post commit My main problem is that I cannot get the ref names I want. I assume it is one of the %g? format strings, but none of them seem to give me the full ref name. Another problem is that the %g? format strings are empty unless I walk the reflogs (-g). However git refuses to combine --graph with -g How can reproduce the first sample with a format string which I can further customize?

    Read the article

  • Powershell - Using variables in -Include filter

    - by TheD
    (again!) My final question for the night. I have a function which uses the Get-ChildItem to work out the newest file within a folder. The reason being I need to find the latest incremental backup in a folder and script an EXE to mount it. However, within this same folder there are multiple backup chains for all different servers: i.e. SERVER1_C_VOL_b001_i015.spi SERVER2_D_VOL_b001_i189.spi SERVER1_C_VOL_b002_i091.spi SERVER1_E_VOL_b002_i891.spi (this is the newest file created) I want only to look at SERVER1, look at only the C_VOL and look at only b001 - nothing else. I have all these seperate components: the drive letter, the Server Name, the b00X number stored in array. How then can I go and use the Get-ChildItem with the -Include filter to only look at: .spi SERVER1 C_VOL b001 Given I have all of these separate components in an array taken from a text file: Get-Content .\PostBackupCheck-TextFile.txt | Select-Object -First $i { $a = $_ -split ' ' ; $locationArray += "$($a[0]):\$($a[1])\$($a[2])" ; $imageArray += "$($a[2])_$($a[3])_VOL_b00$($a[4])_i$($a[5]).spi" } I then go onto try and filter then and then get stuck: $latestIncremental = Get-ChildItem -Path ${shadowProtectDataLocation}\*.* -Include *.spi | Sort-Object LastAccessTime -Descending | Select-Object -First 1 I have the .spi filtered, but how can I also just include the C (for volume), the number for the b00x and the server name. Thanks!

    Read the article

  • Eval string for wordpress "in_category" workaround outside the loop

    - by fimbim
    In Wordpress you can´t use "in_category" outside the loop, so I created a function that gives me all the categories my article is in and create a "is_category" if statement out of it. I put my function in my "functions.php": function inCatAlt($catID){ $allCats = get_categories('child_of='.$catID); $childCats = 'is_category('.$catID.') '; foreach($allCats as $childCat){ $childCats.= 'or is_category('.$childCat->cat_ID.') '; }; $allchildCats = trim(trim($childCats, 'or ')); return $allchildCats; } and call this in my sidebar, single and so on: echo inCatAlt(13); which gives me this as a string back: "is_category(13) or is_category(16) or is_category(15)" This is exactly what I needed, but now I want to evaluate the string to use it in a if function like this: if(eval(inCatAlt(13))){ do something } But it doesn´t work. Do I evaluate it wrong or what is the problem? If I copy paste the output into the if function it works fine… Thanks in advanced guys. Is my first time asking something here. I´m curious :)

    Read the article

  • Windows Phone - failing to get a string from a website with login information

    - by jumantyn
    I am new to accessing web services with Windows Phone 7/8. I'm using a WebClient to get a string from a php-website. The site returns a JSON string but at the moment I'm just trying to put it into a TextBox as a normal string just to test if the connection works. The php-page requires an authentication and I think that's where my code is failing. Here's my code: WebClient client = new WebClient(); client.Credentials = new NetworkCredential("myUsername", "myPassword"); client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted); client.DownloadStringAsync(new Uri("https://www.mywebsite.com/ba/php/jsonstuff.php")); void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { try { string data = e.Result; this.jsonText.Text = data; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } } This returns first a WebException and then a TargetInvocationException. If I replace the Uri with for example "http://www.google.com/index.html" the jsonText TextBox gets filled with html text from Google (oddly enough, this also works even when the WebClient credentials are still set). So is the problem in the setting of the credentials? I couldn't find any good results when searching for guides on how to access php-pages with credentials, only without them. Then I found a short mention somewhere to use the WebClient.Credentials property. But should it work some other way? Update: here's what I can get out of the WebException (sorry for the bad formatting): System.Net.WebException: The remote server returned an error: NotFound. ---System.Net.WebException: The remote server returned an error: NotFound. at System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult) at System.Net.Browser.ClientHttpWebRequest.<c_DisplayClasse.b_d(Object sendState) at System.Net.Browser.AsyncHelper.<c_DisplayClass1.b_0(Object sendState) --- End of inner exception stack trace --- at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state) at System.Net.Browser.ClientHttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at System.Net.WebClient.GetWebResponse(WebRequest request, IAsyncResult result) at System.Net.WebClient.DownloadBitsResponseCallback(IAsyncResult result)

    Read the article

  • Opencart Dashboard show last months statistics

    - by John Magnolia
    How could I added the option to show the statistics for last month. PHP public function chart() { $this->load->language('common/home'); $data = array(); $data['order'] = array(); $data['customer'] = array(); $data['xaxis'] = array(); $data['order']['label'] = $this->language->get('text_order'); $data['customer']['label'] = $this->language->get('text_customer'); if (isset($this->request->get['range'])) { $range = $this->request->get['range']; } else { $range = 'month'; } switch ($range) { case 'day': for ($i = 0; $i < 24; $i++) { $query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "order` WHERE order_status_id > '0' AND (DATE(date_added) = DATE(NOW()) AND HOUR(date_added) = '" . (int)$i . "') GROUP BY HOUR(date_added) ORDER BY date_added ASC"); if ($query->num_rows) { $data['order']['data'][] = array($i, (int)$query->row['total']); } else { $data['order']['data'][] = array($i, 0); } $query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "customer WHERE DATE(date_added) = DATE(NOW()) AND HOUR(date_added) = '" . (int)$i . "' GROUP BY HOUR(date_added) ORDER BY date_added ASC"); if ($query->num_rows) { $data['customer']['data'][] = array($i, (int)$query->row['total']); } else { $data['customer']['data'][] = array($i, 0); } $data['xaxis'][] = array($i, date('H', mktime($i, 0, 0, date('n'), date('j'), date('Y')))); } break; case 'week': $date_start = strtotime('-' . date('w') . ' days'); for ($i = 0; $i < 7; $i++) { $date = date('Y-m-d', $date_start + ($i * 86400)); $query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "order` WHERE order_status_id > '0' AND DATE(date_added) = '" . $this->db->escape($date) . "' GROUP BY DATE(date_added)"); if ($query->num_rows) { $data['order']['data'][] = array($i, (int)$query->row['total']); } else { $data['order']['data'][] = array($i, 0); } $query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "customer` WHERE DATE(date_added) = '" . $this->db->escape($date) . "' GROUP BY DATE(date_added)"); if ($query->num_rows) { $data['customer']['data'][] = array($i, (int)$query->row['total']); } else { $data['customer']['data'][] = array($i, 0); } $data['xaxis'][] = array($i, date('D', strtotime($date))); } break; default: case 'month': for ($i = 1; $i <= date('t'); $i++) { $date = date('Y') . '-' . date('m') . '-' . $i; $query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "order` WHERE order_status_id > '0' AND (DATE(date_added) = '" . $this->db->escape($date) . "') GROUP BY DAY(date_added)"); if ($query->num_rows) { $data['order']['data'][] = array($i, (int)$query->row['total']); } else { $data['order']['data'][] = array($i, 0); } $query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "customer WHERE DATE(date_added) = '" . $this->db->escape($date) . "' GROUP BY DAY(date_added)"); if ($query->num_rows) { $data['customer']['data'][] = array($i, (int)$query->row['total']); } else { $data['customer']['data'][] = array($i, 0); } $data['xaxis'][] = array($i, date('j', strtotime($date))); } break; case 'year': for ($i = 1; $i <= 12; $i++) { $query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "order` WHERE order_status_id > '0' AND YEAR(date_added) = '" . date('Y') . "' AND MONTH(date_added) = '" . $i . "' GROUP BY MONTH(date_added)"); if ($query->num_rows) { $data['order']['data'][] = array($i, (int)$query->row['total']); } else { $data['order']['data'][] = array($i, 0); } $query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "customer WHERE YEAR(date_added) = '" . date('Y') . "' AND MONTH(date_added) = '" . $i . "' GROUP BY MONTH(date_added)"); if ($query->num_rows) { $data['customer']['data'][] = array($i, (int)$query->row['total']); } else { $data['customer']['data'][] = array($i, 0); } $data['xaxis'][] = array($i, date('M', mktime(0, 0, 0, $i, 1, date('Y')))); } break; } $this->response->setOutput(json_encode($data)); } HTML <select name="range"> <option value="day">Today</option> <option value="week">This Week</option> <option value="month">This Month</option> <option value="year">This Year</option> </select>

    Read the article

  • Magento MAGMI: Product attributes (custom options) not showing up in import

    - by Rodgers and Hammertime
    When importing a CSV into Magento with the MAGMI importing tool, I am unable to import Custom Options (as in size: smalee/medium/large). The import manages to put in the basic products, but the Custom Options don't transfer accross. By custom options I mean the fields Title, Input Type, Is Required, Sort Order Title, Price, Price Type, SKU, Sort Order Title, Price, Price Type, SKU, Sort Order Title, Price, Price Type, SKU, Sort Order and so on ... Found in the custom options menu... Even using the example CSV from the MAGMI SourceForge Wiki: sku,name,description,price,Size:drop_down:1 T-Shirt1,T-Shirt,A T-Shirt,5.00,Small|Medium|Large T-Shirt2,T-Shirt2,Another T-Shirt,6.00,XS|S|M|L|XL ...it fails to import the attributes. So i'm simply using MAGMI with the supplied example data from SourceForge on a blank magento product list, and it doesn't transfer properly. Can anyone shed any light on what might be wrong? I am using Magento ver. 1.6.1.0 if that changes anything. Thanks.

    Read the article

  • Writing to the DataContext

    - by user738383
    I have a function. This function takes an IEnumerable<Customer> (Customer being an entity). What the function needs to do is tell the DataContext (which has a collection of Customers as a property) that its Customers property needs to be overwritten with this passed in IEnumerable<Customer>. I can't use assignment because DomainContext.Customers cannot be assigned to, as it is read only. I guess it's not clear what I'm asking, so I suppose I should say... how do I do that? So we have DataContext.Customers (of type System.Data.Linq.Table) which wants to be replaced with a System.Collections.Generic.IEnumerable. I can't just assign the latter to the former because DataContext's properties are read only. But there must be a way. Edit: here's an image: Further edit: Yes, this image does not feature a collection of the type 'Customer' but rather 'Connection'. It doesn't matter though, they are both created from tables within the linked SQL database. So there is a dc.Connections, a dc.Customers, a dc.Media and so on. Thanks in advance.

    Read the article

  • Configure Notepad++ DBGP plugin and XDebug for PHP

    - by Wasim
    I followed these steps: download x-debug*.dll to D:\Program Files\webserver\php\ext\php_xdebug.dll modify php.ini and insert following zend_extension_ts="D:\Program Files\webserver\php\ext\php_xdebug.dll" xdebug.remote_enable=1 xdebug.remote_handler=dbgp xdebug.remote_mode=req xdebug.idekey=default xdebug.remote_autostart=1 restart apache and XDebug is successfully installed. DBGP is installed successfully and configured with 127.0.0.1 but XDebugger is still not connecting/working with notepad++.

    Read the article

  • Counting number of children in hierarchical SQL data

    - by moontear
    for a simple data structure such as so: ID parentID Text Price 1 Root 2 1 Flowers 3 1 Electro 4 2 Rose 10 5 2 Violet 5 6 4 Red Rose 12 7 3 Television 100 8 3 Radio 70 9 8 Webradio 90 For reference, the hierarchy tree looks like this: ID Text Price 1 Root |2 Flowers |-4 Rose 10 | |-6 Red Rose 12 |-5 Violet 5 |3 Electro |-7 Television 100 |-8 Radio 70 |-9 Webradio 90 I'd like to count the number of children per level. So I would get a new column "NoOfChildren" like so: ID parentID Text Price NoOfChildren 1 Root 8 2 1 Flowers 3 3 1 Electro 3 4 2 Rose 10 1 5 2 Violet 5 0 6 4 Red Rose 12 0 7 3 Television 100 0 8 3 Radio 70 1 9 8 Webradio 90 0 I read a few things about hierarchical data, but I somehow get stuck on the multiple inner joins on the parentIDs. Maybe someone could help me out here. moon

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >