mysql

Let users choice modules they want

I'm making a social gaming network, for learning but mostly because php is alot of fun! Anyway I want this future.. I wanna let my users chose which "modules" they want activated, like a message board on their profile, polls, buddy list, contact box. Some modules will have to be purchased with points. Im thinking on something like thi...

Retrieving a set of all Nth children

The situation: MySQL 5.0 2 tables 1-to-many parent-child foreign key relationship (A.ID = B.PARENT_ID) What's needed: A SELECT query that yields the set of all the Nth children (sorted by their IDs) Also need a form for use in UPDATE Example: Table B | ID | PARENT_ID | ------------------ | 1 | 1 | | 2 | 1 | | ...

How to use case sensitivity in instr() in MySQL?

Possible duplicate: How to apply wildcard in instr() in MySQL? The possible duplicate linked shows a query which is exactly like my current one sort of. However, I cannot find a way to make it a case sensitive match. :\ SELECT COUNT(*) FROM users WHERE INSTR(flags, 'T') > 0; I get a count of 46 which is obviously wrong. It's counting...

mySQL DB: Making simultaneous entries?

Consider the following tables for a LMS: Item ( ID BIGINT NOT NULL UNIQUE AUTO_INCREMENT, ConnectLog BIGINT NOT NULL, ItemClass BIGINT NOT NULL, ItemType BIGINT NOT NULL, AcqDate TIMESTAMP NOT NULL DEFAULT NOW(), Vendor BIGINT NOT NULL, Cost DECIMAL(64,2) NOT NULL DEFAULT '0....

Check if friend relationship already exist

Why wont this code work? I want to check if the users are already friends before I add. function addFriend() { global $userid, $friendid; $check = mysql_query("SELECT * FROM friends WHERE userid = $userid AND friendid = $friendid"); if (mysql_num_rows($check) == 1) { exit("Youre already friend with this user"); } else { $sql = "INS...

Is there a "Northwind" type database available for MySQL?

I need some test data for a MySQL utility that I am creating. Does anybody know where I can find one that has a similiar (if not more) amount of data as Northwind for SQL Server? ...

little complex sql row postion

basically i have albums, which has 50 images init.. now if i show list of images, i know from which to which row is showing (showing: 20 to 30 of 50), means showing 10 rows from 20 - 30. well now the problem is, i want to select an image, but still show which postion was it selected, so i can move back and forth, but keep the postion too...

Looping through data from multiple tables PHP/Mysql

HI all, I am trying to figure out how to put this into words even, but I am wanting to know how to format the output from each table separately in a "multiple table" mysql query. The output from the table1 "wall" is formatted within a while loop, but the content from table2 "actions" is already formatted(as 1 line of text with links) be...

Building a jar with MySQL jdbc on solaris

Hi All, Im building a java application that uses JDBC to connect to MySQL. I have an ant script that compiles my code and then packages it, along with log4j, junit, libshout-java and the mysql jdbc driver into one executable jar. This all works fine on ubuntu 9.10, and my code connects to mysql and away we go. However my production env...

Predict downloads

Hi, I'm writing a little tool that counts the downloads of an app. I save every download with a timestamp. What algorithm (php and mysql) is normally used for predicting eg todays downloads? Greets, Nick ...

order by and group by mysql

tell some big, diff between order by and group by, like sort columns data=>order by group it by similar data used for aggregation , order by could be used inside the grouped items , please Tell 5 diff ...

MySQL How to insert new record or update a field depending on whether it exists?

I am trying to implement a rating system where I keep the following two fields in my db table: rating (the current rating) num_rates (the number of ratings submitted so far) UPDATE mytable SET rating=((rating*num_rates)+$theRating)/num_rates, num_rates=num_rates+1 WHERE uniqueCol='$uniqueCol' the variables are from my PHP code. So, b...

my "remember me"-feature

Finally I have got this function to work. It does its job but it looks real messy, just wanna hear your thoughts and maybe theirs something I could improve? Thanks alot! Login $result = mysql_query("SELECT * FROM users WHERE username = '".mysql_real_escape_string($_POST['username'])."' AND password = '".md5($_POST['password'])."'"); $...

Create an html table like this one

Hello guys I have a table in DB that has messages exchanged between groups and I need to create a table like this one (messages exchanged between 2 groups): knowing that Gr1,.... are group names from DB and numbers are from DB too. Edited to add sQL query (given by Sarah in comments -below): (SELECT COUNT( Msg_ID ) AS msgcount, Gr...

Performance of local domain vs localhost

Is there a performance difference between TCP connections to: localhost / 127.0.0.1 a domain which resolves to the local machine Or more specifically, do the latter connections go through the loopback device, or over the actual network? The reason I'm asking is I'm thinking about changing database settings in many PHP apps so they u...

MYSQL with Coldfusion - Solutions to create Search Capabilites?

I'm using MySQL & ColdFusion. Currently for searching TEXT fields I'm using LIKE in the database. Luckily my database is empty but soon the table will fill up and I fear I the LIKE SQL query will kill my app. I'm looking for a solution that works with both MySQL & ColdFusion that will allow me to scalably offer search capabilities with ...

MySQL: Table structure for a user's "views"

I've got a question to which I've had opposing pieces of advice, would appreciate additional views. My site has users, each with a user_id. These users can view products, and I need to keep track of the unique instances of users viewing specific products. To record a view in a separate views table, I've currently got two options: OPTIO...

How to create Bold data in MySQL database text field?

Is it possible to create bold text in a MySQL database text table field? We are putting our articles in our database and I want to create bold titles and subtitles. Is this possible? Thanks ...

MySQL Row-level Revision Control

I’m creating revision control for data in our database. It will have the ability to store revisions, rollback, and rollback rollbacks. The database tables I’m using that needs to be revisioned is below: objects object_chunks object_attributes Objects is the main object, chunks are grouped up sections of the object, and attributes are a...

How to show only one duplicate?

This is kind of an extension of this question of mysql not in or value=0? I have two databases one has the widget information and the other is the layout of those widgets according to the module. On the page I have lists to put these widget such as Header, Content, Sidebar, and Footer. There is also a list of widget that are not being u...