Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
D

Dwayner79

@Dwayner79
About
Posts
81
Topics
30
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • [ANSWERED] Group_Concat and using a query result in the where clause
    D Dwayner79

    The answer to #2 is:

    HAVING Authors LIKE %SearchString%

    Thanks for the help...

    ***************** "We need to apply 21st-century information technology to the health care field. We need to have our medical records put on the I.T." —GW

    Database question database

  • [ANSWERED] Group_Concat and using a query result in the where clause
    D Dwayner79

    Sorry! Thought the Pre Tags listed the language... Using MySQL. The group by was the error. I also ended up converting back to chars... For anyone's help, here is the code:

    SELECT ProdID, ProdTitle, GROUP_CONCAT(convert(CONCAT(Contacts.ContactFName, " ", Contacts.ContactLName), CHAR(24))) AS Authors FROM Products LEFT OUTER JOIN ... GROUP BY ProdID

    The second question is more of a best practice I guess. Is there a way to then use the "Authors" list in the where clause? I want the whole list returned, but only with matches to a search string. I know I can duplicate the entire GROUP_CONCAT(convert(CONCAT... but it would be nice if it was only once. Also, will the server actually run those twice? as that seems inefficient. Thanks again!

    ***************** "We need to apply 21st-century information technology to the health care field. We need to have our medical records put on the I.T." —GW

    Database question database

  • [ANSWERED] Group_Concat and using a query result in the where clause
    D Dwayner79

    Two seperate questions, but apply to the same query, so here goes:

    SELECT ProdID, ProdTitle, CONCAT(Contacts.ContactFName, " ", Contacts.ContactLName) AS Author FROM Products LEFT OUTER JOIN ...

    This works and returns each item with multiple "author" like:

    ProdID Prod Title Author
    123 Title 1 John Doe
    123 Title 1 Jane Doe
    465 Title 2 John Doe
    456 Title 2 Jane Smith

    But what I want is:

    ProdID Prod Title Authors
    123 Title 1 John Doe, Jane Doe
    465 Title 2 John Doe, Jane Smith

    So I add a Group Concat to the Author and i get one line and a BLOB in the AUTHORS

    SELECT ProdID, ProdTitle, GROUP_CONCAT(CONCAT(Contacts.ContactFName, " ", Contacts.ContactLName)) AS Authors FROM Products LEFT OUTER JOIN...

    Question #1 is why does this not work. Question #2 is how can I use the resulting "Authors" in the WHERE clause against a search string. Edit 1 ref Question 2: I realize I can redo the concat in the where clause, and that is a fine answer if there are no other options, I just thought you could use the newly created "column" in the where clause directly. Seems cleaner then doing the code twice.

    ***************** "We need to apply 21st-century information technology to the health care field. We need to have our medical records put on the I.T." —GW

    Database question database

  • Best Practices - mysql calls
    D Dwayner79

    Thanks. You say: if you a can create common function that will be used by multiple page, then make that one function. My main question is if doing so causes multiple MySQL calls that would not otherwise be required, is that bad practice? Thanks in advance.

    ***************** "We need to apply 21st-century information technology to the health care field. We need to have our medical records put on the I.T." —GW

    Linux, Apache, MySQL, PHP tutorial question php database mysql

  • Best Practices - mysql calls
    D Dwayner79

    I traditionally live in the client app world, so minimizing lines of code is more important than performance, so my coding style is heavy on common functions, etc. Now that I am working on a web app (PHP and mySQL), I find myself second guessing everything. Here is an example. I am working on a shopping cart for an existing site. There are multiple places where the price of a particular product is returned: Product Page Cart over view Buy process page, receipt print, etc. In most cases, the product data (price) is already available, but the price can vary in different circumstances. I'm considering one function that gets passed the important variables, calculated the price of the product, and returns that price. However, to do so will require polling the database each time each price is requested (in some cases that is multiple prices on one page, so multiple calls to the database while the page is loading). So my question is really one of best practice. How much of a noticeable performance hit does each call to the database take? Is it common to try to reduce the number of mysql calls? Do you not care? should each page have its own code, and just copy paste all over, and tweek each place where common data is shown? There is a lot of how to questions (I have posted them) but I am hoping the community here can offer some more higher level theory. Thank you in advance!

    ***************** "We need to apply 21st-century information technology to the health care field. We need to have our medical records put on the I.T." —GW

    Linux, Apache, MySQL, PHP tutorial question php database mysql

  • Decrementing a column - code not working
    D Dwayner79

    Thanks for the replys... I have error checking

    $u_result = @mysql_query($u_sql, $link_b);
    if (!$u_result) { exit('

    Error reducing inventory: ' . mysql_error() . '

    ');}

    There is no error thrown, just that value is not reduced. Like an idiot, when scrubbing my data, I probably should have left it... My invProdID has - marks in them, so I needed quotes around them. Total newb error. Thank you both anyway. You assurances that it seemed right made me think down the typo path.

    ***************** "We need to apply 21st-century information technology to the health care field. We need to have our medical records put on the I.T." —GW

    Linux, Apache, MySQL, PHP database announcement

  • Decrementing a column - code not working
    D Dwayner79

    I was told this would work, but it is not. I do not know the value in a particular column, but I want to decrease it by a number. In other words, Dude buys 2 widgets, the inventory of said widget gets reduced by two.

    $u_sql='UPDATE sale_inventory SET invqty = invqty - '.$boughtqty.' WHERE invProdID='.$row['ProdID'];

    This yields an SQL Statement like:

    UPDATE sale_inventory SET invqty = invqty - 1 WHERE invProdID=1234567

    I cannot tell why this is not working. Thanks in advance.

    ***************** "We need to apply 21st-century information technology to the health care field. We need to have our medical records put on the I.T." —GW

    Linux, Apache, MySQL, PHP database announcement

  • For Loop does not work
    D Dwayner79

    Thank you both!

    ***************** "We need to apply 21st-century information technology to the health care field. We need to have our medical records put on the I.T." —GW

    Linux, Apache, MySQL, PHP csharp php data-structures json question

  • For Loop does not work
    D Dwayner79

    First time developing in PHP. Used to coding in c#, so feel free to make fun of me. Here is the code I am using:

    <?php
    $response = file_get_contents($url);
    $jsonResults = json_decode($response, true);

    echo "Title: ".$jsonResults['items']['0']['volumeInfo']['title']; //this works
    echo "Title: ".$jsonResults['items']['1']['volumeInfo']['title']; //this works

    //this does not
    for ($i = 0; $i < $jsonResults['items'].length; $i++) {
    echo "Link: ".$jsonResults['items'][$i]['volumeInfo']['title'];
    }
    ?>

    Now the json results look like this:

    array(3) {
    ["items"]=>
    array(10) {
    [0]=>
    array(7) {
    ["volumeInfo"]=>
    array(12) {
    ["title"]=>
    string(64) "MyTitle"
    }

    ***************** "We need to apply 21st-century information technology to the health care field. We need to have our medical records put on the I.T." —GW

    Linux, Apache, MySQL, PHP csharp php data-structures json question

  • [solved] Subracting two shorts [modified]
    D Dwayner79

    Luc, Thanks for your explanation. Not sure if the last line is meant condescendingly, but I value your input too much to complain ;-) . And your right. Its been a while since I really dug through my c# books. This is a PT thing for me. When it was FT, I did spend a lot more time in the books. Thanks again.

    ***************** "We need to apply 21st-century information technology to the health care field. We need to have our medical records put on the I.T." —GW

    C# help question

  • [solved] Proper way to sort a List&lt;&gt; Custom objects
    D Dwayner79

    This is why I love codeproject. It should be a ulong. Thanks!

    ***************** "We need to apply 21st-century information technology to the health care field. We need to have our medical records put on the I.T." —GW

    C# data-structures question

  • [solved] Proper way to sort a List&lt;&gt; Custom objects
    D Dwayner79

    I have been thinking about this for a while and want to be correct in how I go about this. I have a custom struct.

        struct MYSTRUCT
        {
            public double address;
            public short datLen;
            public string data;
        }
    

    I am using an array for these, and chose the List<> because of the Add method. What I want to do is resort the list based on the Address highest to lowest. I am pretty unfamiliar with the IComparer and Comparison option in the built in List<>Sort. Will one of those work for me? Do I override the Sort method? Do I just create a new method to sort the list? How would you guys go about this? Thanks in advance.

    ***************** "We need to apply 21st-century information technology to the health care field. We need to have our medical records put on the I.T." —GW

    modified on Sunday, August 30, 2009 10:14 PM

    C# data-structures question

  • [solved] Subracting two shorts [modified]
    D Dwayner79

    Thanks to both. That makes very little sense to me. If anyone knows a good *why* answer, I would love to hear it, but I will just use a cast. Thanks,

    ***************** "We need to apply 21st-century information technology to the health care field. We need to have our medical records put on the I.T." —GW

    C# help question

  • [solved] Subracting two shorts [modified]
    D Dwayner79

    I have this bit of code:

    short s1 = 10;
    short s2 = 5;
    short s3 = s1 - s2;

    Error says: Error Cannot implicitly convert type 'int' to 'short'. An explicit conversion exists (are you missing a cast?) Aren't shorts just 16 bit integers? You can't subtract two of them?

    ***************** "We need to apply 21st-century information technology to the health care field. We need to have our medical records put on the I.T." —GW

    modified on Sunday, August 30, 2009 9:45 PM

    C# help question

  • Launch txt file in deafult text editor
    D Dwayner79

    Both of you THANKS! and DUH on me. Many users will have notepad, but I know the particular user I am dealing with uses textpad. I wanted it to just call whatever is associated. Thanks again.

    ***************** "We need to apply 21st-century information technology to the health care field. We need to have our medical records put on the I.T." —GW

    C# windows-admin tutorial

  • Launch txt file in deafult text editor
    D Dwayner79

    I need a function that launches a text file in the users default text editor. It would be easy enough to launch notepad, but notepad is horrid. How to I grab the executable that is used for the .txt extension. I assume this is a registry thing, and I have avoided the registry in the past. Thanks.

    ***************** "We need to apply 21st-century information technology to the health care field. We need to have our medical records put on the I.T." —GW

    C# windows-admin tutorial

  • Local Variable and "global" with same name
    D Dwayner79

    I thought in VS2003, it would compile error (or at least warn) of variables in the same namespace that have the same name. While I see how the compiler figures it out, it does not seem like good practice??? What if I DID want to access the global checksum in myFunction2? Would this. still work?

    ***************** "We need to apply 21st-century information technology to the health care field. We need to have our medical records put on the I.T." —GW

    C# csharp data-structures question

  • Local Variable and "global" with same name
    D Dwayner79

    I am working with two functions that format a byte array in preparation to send down the serial port (which .Net 2.0 is a but rough) and strip the formatting from the bytes recieved. These work fairly well, but in this case I had to make a few variables class wide because of the way .Net serial port works. These two functions have similar form, and as such, they use some common variable names. The one in particular was "checksum". Long story short, I move one of the function's "checksum" to a class-wide global variable and left the other in the function. I.E: namespace Coda_Verifier_Pro { public partial class MainForm : Form { byte checksum; private void myFunction1() { checksum = 0x00; //do stuff with checksum } private void myFunction2() { byte checksum; checksum = 0x00; //do stuff with checksum } } } Shouldn't the complier catch this? Am I missing something obvious? This is why I hate using Global variables. ***************** "We need to apply 21st-century information technology to the health care field. We need to have our medical records put on the I.T." —GW

    C# csharp data-structures question

  • Spliting short to 2 bytes
    D Dwayner79

    Nevermind: http://msdn2.microsoft.com/en-gb/library/system.bitconverter.getbytes.aspx

    ***************** "We need to apply 21st-century information technology to the health care field. We need to have our medical records put on the I.T." —GW

    C#

  • Spliting short to 2 bytes
    D Dwayner79

    I need to split MSB and LSB from a short. Thanks in advance.

    ***************** "We need to apply 21st-century information technology to the health care field. We need to have our medical records put on the I.T." —GW

    C#
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups