11, October 2008

a script that can search a csv file - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ 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

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



« on: Dec 25, 2005, 08: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?

Visit through proxy Visit through proxy Visit through proxy

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



« Reply #1 on: Dec 25, 2005, 09: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 Visit through proxy

Last blog : Free Unlimited Bandwith and disk space to good to be true?
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 884
1636 credits
Members referred : 4



« Reply #2 on: Dec 26, 2005, 01:17:57 AM »

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

Visit through proxy Visit through proxy Visit through proxy

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



« Reply #3 on: Dec 26, 2005, 04: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 Visit through proxy

Last blog : Free Unlimited Bandwith and disk space to good to be true?
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 884
1636 credits
Members referred : 4



« Reply #4 on: Dec 26, 2005, 04: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

Visit through proxy Visit through proxy Visit through proxy

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



« Reply #5 on: Dec 26, 2005, 05: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 Visit through proxy
http://www.phpclasses.org/browse/package/2124.html Visit through proxy

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy

Last blog : Free Unlimited Bandwith and disk space to good to be true?
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 884
1636 credits
Members referred : 4



« Reply #6 on: Dec 26, 2005, 06: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, 06:25:17 AM by meth0d420 »

Visit through proxy Visit through proxy Visit through proxy

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



« Reply #7 on: Dec 26, 2005, 06:26:00 AM »

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

http://php.net/file_get_contents Visit through proxy

http://php.net/explode Visit through proxy

http://php.net/in_array Visit through proxy

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy

Last blog : Free Unlimited Bandwith and disk space to good to be true?
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 884
1636 credits
Members referred : 4



« Reply #8 on: Dec 26, 2005, 06: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, 06:35:03 AM by meth0d420 »

Visit through proxy Visit through proxy Visit through proxy

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



« Reply #9 on: Dec 26, 2005, 06: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 Visit through proxy

Last blog : Free Unlimited Bandwith and disk space to good to be true?
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 884
1636 credits
Members referred : 4



« Reply #10 on: Dec 26, 2005, 06:39:43 AM »

hmm im not sure what you mean exactly

Visit through proxy Visit through proxy Visit through proxy

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



« Reply #11 on: Dec 26, 2005, 06: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 Visit through proxy

Last blog : Free Unlimited Bandwith and disk space to good to be true?
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....

Topic sponsors:
Get a permanent link here for $1.99!


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?
Oct 11, 2008, 05:44:37 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: 36.904
Total Topics: 7.557
Total Members: 4.149
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: mirela

26 Guests, 4 Users online :

13 users online today:



Readers

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