[Solved] Sorting a list based on associated scores [closed]

I would approach this as follows: from collections import defaultdict # using defaultdict makes the sums easier correlations = defaultdict(int) # default to int (i.e. 0) for i1, i2, correl in strScoresDict: # loop through data correlations[i1] += correl # add score for first item correlations[i2] += correl # and second item output = sorted(correlations, … Read more

[Solved] Join 3rd Table in MYSQL [closed]

SELECT coll.title AS CollectionTitle, cont.CollectionID, cont.title AS ContainerTitle, cont.ID as ContainerID, cont.LevelContainerID, cont.ContentID, user.Title, user.Value, user.EADElementID FROM tblCollections_Content cont JOIN tblCollections_Collections coll ON cont.collectionid = coll.id JOIN tblCollections_UserFields user ON cont.ContentId = user.ContentId WHERE cont.title is NOT NULL ORDER BY CollectionID, ContainerID I have to assume you have a ContentID column in your tblCollections_Content to … Read more

[Solved] Query to get table name by searching data in SQL Server 20008 [closed]

You can search for a table name in a single database like follows: USE YourDatabaseName SELECT * FROM sys.Tables WHERE name LIKE ‘%SearchText%’ You can also search for a table name in all databases like Pinal Dave describes here: CREATE PROCEDURE usp_FindTableNameInAllDatabase @TableName VARCHAR(256) AS DECLARE @DBName VARCHAR(256) DECLARE @varSQL VARCHAR(512) DECLARE @getDBName CURSOR SET … Read more

[Solved] Querying comma separated field?

Just in case you really need it sorted now without redesigning your database (which I would)… $ids = array(1,2,4); $query = “SELECT room_location.*, client_room.*, users.* FROM room_location INNER JOIN client_room ON room_location.user_loc_id = client_room.id INNER JOIN users ON room_location.user_loc_id = users.userGroupLocID WHERE userGroupLocID REGEXP ‘(^|,)(“.implode(‘|’,$ids).”)(,|$)’ ORDER BY room_location.location”; 2 solved Querying comma separated field?

[Solved] Capitalization of the first letters of words in a sentence using python code [closed]

.split(sep): Specifically split method takes a string and returns a list of the words in the string, using sep as the delimiter string. If no separator value is passed, it takes whitespace as the separator. For example: a = “This is an example” a.split() # gives [‘This’, ‘is’, ‘an’, ‘example’] -> same as a.split(‘ ‘) … Read more

[Solved] Conditional fetching data from a table

In Your model add this method: public function getINFO(){ $query = $this->db->get_where(‘usuarios’, array(‘id’ => $this->session->userdata(‘id’))); if ($query->num_rows() > 0 ) { return $query->row_array(); } } See this link for more : https://www.codeigniter.com/user_guide/database/results.html#result-arrays 18 solved Conditional fetching data from a table

[Solved] Programming Challenges 110106 [closed]

I think you problem may be here while (input.hasNext()) { int num = Integer.parseInt(input.next()); if (input.next() == “”) { The second line reads an input, but so does the next line. So when the loop is at the last element, the first line will read it, then the next line will try to read a … Read more

[Solved] TCL Sort program without using lsort [closed]

While we won’t give you the answer, we can suggest a few useful things. For example, you compare two elements of a list (at $idx1 and $idx2) with this: string compare [lindex $theList $idx1] [lindex $theList $idx2] And you might use this procedure to swap those two elements: proc swap {nameOfListVar idx1 idx2} { upvar … Read more

[Solved] PrivateRouting when Token in Local Storage [TypeScript]

This will go in your index.tsx file: const token = localStorage.getItem(‘token’); const PrivateRoute = ({component, isAuthenticated, …rest}: any) => { const routeComponent = (props: any) => ( isAuthenticated ? React.createElement(component, props) : <Redirect to={{pathname: ‘/login’}}/> ); return <Route {…rest} render={routeComponent}/>; }; And use this in the browser router/switch: <PrivateRoute path=”/panel” isAuthenticated={token} component={PrivateContainer} /> solved PrivateRouting … Read more

[Solved] 500 Internal Error, Whats wrong with my code? [closed]

You have a little typo in the third line: $email = mysql_real_escape_string(strip-tags($_POST[’email’])); should be $email = mysql_real_escape_string(strip_tags($_POST[’email’])); And have a look at the comments, they are quite important. 0 solved 500 Internal Error, Whats wrong with my code? [closed]