mysql

What are the possible ways to handle an expandable form using PHP?

I have a database that has two tables, one of which contains a foreign key back to the first. Similar to this: Table1 id description some other information Table2 table1ID Some other information For each table1 there can be any number of entries in table2. I need to create a form that allows user...

Decrement in mysql goes past zero

I am trying to do this in mysql: UPDATE table SET value = value - 1 WHERE blah blah If value is 0 and this is run value is set to 4294967295. This is because it is an unsigned integer so it is looping round back to the maximum value. How would I go about making it stay on zero instead? Can I do this purely in the sql? ...

how to do this with pure mysql?

If mysql record with condition exists-update it,else create new record ...

Is there a way to insert custom data while loading data from a file in MySQL?

I am using the following statement to load data from a file into a table: LOAD DATA LOCAL INFILE '/home/100000462733296__Stats" INTO TABLE datapoints FIELDS TERMINATED BY '|' LINES TERMINATED BY '\n' (uid1, uid2, status); Now, if I want to enter a custom value into uid1, say 328383 without actually asking it to read it from a file...

nHibernate/MySql: Parameter Index out of bounds exception

This strikes me as an odd problem. I have two classes representing tables in my database. The first simply has an int ID field and a varchar NAME field; it's *.hbm.xml mapping file contains the following (everything works as expected with this model): <class name="CBaseDataProvider.Models.PC, CBaseDataProvider" table="pc"> <id ...

Insert multiple rows into mysql with php using foreach arrays

Im stuck, been trying to figure this out for 2 hours now. I have figured out the foreach loop, but cant figure out how to insert the data now. here is my php, what am I doing wrong? $query = "INSERT INTO images (thumb_path, image_path, main_image, project_id) VALUES "; foreach($_POST as $key => $value) { $query .= "$thumb_pat...

Doctrine quoting apostrophes

I am using Doctrine ORM for php and Zend MVC. I have a mysql database. When I insert into the database it is escaping quotes. In other-words when I enter <input name="customer_name" value="Test'ed user"> ... into my form, and assign to a doctrine object and save. When I look at the database through the mysql command line I get Tes...

Serialized data in mysql database needs to combined in an array

I am working in PHP/MySQL. I have a table in my database called hourly in that table their is a column named webaddress these are serialized. There are multiple rows of each column of webaddresses each is serialized. I need to pull each row, unserailize them then put them into an array. I tried using this bit of code but it only gr...

Glassfish hangs when serving multiple blob-images from an imageservlet

In my JSP/HTML files i use the following servlet to get blob-images from the MySQL-database. <img src="/image?id=1" /> Image servlet This is mapped to a imageservlet, who: - gets a stateless session-bean injected - uses the session-bean to lookup a product, based on the id passed in to the servlet - streams this image out as the resp...

Count(id) in MySQL into a string

Hello, I have the SQL query: $query = "SELECT yearoffiling, COUNT( id ) FROM files GROUP BY yearoffiling LIMIT 0 , 30"; How do I put the values from COUNT(id) inside a string? Thank you. ...

How do I Create a Comma-Separated List using a SQL Query?

I have 3 tables called: Applications (id, name) Resources (id, name) ApplicationsResources (id, app_id, resource_id) I want to show on a GUI a table of all resource names. In one cell in each row I would like to list out all of the applications (comma separated) of that resource. So the question is, what is the best way to do this ...

What does M,D mean in decimal(M,D) exactly?

Does anyone know about this? ...

SQLAlchemy not returning selected data

I'm using SQLAlchemy as the ORM within an application i've been building for some time. So far, it's been quite a painless ORM to implement and use, however, a recent feature I'm working on requires a persistent & distributed queue (list & worker) style implementation, which I've built in MySQL and Python. It's all worked quite well un...

How to get affected rows in previous MySQL operation?

mysql_affected_rows is to get number of affected rows in previous MySQL operation, but I want to get affected rows in previous MySQL operation. For example: update mytable set status=2 where column3="a_variable"; Before this operation, status of some rows is already 2, and I want to get affected rows in previous MySQL operation, you c...

Cumulative average number of records created for specific day of week or date range...

Yeah, so I'm filling out a requirements document for a new client project and they're asking for growth trends and performance expectations calculated from existing data within our database. The best source of data for something like this would be our logs table as we pretty much log every single transaction that occurs within our appli...

maximum enum usage in schema

i need to populate a table column which takes one of 30 different string values. Is it advisable to use enum here for speed up processing . Can anyone suggest better solution which is reasonably optimum for storage and processing(comparison)? ...

Need little help with Mysql paging (LIMIT)...

I have this code: $page = $_GET['page']; $res_per_page = $_GET['res_per_page']; $start_point = (($page * $res_per_page) - $res_per_page); $query.= " LIMIT $start_point, $res_per_page"; $qry_result = mysql_query($query) or die(mysql_error()); $total_pages = ceil($nr_ads / $res_per_page); The variable '$nr_ads' ...

How to store a list of users, and let the users know they are on that list

Im building a site where a user can add people to their "list". This list belongs to the user, but im wondering whats the best way to store/retrieve/loop through this list in a function, to show the people who are on the list, that they are there and who created it. So once the list of usernames is created, i would assume store it in a ...

how can I get data in the table cell that is checked after submit

can someone give me help, please. here's my basic html <form action="addSomething.php" method="POST"> <table> <tr> <th>Add Data</th> <th>Description</th> <th>Quantity</th> </tr> <tr> <td><input type="checkbox" name="data[]" value="sample1" /> </td> <td class="desc">Newbie</td> <td>2</td> </tr> <tr> <td><input type...

Learning PHP and MySQL

Hi, I would appreciate if people can point me towards some good websites where I can learn PHP and MySQL for a complete newbie in these areas. I have the HTML, CSS and Javascript background but would like to venture out to PHP and MySQL. Any help would be appreciated. Thanks. ...