Search Results

Search found 2655 results on 107 pages for 'city'.

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

  • How can I get a distinct list of elements in a hierarchical query?

    - by RenderIn
    I have a database table, with people identified by a name, a job and a city. I have a second table that contains a hierarchical representation of every job in the company in every city. Suppose I have 3 people in the people table: [name(PK),title,city] Jim, Salesman, Houston Jane, Associate Marketer, Chicago Bill, Cashier, New York And I have thousands of job type/location combinations in the job table, a sample of which follow. You can see the hierarchical relationship since parent_title is a foreign key to title: [title,city,pay,parent_title] Salesman, Houston, $50000, CEO Cashier, Houston, $25000 CEO, USA, $1000000 Associate Marketer, Chicago, $75000 Senior Marketer, Chicago, $125000 ..... The problem I'm having is that my Person table is a composite key, so I don't know how to structure the start with part of my query so that it starts with each of the three jobs in the cities I specified. I can execute three separate queries to get what I want, but this doesn't scale well. e.g.: select * from jobs start with city = (select city from people where name = 'Bill') and title = (select title from people where name = 'Bill') connect by prior parent_title = title UNION select * from jobs start with city = (select city from people where name = 'Jim') and title = (select title from people where name = 'Jim') connect by prior parent_title = title UNION select * from jobs start with city = (select city from people where name = 'Jane') and title = (select title from people where name = 'Jane') connect by prior parent_title = title How else can I get a distinct list (or I could wrap it with a distinct if not possible) of all the jobs which are above the three people I specified?

    Read the article

  • Adding Column While Selecting Table in SQl

    - by kmkperumal
    My First Table is ProjectCustomFields CustomFieldId ProjectId CustomFieldName CustomFieldRequired CustomFieldDataType 69 1 User Name 1 0 72 1 City 1 0 74 1 Email 0 0 82 1 Salary 1 2 My Second Table is ProjectCustomFieldValues CustomFieldValueId ProjectId CustomFieldId CustomFieldValue RecordId 35 1 69 kaliya 1 36 1 72 Bangalore 1 37 1 74 [email protected] 1 41 1 69 Yohesh 2 42 1 72 Delhi 2 43 1 74 2 50 1 69 sss 3 51 1 72 Delhi 3 52 1 74 [email protected] 3 57 1 69 Sunil 4 58 1 72 Mumbai 4 59 1 74 [email protected] 4 60 1 82 20000 4 I tried Below Query Select M.CustomFieldName,N.CustomFieldValue,N.RecordId From (Select G.CustomFieldName,H.RecordId From (Select CustomFieldName From ProjectCustomFields Where ProjectId=1) G Cross Join (Select Distinct RecordId From ProjectCustomFieldValues) H) M Left Join (Select CustFiled.CustomFieldName,CustValue.CustomFieldValue,CustValue.RecordId From ProjectCustomFieldValues CustValue Left Join ProjectCustomFields CustFiled On CustValue.CustomFieldId=CustFiled.CustomFieldId Where CustValue.AuctionId=1 ) N On M.CustomFieldName=N.CustomFieldName And M.RecordId=N.RecordId But I got the result below #CustomFieldName# CustomFieldValue RecordId User Name kaliya 1 City Bangalore 1 Email [email protected] 1 Salary NULL **NULL** User Name Yohesh 2 City Delhi 2 Email 2 Salary NULL **NULL** User Name sss 3 City Delhi 3 Email [email protected] 3 Salary NULL **NULL** User Name NULL **NULL** City NULL **NULL** Email NULL **NULL** Salary NULL **NULL** User Name Sunil 4 City Mumbai 4 Email [email protected] 4 Salary 20000 4 But Expected Result is CustomFieldName CustomFieldValue RecordId User Name kaliya 1 City Bangalore 1 Email [email protected] 1 Salary NULL **1** User Name Yohesh 2 City Delhi 2 Email 2 Salary NULL **2** User Name sss 3 City Delhi 3 Email [email protected] 3 Salary NULL **3** User Name Sunil 4 City Mumbai 4 Email [email protected] 4 Salary 20000 4 Please guide me some one,I tried so much but i got null value in recordId,So I need same recordId above one..

    Read the article

  • Can't parse XML effectively using Python

    - by Harshit Sharma
    import urllib import xml.etree.ElementTree as ET def getWeather(city): #create google weather api url url = "http://www.google.com/ig/api?weather=" + urllib.quote(city) try: # open google weather api url f = urllib.urlopen(url) except: # if there was an error opening the url, return return "Error opening url" # read contents to a string s = f.read() tree=ET.parse(s) current= tree.find("current_condition/condition") condition_data = current.get("data") weather = condition_data if weather == "<?xml version=": return "Invalid city" #return the weather condition #return weather def main(): while True: city = raw_input("Give me a city: ") weather = getWeather(city) print(weather) if __name__ == "__main__": main() gives error , I actually wanted to find values from google weather xml site tags

    Read the article

  • How to implement python to find value between xml tags?

    - by Harshit Sharma
    I am using google site to retrieve weather information , I want to find values between XML tags. Following code give me weather condition of a city , but I am unable to obtain other parameters such as temperature and if possible explain working of split function implied in the code: import urllib def getWeather(city): #create google weather api url url = "http://www.google.com/ig/api?weather=" + urllib.quote(city) try: # open google weather api url f = urllib.urlopen(url) except: # if there was an error opening the url, return return "Error opening url" # read contents to a string s = f.read() # extract weather condition data from xml string weather = s.split("<current_conditions><condition data=\"")[-1].split("\"")[0] # if there was an error getting the condition, the city is invalid if weather == "<?xml version=": return "Invalid city" #return the weather condition return weather def main(): while True: city = raw_input("Give me a city: ") weather = getWeather(city) print(weather) if __name__ == "__main__": main() Thank You

    Read the article

  • Can't make HREF change based on PHP value

    - by Liso22
    I want to retrieve the user's location and then show a link that points to an URL that changes according to that location. I just want to place the user's city name at the end of the HREF. I need this work on my wordpress site, on a static page. I use a plugin called Exec-php which let's me run PHP in pages. I have a plugin that provides me the user's city through the shortcode "[mmjs-city]". I tried to make it work through different paths but I never get the link to work. Here I tried assigning that shortcode to a value, <?php $city= "[mmjs-city]"; echo $city; echo "<a href='?s=" . $city ."'>Search for your city</a>"; ?> I added the first two lines to check whether the shortcode is working or not and if it's correctly assinged to the value $city. That part works. Then it creates the link and put's the value $city at the end of it. But when trying it instead of taking me to: /?s=new+york It takes me to: /?s=%3Cscript%20language=%22javascript%22%3Edocument.write(geoip_city());%3C/script%3E I have no idea what to do. I would be really thankful for any info on how to make it work, it's really an important feature for my site. Please ask for any further info or idk anything. Also this is where I tested that code: http://chusmix.com/?page_id=1129 Thanks

    Read the article

  • Listing issue, GROUP mysql

    - by SethCodes
    Here is a mock-up example of Mysql table: | ID | Country | City | ________________________________ | 1 | Sweden | Stockholm | | 2 | Sweden | Stockholm | | 3 | Sweden | Lund | | 4 | Sweden | Lund | | 5 | Germany | Berlin | | 6 | Germany | Berlin | | 7 | Germany | Hamburg | | 8 | Germany | Hamburg | Notice how both rows Country and city have repeated values inside them. Using GROUP BY country, city in my PDO query, the values will not repeat while in loop. Here is PDO for this: $query = "SELECT id, city, country FROM table GROUP BY country, city"; $stmt = $db->query($query); while($row = $stmt->fetch(PDO::FETCH_ASSOC)) : The above code will result in an output like this (some editing in-between). GROUP BY works but the country repeats: Sweden - Stockholm Sweden - Lund Germany - Berlin Germany - Hamburg Using bootstrap collapse and above code, I separate the country from the city with a simple drop down collopase. Here is code: <li> <a data-toggle="collapse" data-target="#<?= $row['id']; ?>" href="search.php?country=<?= $row['country']; ?>"> <?= $row['country']; ?> </a> <div id ="<?= $row['id']; ?>" class="collapse in"> //collapse div here <a href="search.php?city=<?= $row['city']; ?>"> <?= $row['city']; ?><br></a> </div> //end </li> It then looks something like this (once collapse is initiated): Sweden > Stockholm Sweden > Lund Germany >Berlin Germany >Hamburg Here is where I face the problem. The above lists the values Sweden and Germany 2 times. I want Sweden and Germany to only list one time, and the cities listed below, so the desired look is to be this: Sweden // Lists one time > Stockholm > Lund Germany // Lists one time >Berlin >Hamburg I have tried using DISTINCT, GROUP_CONTACT and other methods, yet none get my desired output (above). Suggestions? Below is my current full code in action: <? $query = "SELECT id, city, country FROM table GROUP BY country, city"; $stmt = $db->query($query); while($row = $stmt->fetch(PDO::FETCH_ASSOC)) : ?> <li> <a data-toggle="collapse" data-target="#<?= $row['id']; ?>" href="search.php?country=<?= $row['country']; ?>"> <?= $row['country']; ?> </a> <div id ="<?= $row['id']; ?>" class="collapse in"> //collapse div here <a href="search.php?city=<?= $row['city']; ?>"> <?= $row['city']; ?><br></a> </div> //end </li> <? endwhile ?>

    Read the article

  • What Java data structure/design pattern best models this object, considering it would perform these methods?

    - by zundarz
    Methods: 1. getDistance(CityA,CityB) // Returns distance between two cities 2. getCitiesInRadius(CityA,integer) // Returns cities within a given distance of another city 3. getCitiesBeyondRadius(CityA,integer) //Returns cities beyond a given distance of another city 4. getRemoteDestinations(integer) // Returns all city pairs greater than x distance of each other 5. getLocalDestinations(integer) //Returns all city pairs within x distance of each other

    Read the article

  • Building Queries Systematically

    - by Jeremy Smyth
    The SQL language is a bit like a toolkit for data. It consists of lots of little fiddly bits of syntax that, taken together, allow you to build complex edifices and return powerful results. For the uninitiated, the many tools can be quite confusing, and it's sometimes difficult to decide how to go about the process of building non-trivial queries, that is, queries that are more than a simple SELECT a, b FROM c; A System for Building Queries When you're building queries, you could use a system like the following:  Decide which fields contain the values you want to use in our output, and how you wish to alias those fields Values you want to see in your output Values you want to use in calculations . For example, to calculate margin on a product, you could calculate price - cost and give it the alias margin. Values you want to filter with. For example, you might only want to see products that weigh more than 2Kg or that are blue. The weight or colour columns could contain that information. Values you want to order by. For example you might want the most expensive products first, and the least last. You could use the price column in descending order to achieve that. Assuming the fields you've picked in point 1 are in multiple tables, find the connections between those tables Look for relationships between tables and identify the columns that implement those relationships. For example, The Orders table could have a CustomerID field referencing the same column in the Customers table. Sometimes the problem doesn't use relationships but rests on a different field; sometimes the query is looking for a coincidence of fact rather than a foreign key constraint. For example you might have sales representatives who live in the same state as a customer; this information is normally not used in relationships, but if your query is for organizing events where sales representatives meet customers, it's useful in that query. In such a case you would record the names of columns at either end of such a connection. Sometimes relationships require a bridge, a junction table that wasn't identified in point 1 above but is needed to connect tables you need; these are used in "many-to-many relationships". In these cases you need to record the columns in each table that connect to similar columns in other tables. Construct a join or series of joins using the fields and tables identified in point 2 above. This becomes your FROM clause. Filter using some of the fields in point 1 above. This becomes your WHERE clause. Construct an ORDER BY clause using values from point 1 above that are relevant to the desired order of the output rows. Project the result using the remainder of the fields in point 1 above. This becomes your SELECT clause. A Worked Example   Let's say you want to query the world database to find a list of countries (with their capitals) and the change in GNP, using the difference between the GNP and GNPOld columns, and that you only want to see results for countries with a population greater than 100,000,000. Using the system described above, we could do the following:  The Country.Name and City.Name columns contain the name of the country and city respectively.  The change in GNP comes from the calculation GNP - GNPOld. Both those columns are in the Country table. This calculation is also used to order the output, in descending order To see only countries with a population greater than 100,000,000, you need the Population field of the Country table. There is also a Population field in the City table, so you'll need to specify the table name to disambiguate. You can also represent a number like 100 million as 100e6 instead of 100000000 to make it easier to read. Because the fields come from the Country and City tables, you'll need to join them. There are two relationships between these tables: Each city is hosted within a country, and the city's CountryCode column identifies that country. Also, each country has a capital city, whose ID is contained within the country's Capital column. This latter relationship is the one to use, so the relevant columns and the condition that uses them is represented by the following FROM clause:  FROM Country JOIN City ON Country.Capital = City.ID The statement should only return countries with a population greater than 100,000,000. Country.Population is the relevant column, so the WHERE clause becomes:  WHERE Country.Population > 100e6  To sort the result set in reverse order of difference in GNP, you could use either the calculation, or the position in the output (it's the third column): ORDER BY GNP - GNPOld or ORDER BY 3 Finally, project the columns you wish to see by constructing the SELECT clause: SELECT Country.Name AS Country, City.Name AS Capital,        GNP - GNPOld AS `Difference in GNP`  The whole statement ends up looking like this:  mysql> SELECT Country.Name AS Country, City.Name AS Capital, -> GNP - GNPOld AS `Difference in GNP` -> FROM Country JOIN City ON Country.Capital = City.ID -> WHERE Country.Population > 100e6 -> ORDER BY 3 DESC; +--------------------+------------+-------------------+ | Country            | Capital    | Difference in GNP | +--------------------+------------+-------------------+ | United States | Washington | 399800.00 | | China | Peking | 64549.00 | | India | New Delhi | 16542.00 | | Nigeria | Abuja | 7084.00 | | Pakistan | Islamabad | 2740.00 | | Bangladesh | Dhaka | 886.00 | | Brazil | Brasília | -27369.00 | | Indonesia | Jakarta | -130020.00 | | Russian Federation | Moscow | -166381.00 | | Japan | Tokyo | -405596.00 | +--------------------+------------+-------------------+ 10 rows in set (0.00 sec) Queries with Aggregates and GROUP BY While this system might work well for many queries, it doesn't cater for situations where you have complex summaries and aggregation. For aggregation, you'd start with choosing which columns to view in the output, but this time you'd construct them as aggregate expressions. For example, you could look at the average population, or the count of distinct regions.You could also perform more complex aggregations, such as the average of GNP per head of population calculated as AVG(GNP/Population). Having chosen the values to appear in the output, you must choose how to aggregate those values. A useful way to think about this is that every aggregate query is of the form X, Y per Z. The SELECT clause contains the expressions for X and Y, as already described, and Z becomes your GROUP BY clause. Ordinarily you would also include Z in the query so you see how you are grouping, so the output becomes Z, X, Y per Z.  As an example, consider the following, which shows a count of  countries and the average population per continent:  mysql> SELECT Continent, COUNT(Name), AVG(Population)     -> FROM Country     -> GROUP BY Continent; +---------------+-------------+-----------------+ | Continent     | COUNT(Name) | AVG(Population) | +---------------+-------------+-----------------+ | Asia          |          51 |   72647562.7451 | | Europe        |          46 |   15871186.9565 | | North America |          37 |   13053864.8649 | | Africa        |          58 |   13525431.0345 | | Oceania       |          28 |    1085755.3571 | | Antarctica    |           5 |          0.0000 | | South America |          14 |   24698571.4286 | +---------------+-------------+-----------------+ 7 rows in set (0.00 sec) In this case, X is the number of countries, Y is the average population, and Z is the continent. Of course, you could have more fields in the SELECT clause, and  more fields in the GROUP BY clause as you require. You would also normally alias columns to make the output more suited to your requirements. More Complex Queries  Queries can get considerably more interesting than this. You could also add joins and other expressions to your aggregate query, as in the earlier part of this post. You could have more complex conditions in the WHERE clause. Similarly, you could use queries such as these in subqueries of yet more complex super-queries. Each technique becomes another tool in your toolbox, until before you know it you're writing queries across 15 tables that take two pages to write out. But that's for another day...

    Read the article

  • How to select all options from a drop list in php / mysql

    - by Mirage81
    Thanks to stackoverflow.com's frienly experts I've managed to create my first php + mysql application. The code searches a mysql database for last names and cities. The choices are made through two drop lists like these: Choose city: All cities Liverpool Manchester Choose last name: All last names Lennon Gallagher The code would return eg. all the Lennons living in Liverpool. However, I haven't been able to make the options "All cities" and "All last names" to work so that the code would return eg. all the Lennons living in any city or all the people living in Liverpool. So, how can that be done? The code so far: index.php <?php $conn = mysql_connect('localhost', 'user', 'password') or die("Connection failed"); mysql_select_db("database", $conn) or die("Switch database failed"); //this gets the cities from the database to the drop list $query = "SELECT DISTINCT city FROM user".mysql_real_escape_string($city); $result = mysql_query($query, $conn); $options=""; while ($row=mysql_fetch_array($result)) { $city=$row["city"]; $options.="<OPTION VALUE=\"$city\">".$city; } //this gets the last names from the database to the drop list $query2 = "SELECT DISTINCT lastname FROM user".mysql_real_escape_string($lastname); $result2 = mysql_query($query2, $conn); $options2=""; while ($row2=mysql_fetch_array($result2)) { $lastname=$row2["lastname"]; $options2.="<OPTION VALUE=\"$lastname\">".$lastname; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"> <title>test</title> </head> <body> <form action="get.php" method="post"> <p> <select name="city"> <option value=0>Choose <option value=1>All cities <?=$options?> </select> </p> <p> <select name="lastname"> <option value=0>Choose <option value=1>All last names <?=$options2?> </select> </p> <p> <input value="Search" type="submit"> </p> </form> <br> </body> </html> get.php <?php $conn = mysql_connect('localhost', 'user', 'password') or die("Connection failed"); mysql_select_db("database", $conn) or die("Switch database failed"); $query = "SELECT * FROM user WHERE city = '".mysql_real_escape_string($_POST['city'])."' AND lastname = '".mysql_real_escape_string($_POST['lastname'])."'"; $result = mysql_query($query, $conn); echo $rowcount; $zerorows=true; while ($row = mysql_fetch_assoc($result)) { $zerorows=false; echo '<b>City: </b>'.htmlspecialchars($row[city]).'<br />'; echo '<b>Last name: </b>'.htmlspecialchars($row[lastname]).'<br />'; echo '<b>Information: </b>'.htmlspecialchars($row[information]).'<br />'.'<br />'; } if($zerorows) echo "No results"; mysql_close($conn); ?>

    Read the article

  • Geolocation SQL query not finding exact location

    - by Iridium52
    I have been testing my geolocation query for some time now and I haven't found any issues with it until now. I am trying to search for all cities within a given radius, often times I'm searching for cities surrounding a city using that city's coords, but recently I tried searching around a city and found that the city itself was not returned. I have these cities as an excerpt in my database: city latitude longitude Saint-Mathieu 45.316708 -73.516253 Saint-Édouard 45.233374 -73.516254 Saint-Michel 45.233374 -73.566256 Saint-Rémi 45.266708 -73.616257 But when I run my query around the city of Saint-Rémi, with the following query... SELECT tblcity.city, tblcity.latitude, tblcity.longitude, truncate((degrees(acos( sin(radians(tblcity.latitude)) * sin(radians(45.266708)) + cos(radians(tblcity.latitude)) * cos(radians(45.266708)) * cos(radians(tblcity.longitude - -73.616257) ) ) ) * 69.09*1.6),1) as distance FROM tblcity HAVING distance < 10 ORDER BY distance desc I get these results: city latitude longitude distance Saint-Mathieu 45.316708 -73.516253 9.5 Saint-Édouard 45.233374 -73.516254 8.6 Saint-Michel 45.233374 -73.566256 5.3 The town of Saint-Rémi is missing from the search. So I tried a modified query hoping to get a better result: SELECT tblcity.city, tblcity.latitude, tblcity.longitude, truncate(( 6371 * acos( cos( radians( 45.266708 ) ) * cos( radians( tblcity.latitude ) ) * cos( radians( tblcity.longitude ) - radians( -73.616257 ) ) + sin( radians( 45.266708 ) ) * sin( radians( tblcity.latitude ) ) ) ),1) AS distance FROM tblcity HAVING distance < 10 ORDER BY distance desc But I get the same result... However, if I modify Saint-Rémi's coords slighly by changing the last digit of the lat or long by 1, both queries will return Saint-Rémi. Also, if I center the query on any of the other cities above, the searched city is returned in the results. Can anyone shed some light on what may be causing my queries above to not display the searched city of Saint-Rémi? I have added a sample of the table (with extra fields removed) below. I'm using MySQL 5.0.45, thanks in advance. CREATE TABLE `tblcity` ( `IDCity` int(1) NOT NULL auto_increment, `City` varchar(155) NOT NULL default '', `Latitude` decimal(9,6) NOT NULL default '0.000000', `Longitude` decimal(9,6) NOT NULL default '0.000000', PRIMARY KEY (`IDCity`) ) ENGINE=MyISAM AUTO_INCREMENT=52743 DEFAULT CHARSET=latin1 AUTO_INCREMENT=52743; INSERT INTO `tblcity` (`city`, `latitude`, `longitude`) VALUES ('Saint-Mathieu', 45.316708, -73.516253), ('Saint-Édouard', 45.233374, -73.516254), ('Saint-Michel', 45.233374, -73.566256), ('Saint-Rémi', 45.266708, -73.616257);

    Read the article

  • c# - How do you get a variable's name as it was physically typed in its declaration?

    - by Petras
    The class below contains the field city. I need to dynamically determine the field's name as it is typed in the class declaration i.e. I need to get the string "city" from an instance of the object city. I have tried to do this by examining its Type in DoSomething() but can't find it when examining the contents of the Type in the debugger. Is it possible? public class Person { public string city = "New York"; public Person() { } public void DoSomething() { Type t = city.GetType(); string field_name = t.SomeUnkownFunction(); //would return the string "city" if it existed! } } Some people in their answers below have asked me why I want to do this. Here's why. In my real world situation, there is a custom attribute above city. [MyCustomAttribute("param1", "param2", etc)] public string city = "New York"; I need this attribute in other code. To get the attribute, I use reflection. And in the reflection code I need to type the string "city" MyCustomAttribute attr; Type t = typeof(Person); foreach (FieldInfo field in t.GetFields()) { if (field.Name == "city") { //do stuff when we find the field that has the attribute we need } } Now this isn't type safe. If I changed the variable "city" to "workCity" in my field declaration in Person this line would fail unless I knew to update the string if (field.Name == "workCity") //I have to make this change in another file for this to still work, yuk! { } So I am trying to find some way to pass the string to this code without physically typing it. Yes, I could declare it as a string constant in Person (or something like that) but that would still be typing it twice. Phew! That was tough to explain!! Thanks Thanks to all who answered this * a lot*. It sent me on a new path to better understand lambda expressions. And it created a new question.

    Read the article

  • NHibernate and objects with value-semantics

    - by Groo
    Problem: If I pass a class with value semantics (Equals method overridden) to NHibernate, NHibernate tries to save it to db even though it just saved an entity equal by value (but not by reference) to the database. What am I doing wrong? Here is a simplified example model for my problem: Let's say I have a Person entity and a City entity. One thread (producer) is creating new Person objects which belong to a specific existing City, and another thread (consumer) is saving them to a repository (using NHibernate as DAL). Since there is lot of objects being flushed at a time, I am using Guid.Comb id's to ensure that each insert is made using a single SQL command. City is an object with value-type semantics (equal by name only -- for this example purposes only): public class City : IEquatable<City> { public virtual Guid Id { get; private set; } public virtual string Name { get; set; } public virtual bool Equals(City other) { if (other == null) return false; return this.Name == other.Name; } public override bool Equals(object obj) { return Equals(obj as City); } public override int GetHashCode() { return this.Name.GetHashCode(); } } Fluent NH mapping is something like: public class PersonMap : ClassMap<Person> { public PersonMap() { Id(x => x.Id) .GeneratedBy.GuidComb(); References(x => x.City) .Cascade.SaveUpdate(); } } public class CityMap : ClassMap<City> { public CityMap() { Id(x => x.Id) .GeneratedBy.GuidComb(); Map(x => x.Name); } } Right now (with my current NHibernate mapping config), my consumer thread maintains a dictionary of cities and replaces their references in incoming person objects (otherwise NHibernate will see a new, non-cached City object and try to save it as well), and I need to do it for every produced Person object. Since I have implemented City class to behave like a value type, I hoped that NHibernate would compare Cities by value and not try to save them each time -- i.e. I would only need to do a lookup once per session and not care about them anymore. Is this possible, and if yes, what am I doing wrong here?

    Read the article

  • jQuery autocomplete: taking JSON input and setting multiple fields from single field

    - by Sly
    I am trying to get the jQuery autocomplete plugin to take a local JSON variable as input. Once the user has selected one option from the autocomplete list, I want the adjacent address fields to be autopopulated. Here's the JSON variable that declared as a global variable in the of the HTML file: var JSON_address={"1":{"origin":{"nametag":"Home","street":"Easy St","city":"Emerald City","state":"CA","zip":"9xxxx"},"destination":{"nametag":"Work","street":"Factory St","city":"San Francisco","state":"CA","zip":"94104"}},"2":{"origin":{"nametag":"Work","street":"Umpa Loompa St","city":"San Francisco","state":"CA","zip":"94104"},"destination":{"nametag":"Home","street":"Easy St","city":"Emerald City ","state":"CA","zip":"9xxxx"}}}</script> I want the first field to display a list of "origin" nametags: "Home", "Work". Then when "Home" is selected, adjacent fields are automatically populated with Street: Easy St, City: Emerald City, etc. Here's the code I have for the autocomplete: $(document).ready(function(){ $("#origin_nametag_id").autocomplete(JSON_address, { autoFill:true, minChars:0, dataType: 'json', parse: function(data) { var rows = new Array(); for (var i=0; i<=data.length; i++) { rows[rows.length] = { data:data[i], value:data[i].origin.nametag, result:data[i].origin.nametag }; } return rows; } }).change(function(){ $("#street_address_id").autocomplete({ dataType: 'json', parse: function(data) { var rows = new Array(); for (var i=0; i<=data.length; i++) { rows[rows.length] = { data:data[i], value:data[i].origin.street, result:data[i].origin.street }; } return rows; } }); }); }); So this question really has two subparts: 1) How do you get autocomplete to process the multi-dimensional JSON object? (When the field is clicked and text entered, nothing happens - no list) 2) How do you get the other fields (street, city, etc) to populate based upon the origin nametag sub-array? Thanks in advance!

    Read the article

  • Where I&rsquo;ve Been

    - by Lee Brandt
    Hey all. I am still here. Still kickin’. I’ve been swamped with work and community stuff. But I wanted to post about some of the things going on. Just finished up Twin Cities Code Camp 8, and had a blast! Always good to see these guys. First of all, up-coming speaking engagements: Iowa Code Camp – May 1st in Iowa City, IA [more info] DevLink – August 5-7 in Nashville, TN [more info]   Plus I am organizing a second developer’s conference in Kansas City. Kansas City Developer’s Conference (KCDC) – June 19th in Kansas City [more info]   I will also be doing Lunch & Learns for my company in April and May at JCCC: April 29th, May 12th and May 27th at Johnson County Community College in Kansas City.   So May, June and August are covered. I may just take July off, I could use a break after KCDC is over.

    Read the article

  • Algorithm for waypoint path following?

    - by Thierry Savard Saucier
    I have a worldmap, with different cities on it. The player can choose a city from a menu, or click on an available cities on the world map, and the toon should walk over there. I want him to follow a predefined path. Lets say our hero is on the city 1. He clicks on city 4. I want him to follow the path to city 2 and from there to city 4. I was handling this easily with arrow movement (left right top bottom) since its a single check. Now I'm not sure how I should do this. Should I loop threw each possible path and check which one leads me to D the fastest ... and if I do how do I avoid running in circle forever with cities 1-5-2 ?

    Read the article

  • Using PDO for Data Management

    - by edorahg
    This question is more a design oriented question than a code specific question. I am new to PHP and I am planning to use PDO as a data access layer. Say for instance I have a class called CITY. Now if I need to create an instance of this class, what is the best technique. Should have a singleton DB access class which is used to write and read data from the db layer. OR should I delegate it to the individual class object. For example if I invoke city.save() (city is a class), then the city class will handle the saving of that city object's data into the database. Excuse my ignorance but i have a java background and therefore trying to understand what is the best design principle for data management when using php.

    Read the article

  • Update table.column with another table.column with common joined column

    - by Matt
    Hit a speed bump, trying to update some column values in my table from another table. This is what is supposed to happen when everything works Correct all the city, state entries in tblWADonations by creating an update statement that moves the zip city from the joined city/state zip field to the tblWADonations city state TBL NAME | COLUMN NAMES tblZipcodes with zip,city,State tblWADonations with zip,oldcity,oldstate This is what I have so far: UPDATE tblWADonations SET oldCity = tblZipCodes.city, oldState = tblZipCodes.state FROM tblWADonations INNER JOIN tblZipCodes ON tblWADonations.zip = tblZipCodes.zip Where oldCity <> tblZipcodes.city; There seems to be easy ways to do this online but I am overlooking something. Tried this by hand and in editor this is what it kicks back. Msg 8152, Level 16, State 2, Line 1 String or binary data would be truncated. The statement has been terminated. Please include a sql statement or where I need to make the edit so I can mark this post as a reference in my favorites. Thanks!

    Read the article

  • DOM innerHTML Duplicate Problem

    - by Kubi
    function SwapPlans(city, id) { var tp = GetTravelPlanById(id); var content = MakeHTMLAccordionMe(tp.items[0]); document.getElementById(city).innerHTML = " "; document.getElementById(city).innerHTML = content.innerHTML; document.getElementById(city).outerHTML = " "; document.getElementById(city).outerHTML = content.outerHTML; } Hi, I have a problem with the snippet above. MakeAccordionME function returns the content that I want to change by document.getElementById(city) = value; but It doesn't remove the first content of the first div. Is there any content.clear method in DOM javascript ? thx p.s. the div that returns from document.getElementById(city) is a jquery accordion div.

    Read the article

  • How I can get logged in user's info like email id,name,city etc. in Facebook with uId

    - by vaibhavbhalke
    Hi all Can any one help me to get logged in user's info like email id,name,city etc. with the help of Facebook uId . " Long uid = apiClient.getLoggedInUser ();" Users_getInfo is not useful. It returns No of users connected to _User & according that there info gets. If user login successfully using fb connect, Facebook gives us uid. However, I need to match the logged in user with our member's account If that member is not present in DB then want to register him and I'm trying to do that with e-mail(hashed) address and other info.

    Read the article

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