PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 11th, 2000, 06:34 AM
Mouse2K Mouse2K is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Posts: 8 Mouse2K User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi,

I am new to php and I am looking for a flat file database system which will allow me to call different product prices from the flat file database. So basically I have a page that lists many different products. For each product I want to list the price. So I would do a search for each individual product code and then return the appropriate price. Can this be done? And can someone point me in the right direction because I don't even know where to start. I first tried doing this using cgi and some ssi's. However due to multiple ssi's on one page (for mutiple prices) it was too slow and so I was recommended to use php. I would be very grateful to someone who can help me. Please note, the only functionality i really need is for the text file to be searched on and to be able to return a price or code value. Thanks in advance.

Dave.

Reply With Quote
  #2  
Old April 12th, 2000, 06:41 PM
Dist Dist is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Posts: 31 Dist User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 14
It would be really much easier to help you if I knew the format of your "flat file database". If this really is a text file rather than a real database I would suggest you'd move on to mysql or similar if you only can. And if you can't paste some records from that file so we can help you.

Reply With Quote
  #3  
Old April 12th, 2000, 11:36 PM
Mouse2K Mouse2K is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Posts: 8 Mouse2K User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Ok, well I can't really move to mySql for lack of support. However i can use any delimeted type database (eg , or ; or | etc). The fields would be like...
Product_Code, Product, Price, Supplier. I want to be able to search on the product code and display the price. Do you think this is possible??? Thanks heaps for your help.

Dave

Reply With Quote
  #4  
Old April 12th, 2000, 11:42 PM
Mouse2K Mouse2K is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Posts: 8 Mouse2K User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I am also not sure what other databases I can use but I am open to suggestions (but not solutions such as msql, mysql etc as I believe they are not supported on my server and that they would be overkill anyway). I am not sure if DBM would be a suitable type solution but I am still unsure how to implement a system using this as well. Thanks again.

Dave

Reply With Quote
  #5  
Old April 13th, 2000, 12:14 PM
wdn2000's Avatar
wdn2000 wdn2000 is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Apr 2000
Posts: 1,058 wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 6 Days 20 h 56 m 43 sec
Reputation Power: 21
I'm also new to PHP, but have had some
success using flat files. You might want
to give something like this a try:

<?php
$fileName = "yourDataFile"; //The flat file
//name goes here
$myFile = fopen("$fileName","r");
if(!($myFile)) {
print("Couldn't read $fileNamen");
}
while(!feof($myFile)) {
$myLine = chop(fgets($myFile, 255));

//Use as many $var's as you have fields.
//Also, this example is 'pipe' delimited.
list( $var1, $var2 )=split("[|]", $myFile);


//Put your evaluation code here...
//ie. if($var == what I'm looking for) {
// print("some HTML");
// }

}
fclose($myFile);
?>

Hope this helps.
Like I said though, I'm new to PHP so this
may not be the most efficent code...

Scott

Reply With Quote
  #6  
Old April 13th, 2000, 06:27 PM
Mouse2K Mouse2K is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Posts: 8 Mouse2K User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I tried this code but couldn't get it working Does this code allow me to use multiple search type items on the one page? I need at least say 20 or so. I was thinking the top part where it opens the file could be at the top, say in the head tag. Then whenever I need to pull in code use the find and print bit. Would that work? Also, are you able to send me an example page you have used as I tried the one you sent and couldn't get it working. Thanks for your help.

Dave

Reply With Quote
  #7  
Old April 13th, 2000, 09:30 PM
Mouse2K Mouse2K is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Posts: 8 Mouse2K User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Ok, well I have something finally working due to some help from WDN. However because I want to seek multiple items on the one page I want them to be displayed in the order that I want them, not the order that they appear in the database. However I am having trouble using the rewind command. I cannot get it to work properly. Here is what I have so far. Can someone please suggest where to put the code to rewind to the start of the file so that I get the results in the order that I seek for them. Thanks in advance...

-------------------
<?php
$myFile = fopen("hardware.txt","r");
while(!feof($myFile)) {
$myLine = chop(fgets($myFile, 255));
list( $code, $product, $price, $street, $supplier ) = split("[|]", $myLine);
?>

</head>

<p>

<?php

if($code=="GREEN12") {
print("<font size='2' face='Arial, Helvetica'>");
print("Code: <b>$code</b><br>n");
print("Street Price: $<b>$street</b><br></font>n");
}

if($code=="TURBO02") {
print("<font size='2' face='Arial, Helvetica'>");
print("Code: <b>$code</b><br>n");
print("Street Price: $<b>$street</b><br></font>n");
}
if($code=="GREEN05") {
print("<font size='2' face='Arial, Helvetica'>");
print("Code: <b>$code</b><br>n");
print("Street Price: $<b>$street</b><br></font>n");
}
?>

<?php
}
fclose($myFile);

?>

Reply With Quote
  #8  
Old April 13th, 2000, 11:22 PM
wdn2000's Avatar
wdn2000 wdn2000 is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Apr 2000
Posts: 1,058 wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 6 Days 20 h 56 m 43 sec
Reputation Power: 21
I see a potential problem with your code,
and have a suggestion as well.

First, the problem.
You're adding a </head> and <p> tag every
time you go through the loop. That could
result in some rather odd looking output.

Now, the suggestion.
You can check for multiple matches in one
"if".

if($code=="GREEN12" | | $code=="TURBO02") {
print("some HTML..."n);
}

You can get some pretty complex evaluations
just using | | and && (or and and).


As for using the rewind function, I've never
had a use it (in the week or so I've been
thrashing about with PHP )

Good Luck,
Scott

Reply With Quote
  #9  
Old April 13th, 2000, 11:41 PM
Mouse2K Mouse2K is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Posts: 8 Mouse2K User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
well the idea was to have this code inside my existing page. So i would have a beginning <head> tag etc. Also it wouldn't be going through a loop. It would only go through once. Perhaps if I show you a page that will demonstrate how I want to lay it out. This page I was able to link the prices using cgi but you will notice it is very slow to load. The cgi brings in the prices that are in bold. I merely call the code of the product I want and make it return the price. This is the same type of thing i want to do with my php. Here is the page... http://www.microway.com.au/catalog/listcpp_addons1.stm

As for the suggestion about using the | and & I don't think it would help me much as i will know which product to call in so I just will search on that and return the price. And I will want several, each below its respective description.

thanks again.

dave

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Flat File Database

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap