27, May 2012

a script that can search a csv file - webmaster forum

 
Webdigity webmaster forums
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: a script that can search a csv file
« previous next »
Pages: [1] Print
Instabuck - The easy way to sell digital products online

Author Topic: a script that can search a csv file  (Read 1942 times)
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 886
1148 credits
Members referred : 4



« on: Dec 25, 2005, 07:30:30 am »

im having trouble writing a script that where u can fill in a search box to search a .csv file .. a customer can enter their customer number and based on that number they find their delivery time which has already been uploaded to the database.. any ideas?


Last blog : phpHaze 1.59.1 in Development
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #1 on: Dec 25, 2005, 08:52:26 pm »

Load the csv file in an array, and use the in_array() function

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 886
1148 credits
Members referred : 4



« Reply #2 on: Dec 26, 2005, 12:17:57 am »

so i should open file then use in array on the file and then close file? im slightly confused


Last blog : phpHaze 1.59.1 in Development
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #3 on: Dec 26, 2005, 03:47:31 am »

First load the file ( file_get_contents() )

Then create an array using the file ( explode() )

Then search the array for the customer number ( in_array )

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 886
1148 credits
Members referred : 4



« Reply #4 on: Dec 26, 2005, 03:56:26 am »

ok so i would use something like this on the actual page where they use the search box, or in a separate script file?

Code:
<?php file_get_contents('db.csv');
explode('db.csv');
in_array;
?>

lol im sure that wont work cuz i dono what im doin with php unless im editing it lol


Last blog : phpHaze 1.59.1 in Development
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #5 on: Dec 26, 2005, 04:02:00 am »

I think that you should check some tutorials on php....

Then you can check those :

http://www.phpclasses.org/browse/package/1358.html
http://www.phpclasses.org/browse/package/2124.html

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 886
1148 credits
Members referred : 4



« Reply #6 on: Dec 26, 2005, 05:21:50 am »

ok i have search.php file and heres code i have so far

Code:
<?php
echo file_get_contents('db.csv');
echo 
explode('db.csv');
echo 
in_array;

?>


then i have the search form with action as search.php and i get this error when i execute it


Warning: Wrong parameter count for explode() in /hsphere/local/home/meth0d42/meth0d.justinlove.net/search.php on line 3
in_array
« Last Edit: Dec 26, 2005, 05:25:17 am by meth0d420 »


Last blog : phpHaze 1.59.1 in Development
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #7 on: Dec 26, 2005, 05:26:00 am »

Read a little about those functions in the php manual before implementing this.

http://php.net/file_get_contents

http://php.net/explode

http://php.net/in_array

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 886
1148 credits
Members referred : 4



« Reply #8 on: Dec 26, 2005, 05:33:20 am »

heres what i got now

Code:
<?php
$data 
file_get_contents('db.csv');
$results explode($data);
$array = array("Customer #","Delivery Time");
if (
in_array('customer_#'$array)) {
   echo $results;
}
if (
in_array('time'$array)) {
   echo $results;
}

?>


Quote

Warning: Wrong parameter count for explode() in /hsphere/local/home/meth0d42/meth0d.justinlove.net/search.php on line 3
« Last Edit: Dec 26, 2005, 05:35:03 am by meth0d420 »


Last blog : phpHaze 1.59.1 in Development
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #9 on: Dec 26, 2005, 05:38:13 am »

explode ( string separator, string string )

That means that you have to provide explode with a string that will split the file Smiley

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 886
1148 credits
Members referred : 4



« Reply #10 on: Dec 26, 2005, 05:39:43 am »

hmm im not sure what you mean exactly


Last blog : phpHaze 1.59.1 in Development
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #11 on: Dec 26, 2005, 05:45:28 am »

Look man propably you should buy a book for PhP and start over with the basic stuff.

I don't want to dissapoint you, but it is very difficult to learn a scripting language (especially one like php or perl) through a forum.

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=1059
Tags : php forums tutorials databases Bookmark this thread : Digg Del.icio.us Dzone more....

Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: a script that can search a csv file
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 27, 2012, 10:10:17 pm





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!


Forum Statistics
Total Posts: 62.814
Total Topics: 11.028
Total Members: 21.451
Tutorials : 58
Resources : 929
Designs : 395
Latest Member: sobbin

105 Guests, 1 User online :

11 users online today:




Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2012 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.