Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Insert All Records From .xls File To Mysql Using Php.


I need to insert all records from .xls file to mysql using php. How could i read all records from php ? (the thing is no need to convert xls file to csv file).




View Complete Forum Thread with Replies

Related Forum Messages:
Insert Records To MySQL
When I use the script below it doesn't insert the record into MYSQL database. I have checked the fields in the form and they are showing fine and the database is connecting without a problem. Does anyone see anything wrong with my script?

$sql = mysql_query("INSERT INTO customers ('client name', 'bill to address', 'shipping address', 'phone', 'contact name') VALUES ('$clientname', '$billtoaddress', '$shippingaddress', '$phone', '$contactname')");

View Replies !
PHP MySQL CSV File Insert
I'm working on a piece of code to upload a CSV file and then import it into MySQL. The upload is working great.

I've used PHPMyAdmin to insert the same CSV file before and it works beautifully. So I figured I would take their PHP generated code (PHPMyAdmin) and use it for my PHP version of the insert, but I'm running into trouble. Code:

View Replies !
PHP / MySQL Insert And File Upload
I am trying to make a script that will upload a file then insert some data into a table in my MySQL database. Can anyone see anything wrong with this code:

View Replies !
Insert Records
When I try to insert a records in the database "socios", it doesn't inserted at all. Code:

View Replies !
Listing Records As Well As Insert
I'm getting all the data from a row of a table into a list box. On selecting a record in the list box, the corresponding records has to be displayed in the second list box.

And now, i have 2 text boxes where the user can enter some text and then can insert into the table. In brief, i have 3 tables:thema, unterthema, artikel:

Thema(Thema_id, Thema_name)
Unterthema(Unterthema_id, thema_id, unterthema_name)
Artikel(artikel_id, unterthema_id, artikel_name, artikel_content)

So, at first, i'm displaying the records from thema_name in a list box. Now, when the user selects the record, the second list box has to be filled with unterthema_name. Now, the user can enter some text and it will be inserted into the fields(artikel_name and artikel_content).

View Replies !
Insert Multiple Records
am trying to create a 'related articles' selection page. The administrator, after creating an article, can select older articles to include on the final displayed page. As the number of older articles increases, so will the number of possible relataed articles, so i am making a dynamic checkbox as the selection. This is all covered in Dreamweavers features, but, what i then need to be able to do is create a new record in the 'related_articles' table for each article selected when the form is submitted.

I found this post below, which is more or less exactly what i want to do, i just wasn't sure that this was php code, looks like asp. Would someone be kind enough to show me how to change it to php code, or even write the code for me?

View Replies !
Insert Records With 1 Submit
I have a form that lists all the counties in the UK. This information is in a record taken from a table. This is then listed using a repeated region to show all of these.

I need to select all or some of these and insert into separate records in mysql database. I am using dreamweaver to create my web pages and I have very limited knowledge on PHP. I think I need to create a loop but I have no idea how to do this.

View Replies !
Records For Update Or Insert
I am trying to add a signup for an e-Newsletter and I want to check to see if they already signed up to prevent duplicates. I found this link talking about it and I am using bpat1434's technique and it tells me the record was updated, when it wasn't even inserted into the database yet? I used a unique email address to test the insert and it passes PHP Code:

if(!$result)

and continues to the update.

View Replies !
Duplicate Records On Insert
How can I insert items into a database and when there is a duplicate phonenumber field update the record and continue.

View Replies !
Multiple Row Insert - Variable Records
I am wanting to insert into a table multiple rows automatically. I relaise that you can use "VALUES ("string1", "string2"), ("string3", "string4")" to insert multiple rows, but I cannot specify the values I want to insert, and similarly the number of records to insert. Code:

View Replies !
Insert Multiple Records In Table
I want to use a form to insert multiple records into a table. I have an book club where a person would rank a book (3 to 1) next to a particular book read for a particular month. 3 being the most favorite book read that month and 1 being least favorite. Below is the table the records would be inserted into.

Key----Month--------Reader---------Rank-------Book
1-------January-------Jim--------------3----------Bible
2-------January---------Jim-------------2----------Koran
3-------January---------Jim-------------1-----------Torah

How can I have a form where the reader sees only (and fills in) the rank and book text fields, and the Key, Month, and Reader fields are filled in behind the scenes with the default info when the form is submitted .

View Replies !
Insert Records Into A Database At The Same Time?
What happens when 2 or more users query or insert records into a database at the same time? Does the website crash andis there a way to overcome it? Also, sometimes, when a user inserts a record it gets duplicated in the database 2 or 3 times. why is this?

View Replies !
FORM-add Submit Button For Insert Records To Database-HOW TO DO THIS?
First file post.php take record and send it to post2.php. Now records are insert into databse without submit button press and that is my problem.

I need working submit button. When user click on submit button=insert data to database. Sorry for my english. Code:

View Replies !
Insert A Page Break For Printing Purposes After X Records On Page.
I need to insert a page break for printing purposes after X records on page. I'm querying five diffrent records with 5 different results and displaying them like:

$record1
$record2
$record3 and so on

So I want to get total number of records which is pretty easy I just add all the totals let's call it $subtotal. Then I want a page break after every 20 records of the $subtotal. Is this possible?

View Replies !
PHP/MySQL Records Per Row
Is there any way to have the records pulled from a mysql database display like this in a table:

record1 | record2
record3 | record4

etc: I've been thinking about this for about three months and have yet to come to a good solution.

View Replies !
Writing Records To File Instead Of A DB
Is there a way to write records and keep them organized to a file instead of a DB?

View Replies !
How Do You Delete Records From Mysql
Could someone please show me how to delete records from mysql. Maybe even an example in a loop that deletes records based on a criteria.

View Replies !
How Many Records Can MYSQL 4.1.14 NT Via TCP/IP Can Hold?
how many records can MYSQL 4.1.14 NT via TCP/IP can hold?

how many records per table can MYSQL 4.1.14 NT via TCP/IP can hold?

how many records in a table can MYSQL 4.1.14 NT via TCP/IP can hold given the table has a field Primary key - BIGINT(20) autoincrement?

need your opinion..Here are the facts:

MY system is an internal one. My Server--Is only a Desktop.. Celeron 2.8 Gigahertz, 40Gig Baracuda HD, 512 MB memory.. And it serves an average of 20 users a day and it also serves me for my system development..The average records inserted per month on mYSQL is 10,000 records..We foresee that system would be used for about 10 years.

View Replies !
Counting Records In MySQL
I've been trying to write a page that checks the database and counts the number of records and if the number is less than 3000, it loads page X, but if the number is equal to 3000, it loads page Y.

I know this should be a simple if/else statement but it's the checking and counting that I cannot get to work. 

View Replies !
Paginating Mysql Records With PHP
I have data more than 10000 in a database.When I retrieve data under some conditions that will come more than 100 records.I need a help to chunk that in to pagewise when retrieve.

View Replies !
Display Records In Php/mysql
i have the mysql database with the name "wwwgosc_ton" and table with 17 field by the name "general". i want to dispaly all the records with 3 to 4 fileds and link each row to detail of the full field of that perticular records. Code:

View Replies !
Ordering Records Php/mysql
I'm trying to change the order records, via links on a php page. my code:

$numID = $_REQUEST['id'];
$numPos = ($_REQUEST['Pos']);
if($numPos > 1){
mysql_query("UPDATE FamilyPhotoAlbum SET DisplayOrder = DisplayOrder - 1 WHERE Id = " . $numID);

$numCounter = $numPos;..

I think my logic is a little off here. I can't seem to get the records to order correctly with out it skipping numbers.

View Replies !
Pagination Of MySQL Records
Data is being passed to page and being displayed in a dynamic table (Adjusts based upon the number of records to display.).

Table row colors alternate; gray - white - gray. In addition, the <thead> is set up to allow for ordering of records. Now I want to add pagination; limiting the number of displayed rows to 20. Code:

View Replies !
Displaying Mysql Records:
I wondered if anyone could offer some guidance, I trying to write a php script to connect to a database, and display the records in a table. I found the code here in a php4 text, and when I run this directly through the php intrupeter, the line Successfully connected is display and 4 as the number of rows. The database table we connect to, has three field username, firstname, surname.

When I tried a while loop, to display the data in a table. No values were displayed. Could anyone possibly demonstrate how to display the username, firstname, surname values in a basic table?

<?php
function db_connect(){
global $MYSQL_ERRNO, $MYSQL_ERROR;

$link_id = mysql_connect("localhost","user04", "password04");

if(!$link_id){
$MYSQL_ERROR = "Connection failed";
..................

View Replies !
Replacing Records In Mysql
I have a web form for updating projects that feeds a bunch of mysql tables. The problem is that some of the fields on the form may generate more than one entry. So for example, I may have a project that is working into 5 countries. Code:

View Replies !
Updating Mysql Records
I have programmed the code to display the information of a particular person in the form so that he/she can change his/her details in the form and hence update his/her records.I have tried with the following code.It displays the form with the previous data.

But when I submit,it blanks the fields (excepting the name,surname and dob which I have blocked from making any correction).The remaining 7 fields become blank with the last field's (ExamsPending) value to be zero. Code:

View Replies !
MySQL Consecutive Records
I have a table with columns like this: ob (datetime) temperature (float). There should be one record for each hour in a day (ob). I need to query this table and return a count of the number of consecutive records preceeding each hour within an 8 hour timeframe where the temperature > 70 degrees. I know how to get the number of records spread out during a timeframe, but I'm having trouble finding consecutive records.

View Replies !
Multiple Mysql Records
I am trying to develop a form which has the user inputing data in a columnar format. Each column has multiple fields (one for each row) there are 12 columns, I was able to submit to MySql database the first column fields. All subsequent columns would be the same field inputs but the values could be different. I need each column to be submitted to the database as a seperate record by using only one form submit.

View Replies !
Writing Records To Text File
I have the following code which displays some some formatted text in my
browser. The problem is I need to create a text file and write the records
from this array into it. Does anyone know how to acheive this...

View Replies !
Displaying Records From Text File
I have the following Code which reads in information from a text file: PHP Code:

View Replies !
Duplicate Records In DB When Importing From CSV File
The code below is used to grab each row from a CSV file (except the
first row) and insert it into a database, as long as it's not already
in the DB.

If I echo each row's data, it appears only once on the page. But, for
some reason it inserts each row into the database 3 times. The code
that echos the data, and the DB insertion code all appear within the
same for loop.

The database insertion code (below) works perfectly in another script.
It's just copied/pasted into the for loop.

$row = 0;
$handle = fopen ("some-file.csv","r");
while ($data = fgetcsv ($handle, 1000, ",")) {
if($row == 0){
// set the varible array
$num = count ($data);
$csvNames = array();
for ($c=0; $c < $num; $c++) {
$csvNames[$c] = $data[$c];
eval("$" . $data[$c] . " = array();");
}
$row = 1;
}else{
$num = count ($data);
$row++;
for ($c=0; $c < $num; $c++) {
$buildEval = "$" . $csvNames[$c] . " = "" . $data[$c] .
"";";
eval($buildEval);
echo $buildEval . "<br>"; // this properly displays only one
row's data from the CSV file, then displays the next row in the CSV
file when it loops again.

// BUT FOR SOME REASON, THE DB CODE BELOW INSERTS EACH ROW FROM THE
CSV FILE 3 TIMES.

// Set variables with current date and time to be inserted into DB
later
$appDate = date('Y-m-d');
$appTime = date('H:i:s');

// Prepare the phone numbers for easy input into the database further
down this page.
$fHomePhoneCombined = $fHomePhone1 . "-" . $fHomePhone2 . "-" .
$fHomePhone3;
$fBusinessPhoneCombined = $fBusinessPhone1 . "-" . $fBusinessPhone2 .
"-" . $fBusinessPhone3;

// Connect to the database
$db = mysql_connect ("localhost", "username", "password");
mysql_select_db ("mydatabase");

// Check to see if the record is new,
$newRecord = 1;
$queryNewRecord = mysql_query("SELECT * FROM cust_test WHERE
first_name = '$fFirstName' AND last_name = '$fLastName' AND email =
'$fEmail'");
if (mysql_num_rows($queryNewRecord) > 0){
$newRecord = 0;
}

// If it's NOT a new record, insert the contents into cust_test_bad DB
// I'll insert this code later. It's not important for this test.

// Write the information to the customers table, if it's a new record.

if ($newRecord == 1){
$query = "INSERT INTO cust_test SET
application_date = '$appDate',
application_time = '$appTime',
first_name = '$fFirstName',
last_name = '$fLastName',
email = '$fEmail',
address = '$fAddress',
state = '$fState',
zip = '$fZip',
home_phone = '$fHomePhoneCombined',
best_time_to_call = '$fBestTime',
lead_buyer = '$lbuy'";


$result = mysql_query($query) or die('Failed because:
'.mysql_error());
}

} // end of for ($c=0; $c < $num; $c++)
}
}
fclose ($handle);

View Replies !
Converting Records Into Excel File
I have preview page that shows simple details of properties. you can see address, price etc.. There is a sort option on this page where you for example select records 1,3,12,10 and click a button and all of records that are not selected disappear. If you click details link in depth details are listed.

I need to find a way to convert these records from the PHP DB to an excel file.

I found a script that will convert the entire table to a excel file but I need to find a method that will only convert certain records (the ones that are selected)

here is that code, I figure it might be a good place to start: ...

View Replies !
Text File Records Overwriting Each Other
I'm doing a special web stats page for my website and I need to work out the users resolution and store it to a text file via php.

The actionscript works, it stores the record to the text file but doesnt create any more records. It just keeps overwriting the same record! I need the php, I believe to make a line after creating a record. Any pointers? Code:

View Replies !
Does PHP Have A Way To Export Records Of A MySQL Database?
Quite by accident, I found the mysqldump utility, that comes with MySQL,
which dumps/backsup a database, table, or record. It looks very versatile!

Does PHP have a way to export records of a MySQL database? Anything that
does the same independent of the database used?

View Replies !
How Do Iterate Through MySQL Records And Displat Them?
Basically I have a page where a person can choose from a list of stories posted by people, or they can choose to submit their own. I've managed to do the page where they can submit their on. The way i did this was to set up a mySQL database, and table in the database called stories. I then made an id (primary key), author, title, body and date field in the table. When the user submits their story its given an id (which increments on each submition) and their author, title and body fileds are sent to the database. The date key is automatically stamped in.

Ive also managed to have the submition page display what they submitted by using the count(*) function, their story would be the last to be submited , so it pulls that from the database and displays it.

Now what I want to do - on the page where they can pick a story, is have the page connect to the database and grab each record and display the author and title on the page next to a radio button. And have the id for the story in a hidden field or variable so when the user to chooses a particlar story it uses the id to grab the story from the database.

So how do iterate through all the records in the database, and display each one?

View Replies !
Problems Updating Records In MySQL With PHP
Sorry to ask what is probably a simple answer, but I am having problems
updating a table/database from a PHP/

PHTML file. I can Read From the Table, I can Insert into Table/Database, But
not update. Here is a copy of the

script I am using. I do not know what version of MySQL my host is running
nor do I have Shell Access to it. I

would like to setup a script so my website users can update thier records
without my intervention.

Also you may send replies to stevennyoung@yahoo.com

Begin Script

<?php
$db = mysql_connect("localhost", "username", "password");
mysql_select_db("databasename",$db);

if ($id) {
if ($submit) {
$sql = "UPDATE tablename SET
EMail='$EMail',Username='$Username',Password='$Pas sword',Item=

'$Item',Price='$Price',URL='$URL' WHERE Username='$Username'";
$result = mysql_query($sql);
echo "table Updated.";
} else {
// query the DB
$sql = "SELECT * FROM tablename WHERE Username='$Username'";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
?>
<form method="post" action="<?php echo $PHP_SELF?>">
e-Mail Address:<input type="Text" name="EMail" value="<?php echo
$myrow["EMail"] ?>"><br>
Username:<input type="Text" name="Username" value="<?php echo
$myrow["Username"] ?>"><br>
Password:<input type="Text" name="Password" value="<?php echo
$myrow["Password"] ?>"><br>
Item:<input type="Text" name="Item" value="<?php echo $myrow["Item"]
?>"><br>
Price:<input type="Text" name="Price" value="<?php echo $myrow["Price"]
?>"><br>
Item URL:<input type="Text" name="URL" value="<?php echo $myrow["URL"]
?>"><br>
<input type="Submit" name="Update" value="Update table">
</form>
<?php
}
} else {
// display list of articles
$result = mysql_query("SELECT * FROM tablename",$db);
while ($myrow = mysql_fetch_array($result)) {
printf("<a href="%s?Username=%s">%s %s</a><br>
", $PHP_SELF,
$myrow["Username"], $myrow["Item"], $myrow

["URL"]);
}
}
// Close DB Connection
mysql_close()
?>

View Replies !
Grabbing Specific MySQL Records
I have set up a target page to pull information out of a mySQL database to populate the page. The problem is that it is only pulling from the first record and not the record specified. What do I have to do to pull from a specific record? I am using Dreamweaver MX to administer the site on WinXP using PHP if that information will help.

View Replies !
PHP Mysql Outputting Records Repeatedly.
I have not messed with php/mysql in a while and have come up with a
problem I have run up against before but cannot remember the solution.
See the following page:

View Replies !
How Many Records Will A MySql Database Hold?
how many records will a MySql database hold?

View Replies !
Sensible Method Of Inserting Records In To MySQL
I have users using a third party windows application. They can export data
from this application directly to a text file (CSV). So far as I know,
there is no way to make this application talk directly to the MySQL server.

We're talking thousands of records here - it's not practical to have an HTML
form handled by PHP which inserts the data to MySQL... or is it??

What I thought about doing was to have them export the data to the CSV file
& then upload it to the web server using FTP.

Once uploaded, I would have
them go to a page with a PHP script which would run the command to import
the data to MySQL. PHP can run shell commands, as I understand it from the
manual. Perhaps this would be a bitch on Windows, though. Code:

View Replies !
& MySQL - Updating & Deleting Records
I am very new to MySQL and have built myself a small database for website update requests. The thing is Instead of having a "enter the record id # and press edit" I want to have a small edit icon at the end of each record I am displaying in a table. I've got the table data box setup at the end of the record and this is what I put in it: Code:

View Replies !
Very Slow MySQL SELECT Query After 11 Records
I have a very weird problem

I moved my database to new IIS 6.0 + PHP 4.3 + MySQL 4.0 setup. I tried to check with myphpadmin if everything works fine, but I couldn't browse my table (125 records). I used SELECT option and found out that SELECT query up to 11 records is ok, but after that, even if I choose to limit query to 12 records, it just hangs.
I tried selecting from the beginning of the table and from the middle - same thing, but when I run query localy on mysql console, everything works fine

View Replies !
How Do I Prevent Mysql From Printing Redundant Records?
I have a very urgent question. I am using php and mysql.
Say I have a database full of names and email addresses. I want to do a query that when you type in the name or partial name, mysql will only show a name once, even if it is in the database 200 times. Then I want to click on that name and have mysql show the 200 email addresses associated with that name (which I know how to do). See below:

View Replies !
Set Session Variables From Records In A MySql Database
I am working on a memebship section for a website and I am trying to set session variables from records in a MySql database when the user logs in. I think I am missing something because try as I might the just don't work!

The sever I use had Glabal variables turned on, dont know if thats an issue in this case.

Heres the code on the check user page:

View Replies !
Inserting Master-detail Records In Mysql
how I can insert a master-detail record in mysql? I use an auto-increment key, but I don't know how I can find that key for inserting the detail records, I tried to make a 'highest-key' function with 'select MAX(field)...' but in php it gives the wrong key (in mysql it gives the right one).

View Replies !
Changing Data In Objectified Mysql Records
I am using this very slightly modified function found here:
http://us2.php.net/mysql_fetch_object
to make mySQL rows into objects of type $classname:

// This takes db result rows and makes real objects of $classname type
function &buildObj($result, $classname) {
while($row = mysql_fetch_assoc($result)) {
if ($row === null) return null;

/* Create the object */
$obj =& new $classname;

/* Explode the array and set the objects's instance data */
foreach($row as $key => $value)
{
$obj->{$key} = $value;
}
$objs[] = $obj;
}
return $objs;
}

This is called by a retrieve: function:

function retrieve($where) {
echo $query = "SELECT * FROM $this->table WHERE " . join(' AND ',
$where);
$result = mysql_query($query);
$rows =& buildObj($result, get_class($this));
mysql_free_result($result);
return $rows;
}

The problem I am encountering is that if I do this in my script:

$listing = new Listing;
$listings = $listing->retrieve(array('row > 1') );
foreach ($listing as $aListing) {
$aListing->address='xxxxxxxxxxxxx'
}
foreach ($listing as $aListing) {
print_r($aListing);
}

The value in $aListing->address is unchanged.

However if I do this:

$listing = new Listing;
$listings = $listing->retrieve(array('row > 1') );
foreach ($listing as $aListing) {
$aListing->address='xxxxxxxxxxxxx'
$newArray[] = $aListing;
}
foreach ($newArray as $aListing) {
print_r($aListing);
}

I see the update values in $aListing->address .

View Replies !
Break MySQL Records Into CSS Columns Automatically
I'm making a page of links, each assigned a category. There are two tables - "favourites_links" and "favourites_categories". This is how the links currently appear:

Category 1 Name
Link 1
Link 2
Link 3

Category 2 Name
Link 1
Link 2
Link 3

What I want to do is break my page into columns. Basically, set a number of columns (e.g. 3), count the total records, and work out how many records to show per column. Each column should be enclosed in a <div class="column"> wrapper, which floats to the left. Code:

View Replies !
Having Trouble Looping Through Records In A MySQL Table
I'm having some trouble looping through the records of a MySQL table using PEAR DB. Here is my code:

$navigationSql = "SELECT * FROM nav";
$navigation =& $db->query($navigationSql);
while ($navigation->fetchInto($nav)){
define("NAVIGATION", "<a href="$nav[2]" target="$nav[3]" title="$nav[1]">$nav[1]</a><br />"); }

The when I enter:
print NAVIGATION;

into any of my PHP scripts it should loop through the stuff in table named nav, but it is only displaying the first record and so far everything I've tried does not seem to make it loop through all of the records in the table and I can't figure out why not.

View Replies !
Inputting Multiple Records At Once To Mysql Via Text Box
I was wondering if anyone can point me in the right direction. I wanted to create a text box, as seen in some scripts, where you input various fields of information, separated by commas and the script inputs those fields into the db.

View Replies !
Select Multiple Dates' Records From MySQL DB
I need to select multiple records from a MySQL DB based on one date value that I get from a form.

When I get the date from the form I need to get the values for that date and for the six days before that to display the full week's data. Code:

View Replies !
MySQL Connection - Get Some Records And Print Them To The Browser
I have a script that works but it shouldn't, and I would like to know why. I originally wrote it with a statement to connect to the database, then there's a part to select the database, then I get some records and print them to the browser. It all works fine. A couple of months ago, I commented out the connection part (I can't remember why), and it still works. I had thought that there must be a connection statement.

View Replies !
Check For Errors Before Inserting Records In Mysql
I'm creating an auction script from scratch and I'm busy with the registration page. I was wondering if there is a better way to check that there are no errors when inserting the users profile into the database. ....

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved