mysql

Put the most popular option at first on a select box with mysql

Hi there. I'm new on mysql, but I have a database with some data, ordered by name: <option value="4"> George </option> <option value="55"> John </option> <option value="13"> Paul </option> <option value="24"> Ringo </option> I want to put this on a select, like this: while($row = mysql_fetch_array($result) ){ echo "<optio...

MySQL foreach alternative for procedure

My problem is fairly simple. I have table sets that store product sets (more products looking like one on the outside - computer, mouse and keyboard for ex.) it's connected M:N using sets_products table to products table. Each product can have parameters (connected again M:N). I have a procedure, that generates all parameters as string...

Maxmind GeoIP Country/City MySQL Open-Source Alternative

Is there an open-source alternative to MaxMind GeoIP Country/City that I can use for MySQL? ...

Display threaded comments with MySQL & PHP

Hello guys, Given the following table, how can write a MySQL query to display threaded comments in a single page? Table structure: comment_id comment_parent comment_content Thank you. ...

update in mysql select statement

Is there any way to run UPDATE or INSERT inside a SELECT statement in mysql? ...

Immediate update of site-map index in google, shouldn't that be impossible?

Ckeck out http://www.blocket.se/goteborg?ca=15 Look at the first ad. Copy the headline, and paste it into google, and also write 'blocket' after the headline in google, now search. You will see it finds the ad right away. How come? Does googles crawlers really update their index that fast? Or is it just because you entered that sea...

MySQL, per found record join a different parent table.

I have the following parent <-> child datamodel: (almost every line is a table, indented means child-of) consumerGoods food meat item fruit item vegetable item The child-items of meat, fruit and vegetables are in the same table (named items) because they have identical a...

MySQL - Do's and Don'ts

Hi, I am currently learning MySQL and am noticing a lot of different do's and don'ts. Is there anywhere I can find the absolute list of best practices that you go by or learned from? Thanks for your time. ...

HTML Radio button not showing up in $_POST

Hi, I have a forum the user fills out with 2 separate radio button categories they can fill out. Permissions: private <input type="radio" name="permissions" value="private" /> public <input type="radio" name="permissions" value="public"/><br /> Category: default <input type="radio" name="cat" value"default" /> sport <input type="radio...

Assign places in the rating (MySQL, PHP)

Hi guys! I have a MySQL database with the following columns: id company rating_score rating_place I have companies and rating scores for each company. So, my db looks like: id company rating_score rating_place 75 Intel 356.23 34 Sun 287.49 etc. How can I assign the p...

MySQL Transaction across many PHP Requests

I would like to create an interface for manipulating invoices in a transaction-like manner. The database consists of an invoices table, which holds billing information, and an invoice_lines table, which holds line items for the invoices. The website is a set of scripts which allow the addition, modification, and removal of invoices and...

MySQL querying with a dynamic range?

Given the table snippet: id | name | age I am trying to form a query that will return 10 people within a certain age range. However, if there are not enough people in that range, I want to extend the range until I can find 10 people. For instance, if I only find 5 people in a range of 30-40, I would find 5 others in a 25-45 range. I...

Measuring online time on website

Hello! I would like to measure how much time a user spends on my website. It's needed for a community site where you can say: "User X has been spending 1397 minutes here." After reading some documents about this, I know that there is no perfect way to achieve this. You can't measure the exact time. But I'm looking for an approach which...

Select From One Table And Include Sum Value From Another

My title is terrible but I'm having a hard time wrapping my head around this. I have two tables. Links and Votes. Links contain info about links submitted and the usual jazz, votes contains a foreign key link_id and a karma_up and karma_down value (both unsigned ints). Because I want to limit votes to one per user and record vote tim...

How can I get my content from a Joomla blog into Blogger or Wordpress?

I have an old joomla site (v 1.0.11) that I would really like to move over to Blogger or Wordpress. The commenting on the site uses AkoComment which was an add on module. Basically, I want to transfer: posts comments users css I haven't found a good tool out there to do this. What tools would be best to begin to work with this dat...

Mysql Error: #1247 - Reference 'karma' not supported (reference to group function)

Here is my mysql query below. Through many helpful questions and comments I am almost at the end of my journey. The idea behind this query is a user submits a link, the application inserts two rows, one into links and another into votes (a default vote, why wouldn't a user vote for their own submission?) Then every vote is just anothe...

How does mySQL handle dynamic value within ORDER BY

It stumbled upon me while I was reading the query in another post. Take the following query for example (ignore the non-practical use of the ordering): SELECT * FROM Members ORDER BY (TIMESTAMPDIFF(FRAC_SECOND, DateCreated , SYSDATE())) Say "Members" table has a huge row count (or the query is complex enough for it to be executed o...

Tutorial for converting PHP applications to Cocoa?

I do a lot of coding in PHP and MySQL, but I'm looking at moving my applications to a desktop environment in order to allow users to access the data offline, and periodically receive updates from a central online database. For the time being, however, I'm looking for a decent tutorial on how to convert PHP applications to Cocoa, and how...

Efficiently inserting / updating 1000's records with mysql transaction help?

I have to insert and then keep updating 1000's of records every minute, will mysql transaction help in the speed performance as it does in sqlite3. I carried out a test (Inserting 1300 records) but showed the same result with InnoDB (for transaction) and MyISAM. Using MySQLdb for Python ...

Why do I get "Resource id #4" when I apply print_r() to an array in PHP?

Below is the code: $result=mysql_query("select * from choices where a_id='$taskid'")or die(mysql_error()); print_r($result); I get "Resource id #4", any idea? After I added while($row=mysql_fetch_assoc($result)) { print_r($row); } I just got [] What's wrong? ...