mysql

Find top contributers from DB

Each post that gets created on my site get stored in a database table, inside that table is a column which lists the users username. I'd like to find the top 10 contributers to my site, how can I count all the posts create by all users and then display the top 10 contributers in a list. Table name: posts Table column: username Each po...

mysql server port number

I've just made a database on mysql on my server. I want to connect to this via my website using php. This is the contents of my connections file: $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = 'password'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql'); $dbname = 'epub'; mysql_select_db($db...

url safe name function in mysql

I have this php function wich generate name from title which contains polish local characters like ł,ó,ż,ć function safe_name($name) { $chars = array('ą' => 'a', 'ż' => 'z', 'ź' => 'z', 'ś' => 's', 'ć' => 'c', 'ó' => 'o', 'ł' => 'l', ' ' => '-', '"' => '-', "'" => '-'); $result = strtr(strtolower(trim($name)), $chars); return pre...

how can i create a success back function?

$(function() { $(".follow").click(function(){ var element = $(this); var I = element.attr("id"); var info = 'id=' + I; $.ajax({ type: "POST", url: "listen.php", data: info, success: function(){} }); $("#follow"+I).hide(); ///showi...

how to solve this particular query?

table1 table2 col1 date col1 date a d1 e d4 b d2 f d5 c d3 a d6 I want a new table which have 4 entries order by date but if any entries of column 1 replicate it remove this duplication also. suppose if my date order is d1>d6>d2>d3>d5>d4 then result should be: col1 date a d1 b ...

How to add column in a table on fly?

i want to add two tables. But how should i distinguish that which entries is from which table? table1 col1 ----- a b c table 2 1 2 3 The result should be: col1 tablename ---------------- a table1 b " c " d table2 e " f " ...

SQL - Correct query for sorting items by values from other table

Hi there! I've got a little problem with correct query and hope you can help me. My testing tables structures are as follow: CREATE TABLE IF NOT EXISTS `users` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(45) DEFAULT NULL, PRIMARY KEY (`id`), ) ; CREATE TABLE IF NOT EXISTS `user_throws` ( `id` int(11) NOT NULL AUTO_I...

PHP/MySQL editing database and calling values

I've done some work with PHP/MySQL in the past but not huge amounts. This should be a fairly simple problem I would have thought. I have a table called 'user' inside which there are columns called 'id' (primary key), 'name', 'room', 'subject, and 'fb' (facebook profile URL). I need to add values to each of these eg. id: 1 name: bob roo...

Search Box - Selecting Data from Multiple Tables

In my application, I want to create a "universal search" box that will allow the users to perform a general search on any of the 'informational' data within the database. The system happens to be an account management system, so ideally they'd be able to do searches for e-mail addresses, usernames, ID's, etc. I've been searching around...

my jquery ajax request is not accessing the the database?

jQuery(function ($) { /* fetch elements and stop form event */ $("form.follow-form").submit(function (e) { /* stop event */ e.preventDefault(); /* "on request" */ $(this).find('i').addClass('active'); /* send ajax request */ $.post('recycle.php', { followID: $(this).find...

Problem HIbernate + Mysql

I'm having the following problem. I have a survey which indicate the start / end of a given process. When I select the start date, everything works. When I put only the end date (and no other filter the search), here comes the problem. I have a monster delay in the research and the session falls Ext. My bank has about 250,000 registered...

How to find changes in a table relative to an initial SQL fixture?

I have a number of tests that run against a MySQL database which is pre-loaded with schemas and example data from a set of SQL files. Some of these tests, during their run, also create new data in the database. Normally, tests are responsible for cleaning up after themselves (and thus not polluting the database environment for other tes...

Create dynamic associated array. Please help!

Hello, I got a database with 2 fields (amount and name). I want to get all data from the database (40 rows) and create an associated array out of it like this. $arr = array("amount" => "12", "name" => "John"); How is this done dynamically in PHP? I am stuck. ...

MySQL count and total

I have a table with a number of votes recorded in it, each vote goes against a post. What I want to be able to do is count the total occurances of each vote. Table looks like this: vote ----- 1 2 3 1 2 3 4 5 2 2 2 2 ...and so on... How can I count the records, e.g. In that ...

How to format a SQL query into a more human-readable format?

I'm looking for a program that can take in an SQL string, (my environment is MySQL, but I could look at similar tools for other RDBMSs) parse it and render it again in a format that is more human-readable. I've seen some online ones, but I'm hoping for one that I can integrate into some internal logging tools. For example, taking: SELE...

Generate a dynamic grid and populate selected cells. Please help!

Hello, I want to generate a grid where people can selected one or more cells and then save them into the database in this format (row,cell): 18,27 18,28 19,27 19,28 Then I want to generate the grid and at the same time mark the cells that is occupied. I have managed to do this (see below) but it does not feel right and I must get the...

MySQL join multiple columns from same table

Hi all I am trying to write a query that returns a users profile information, along with a count of occurrences of the user's ID in 2 columns from another table. An example below: TableA userID userName 1 UserA 2 UserB TableB LinkID leadID followID 1 1 2 2 1 3 3 2 1 Querying against...

Since information_schema is a standard, where can i find the documentation of it?

Hi, Many databases has a information_schema database, since it is a standard. I want to know where can i find the documentation of it. Such as meaning of columns etc. Thanks. ...

Mysql: limits on table count, rows, and such

I'm working on a social network. From what I've gathered, there's a limit at 1792 for number of tables in a mysql cluster. I will probably end up with 100-200 tables for now. Is this reasonable/acceptable? Or is my db schema horrible like this? What is reasonable for a large scale project such as a social network? Also, what then is t...

Multiple delete in a single query.

Hi, DELETE FROM Table1 WHERE ConditionID=?ConditionID; DELETE FROM Table2 WHERE ConditionID=?ConditionID; DELETE FROM Table3 WHERE ConditionID=?ConditionID; ConditionID is a column present in Table1,Table2,Table3, instead of running 3 times individually, is there a way to run all the three in a single query(in mysql)? Thanks. ...