Export MYSQL Selected Rows
Any ideas on how to export selected rows from a mysql table into a schema.sql file?
I want to use mysqldump --opt database table but I don't wanna dump the whole table only results of a select.
PHPMyAdmin does it but I need to do it in shell script code.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
How Do I Delete Selected Rows From MySQL Table?
I am trying to figure out how to delete selected rows from a MySQL database table. The web site that I am working on has a page that will extract rows, using the "SELECT * FROM .. etc." statement from a database and output them in a table - like the one below (bottom part). I've got that part figured out. What I am trying to figure out is if the user puts a checkmark in one of the checkboxes (below) how would I write the PHP code to delete one or two of the rows from the MySQL table? PHP Code:
Option Selected Multiple Rows Logic
I am having problem getting the logic to work to get a multiple option box to get populated from the database and select the ones which are already in the database. Here is my code: PHP Code:
Export Whole MySql Database
I am looking for the straightest way to export a whole MySql database, but all I can find is SQL statements to export specific tables....
Export Access To Mysql
I have the code to display the tables in Access now I need to take the data from access and replace the data in mysql The Access DB is the master and controled via are Doc Mang software blah blah The day-to-day users and testing Equi.... us the mysql DB. I have all the code to trigger the script for update once the DB is changed now just working on the mysql update side. I was thinking of placing the data from Access (at the same time it is being displayed) into an array then take that array and dump it into mysql Code:
Export Mysql To Text File Via PHP
I need help on how to export one of table mysql to text file to download. (not saving text into server) something with like header("Content-type: text/plain");
Import/export Problem With CSV/PHP/MySQL
I need to design an import/export system. Data comes from a filemaker pro DB in a big CSV file. Some alterations are made on the data as it is imported into my mysql table. Data is something like :id,text1html, text1raw,... . Problems : 1. Texts can contain html tags, including entities (" etc), so using only the '' as separator does not work. 2. Some line are so long that is appears php breaks them down, so I lose data reading the file. For 1, I've come across fgetcsv() in recent posts. Works fine for now. For 2, I can't seem to find a solution. I've tried to detect "broken" lines and stick them back together but no effect... Another problem arises when I try to export the data back into CSV, as it is suposed to be used in Excel. The CR/LF that are in the text are logically interpreted as new rows in Excel. How can I get around this ? Is there a special "new line" character that excel would not interpret as new row ? Should I try another file format ?
CSV File Export To MySQL Databse
I have not created a database within MySQL, neither do i have any knowledge of PHP. I would like to export data from a webpage into the MySQL database. The generate sublist at the end of the page displays the data. I would like the generated data to be extracted and written into the MySQL database. I would like this process to be automated. Meaning if data from where i am exporting changes, then the changes can be reflected into the MySQL database where i am exporting. Any hints or tips where i can start from? I am in the process of learning MySQL first, then PHP.
Export Tables From Mysql -> Ms Access
i've got a mysql database with a research data. i would like to get some information from that database and save it as ms access database. it will be a client feature. the client clicks a button -and downloads ms access database with a certain information from the master mysql database. is it possible in php? how?
Export Php Code With Mysql Phpmyadmin! How?
I have a mysql db that I use with phpmyadmin I want to export my entire database, but in php code because I am transferring this data to another db which does not have access to phpmyadmin, so i need to do it via php code I can choose to dump the db with phpmyadmin with "none" selected and it shows me the sql but with a bunch of crap that will error the mysql_query() function for example: Code:
Export MySQL To Certain Excel Cells
I have .xls files that I want to be able to export MySQL data into. Is there a straightforward way to do this...I'll really only be inputing 2-3 values. So pretend I have: $test1 $test2 $test3 And I want to export them into test.xls in cells A1, A2, A3. Can someone provide the method for doing this?
Generating MySQL Structure Export Data
I'm lookup for a PHP mechanism to export the structure data of a MySQL database. The utility phpMyAdmin does this, via the export function. I studied the code, but failed to extract the relevant code. I'm lookup for both structure-only as well as structure+content dumps. I'm using it to backup my website via webinterface (remote backup downloading). Would any of you guys have any links to examples on how to proceed? I could of course compress the raw MySQL files from /var/db/mysql in a TARfile, but i'd rather do it through the MySQL database.
Local Access Database To Shared PHP/MySql Hosting Export
My client has an MS Access database application on her local machine. I have full access to that in terms of changing the design. I've got a simple PHP/MySql application on shared hosting, so no direct access to the db server. I'd like to give her the facility to export the information in her local Access application to the shared PHP/MySql site. From one command button (or similar) in the Access application. It would be probably be a complete overwrite. That is to say all the information on the shared site would be overwritten with that from the local machine. I'm assuming that I'd have to make an HTTP request to some PHP page which would then run the SQL to delete all the records, then append all the new ones. Is this the right approach? I don't want to spend weeks finding out that this is fundamentally flawed in some way. The client has an ADSL connection.
PHP/MySQL: Query Based On Selected Form Option
Using PHP and MySQL. Trying to put a list of categories into a drop down select option of a form like: <form name="form" action="<? print $_SERVER['PHP_SELF']?>" method="get"> <select name="subject"> <option value=""></option> <option value="field1">Field 1</option> <option value="field2">Field 2</option> </select> <input type="submit" name="Submit" /> </form> Then I want to process it so the MySQL query gets done depending on what was selected. I came up with this: //connect to database mysql_connect("$dbhost","$dbuser","$dbpass"); mysql_select_db("$dbase") or die("Unable to select database"); // Build SQL Query if (isset($_GET['subject'])) { switch($_GET['subject']) { case 'field1': $query = "select * from tips where category = 'field1'"; break; case 'field2': $query = "select * from tips where text like 'field2' "; break; default: echo 'No subject found' } } $results=mysql_query($query); $numrows=mysql_num_rows($results); etc etc etc But that switch doesn't seem to work. Anyone have a suggestion as to how I can code this to do the MySQL query based on the subject?
PHP/mySQL Counting Rows In My Db
I'm building a little news board and I need to count the total number of rows in my db ... simple, I know... but I can't get a result. here is the code...
Deleting Rows In Mysql
Is there a way in php that I can mark a row in my mysql database and then later so delete these rows that have been marked?
Warning: Mysql Num Rows():
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/domain/public_html/signup.php on line 159 source code:
Deleting Mysql Rows
Is there an easy or another way to delete rows? Right now I'm checkmarking the row I want to delete and then clicking on the red x for each one. It takes absolutely forever. Is there a better way?
Get Rows In Mysql At Command Prompt
This question really belongs more in a mySQL group, but my NNTP server doesn't have a mySQL group available. I'm trying to get number of rows in a table without doing a "select * from table" or even a "select id from table". I know in PHP you put: mysql_numrows() but what's the equivelant in command prompt? I searched mysql.net and can't find anything.
Sessions And Updating MySQL Rows?
I've began constructing my dynamic website with PHP and MySQL, and I've created my user table. In that table is a column called 'keystones' and it's almost how many 'credits' a user has accumulated through the visit. (Every time a user discovers a secret or finds 'keys' to open doors, they are awarded keystones.) Now I have stored all the users in a table, and I'm using sessions for login method. However, I have a problem. Since I'm using sessions, when the user logs in, it defines the session variables. Those STAY constant every time a user logs in, so if a user accumulates keystones, and it's updated in the database, the SESSION variables won't reflect the change. Since it would be a pain to tell the users to log out/login again to see the change in keystones, how would I go about making that session variable dynamic across pages? Should I 'redefine' that variable every time a user goes to another page? Would that include making a SQL query such as this: Code: SELECT keystones FROM users WHERE user_id='$_SESSION['user_id']'' at the beginning of every page?
MySql Select Unique Rows?
I am have a table which contains recent search querys of another table. I am tryng to output this data into a list so the user can click, and re-run a recent search... The problem is that the table is full of duplicate searches from the same user. How do I select the searches without retrieving duplicates? SELECT id, term FROM project_term WHERE pid='$_SESSION[project_id]' Also, would it make more sense to store all serches of a paricular user, or stop the insert if the record exists? Is there a way I can do this without performing 2 queries (ie adding some sort of LIMIT or other xeyword to the INSERT query?) I can't make the column unique because two users could perform the same search...
Updating Multiple Rows (MySQL)
I have a piece of code which works perfectly when I want to insert multiple rows in a MySQL table. I am storing links in one table, categories for these links in another table and a link_category table (Id, LinkId, CategoryId) to attach one or more categories to the links. The $AddCatId (array) comes from a form where the user can select one or more categories for a link. PHP Code:
Duplicating MySQL Table Rows
I'm not sure whether this should be posted here on in databases, but it's a question about inserting records in a MySQL table using PHP. I have a large table with some 50+ fields with an auto-increment primary key field. When a record is edited by a user, we need to duplicate the original record, and update the fields changed by the user. My question is, what is the easiest way to capture and duplicate the original table row? Yes, I could read the record in and then loop through the $row[] array using this as the source of all fields (except the primary key), but it strikes me that there must be a simpler method.
Summing Individual Rows In Mysql
I have created a php score sheet that allows graders to enter scores for different criteria. It uses a mysql database to store the information. I want each row to total, and cannot figure out how to do that. Since new people and new scores will be added to the list, the total row needs to total new people as well. I'm pretty new to this, so don't assume I know syntax, etc. Can anyone tell me how to do this? Name Spelling Math Science Total Joe 15 11 45 Mary 11 22 41 Sam 7 3 11
Random Extraction Of Rows From Mysql Db
I want to pull out data from a mysql database in a random order. I want multiple rows pulled out and I want next and prev buttons. I have it all working (the next and prev part) but when I add the ORDER BY RAND ( ) part I get the error "Warning: Supplied argument is not a valid MySQL result resource" Can anyone help me? Can you get random results this way if you also want to use limit to put a certain number of results to a page? Here is my code:
MySQL: Number Of Rows Question
what I want to do is find out the number of rows in a table. The most obvious solution is to do something like the following: $sql = "SELECT blah FROM blah WHERE 1"; $result = mysql_query($sql, $db); $num = mysql_num_rows($result); If you have a large table, to me that seems like it would be a system hog if all you want is the number of rows but not the data. I'm not sure if using mysql_unbuffered_query() would solve this, would it? Basically my question is this: what is the fastest, most effecient way to just find out the number of rows in a table?
How Do I Extract 10 Rows At A Time? Mysql
How do I extract 10 rows at a time from a mysql database? What code could I use to do ten rows at a time? Say I am trying to get 10 rows and get the lastname field from each. The code below works for one at a time. PHP Code:
PHP Commands Vs. Extra MySQL Rows
What's better, storing extra information on something in a mySQL database, or using code to go through the database to find the information? For example, for the forum I am writing, I'm not sure whether I should store the last post of the user in thier row, or I should use the code to search through all the posts and find the last one by the user. Which do you think is better and why?
Navigation Through Mysql Table Rows.
I am running a query on a master detail page which results in a number of records. I call this page the master detail page. The master detail page has a number of records listed as thumbnails. Each thumbnail has a link identifier which is linked to a detail page. On the detail page I have no problem querying the specific recordset through $HTTP_GET_VARS['id'] and the additional info below. PHP Code:
Mysql And Php5 Deleting Rows
I can't seem to delete rows from a mysql database. I have a database that I want to delete rows from based on user name. i have researched this extensively and can't seem to find anything that works.
Counting The Contents Of Multiple MySQL Rows
Ok, I'm working on a poll for my site, which uses a mysql db.. I need my script to count the number of votes total, so I can take a percentage out of the total number of votes.. The table has the following rows. vote_id | vote_option_id | vote_option_text | vote_result I need to add up all the numbers under the "vote_result" columns.. but I hardely even know where to begin.
Deleteing MySQL Rows Older Than 1 Hour
Hi, as the title says, I have a mysql table which logs data, I have a timestamp field which collects what time the record was added, I really need to know howto setup a WHERE clause which will tell mysql to delete rows that are older than one hour, can anyone help?
Displaying An Array From Rows Retrieved From Mysql
I have a web site where users can add pages to it. When they make a new web page the url of the page and username of the user who created it is stored in Mysql. When the user logs back in the users previously made pages are displayed as links or atleast should be. Below is the code that I am using. PHP Code:
Add Select Mysql Output Rows To Session
I'm using php and mysql to search records and print the results to the screen. Output looks like this example (with more columns of course) but is typically spread over 2-3 pages with 200 results. The [] represent checkboxes with the id value for each record: [] Hat [] Car [] Sweater [] Boat I just want to be able to let the user select which boxes/records they want to print and put these in an array. When they're ready, I'd like them to be able to view all the records from the array on a page. So, if they've checked records 1,5,8, and 12, I would query the database for these id's and output to the page. Sounds simple, but I can't seem to figure the multiple select and store via sessions out.
Insert Data From Mysql Rows Into An Array
I am working on a project where I need to select rows from a table called 'hub' and take the rows where 'to_id' = '$to_id' and put them into an array. How can I get MySql info into an array?
Updating Multiple Rows In A Table In Mysql
ok so im making this form that updates multiple rows in the mysql database but the thing is that the number of rows is a variable so once it may be one row once it may be 31 rows. is there anyway i can do this using a while loop? or even is there a way to do this period?
Multiple Selected="selected" In A List.
I have a database with 1 to many and the many is a list with multiple selects in a list. When I click on a master record I have as part of my form the select statement for the multiple choice list. I want the list to highlight the multiple chosen values. here is part of the code. $dresscat = specdresscat($dresstypeid); //this is the query to get the values in the detail table $drcatrow = pg_fetch_array($dresscat);// the array for the detail table. <select name="stages[]" multiple="multiple"> <?php $allstages = allstages(); // this is a function to query my database to get the value for the list. while ($allstagerows=pg_fetch_array($allstages)) { $eachstage= $allstagerows["stageid"]; $specstage= $drcatrow["stageid"]; // this is the point I need help if ($specstage == $eachstage){ ?> <option value=<?php echo $eachstage;?> selected="selected"><?php echo allstagerows["stage"]?></option> <?php }else{ ?> <option value=<?php echo $eachstage;?>><?php echo $allstagerows["stage"]?></option> <?php } } ?> </select>
PHP / MySQL -- Moving Rows Between Tables And Dealing With The Primary Key
Let me start by saying that I'm still very new at PHP/MySql and will take any advice. :-) The issues is that every once in a while users get an error when they use this code. I believe the issue is that I'm copying the primary key as well as the other data in the row. So, my thoughts on fixing this are to just select everything but the 'pkey' column, but I'm not sure what would result from that. Would MySql use the next auto incremented primary key for the 'pkey' column when the data is moved into the table, or would it just leave it blank? Also, is their a better strategy for moving data from one table to another than the one I have taken? ///////////////my variables////////////// $newtablename == name of the target table $tablename == name of the current table $pkey == the table's primary key (big int, auto incrementing) //////////////The Code//////////////////// mysql_connect(DB_HOST, DB_USER, DB_PASS) or die(mysql_error()); mysql_select_db(DB_NAME) or die(mysql_error()); /////////////My move Queries////////////// $sql1 = "insert into $newtablename select * from $tablename where pkey = $pkey"; $sql2 = "DELETE FROM $tablename WHERE pkey = $pkey"; $result1 = mysql_query($sql1) or die(mysql_error()); $result2 = mysql_query($sql2) or die(mysql_error());
Using Php To Move Rows From Text File Into Mysql Table
Can anyone point me in the right direction for the way to read a text file a line at a time and separate the fields on that line and use them as data in an INSERT to add a record to a mysql table. Then read the second line in text file and repeat.
Divide Mysql Results Into Rows In An Html Table
I need to divide my mySQL results into rows with 4 results on each row. Its for a small image gallery script, I wanna show 4 thumbnails per row. I have all the code ready to get the info and show it, I just need an example of how I can take the data from the table and have it automatically go to a new row every 4 entries.
Insert Multi Rows With A Single Mysql Function Call?
For this table --------------------------------------- | id | foo | bar | -------------------------------------- I understand that we can insert a row to the table per call, like this sql_query = "INSERT INTO `table` (`foo`, `bar`) VALUES ('$string_1', '$string_2')"; mysql_query($sql_query, $db_handle); if I want to insert multi rows(the following example inserts two rows) at the same time, the following example works, but can I merge this two insertion into a single mysql operation (to achieve efficiency)? sql_query = "INSERT INTO `table` (`foo`, `bar`) VALUES ('$string_1', '$string_2')"; mysql_query($sql_query, $db_handle); sql_query = "INSERT INTO `table` (`foo`, `bar`) VALUES ('$string_1', '$string_2')"; mysql_query($sql_query, $db_handle);
Export To CSV
There are some text fields that I am exporting to CSV contain comma in it. And so when I open the csv file, everything is shifted. e.g. "Apple, Banana, Orange", "Excellent", "12345" gives me 5 columns instead of 3 in the csv: Apple Banana Orange Excellent 12345 How can I solve this problem?
PHP Export > Csv
I have got a page on a site that I'm working on. As you can see there are 3 drop down menu's which are dynamicaly driven by 3 tables within my database. On selection of the lists, you are taken to the same page (show if statement - dreamweaver) which shows you the record count. This is based on your criteria! At this point. I would like to export the query results into a .csv file. Now I have looked across the forums and found a few things and tried to implement them into my site, all of which are bringing up an empty page. Possibly because my search queries are dynamic?
Export Sql Code
Can I use a php script to move a database from a db on my local machine to a db on a server.. How exactly would it be structured, and what commands would I have to use? I'm also looking into using mysql to export the code and content from the db on my computer and then import it using phpMyAdmin on the server, but I still havent found out how to do that after searching these forums and reading through the mysql manual.
Import And Export
Anyone could give me some tips about coding an import and export php script with mysql ?
|