View Single Post
  #9 (permalink)  
Old 02-24-06, 05:47 PM
pcinfoman pcinfoman is offline
Coding Addict
 
Join Date: Jan 2006
Posts: 264
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by mab
From the author's code/documentation - "one" is the filename portion of the csv file. From the comment in my sample code. The filename is discussed above, you can change this or make use of a variable. The default location would be the same folder as your script, but you can add a path if it is located somewhere else.
Can you tell me how to build a $filename variable?. Is that something like

$filename = /secured_path/filename.csv

Quote:
Originally Posted by mab
Item_no is the column heading from the csv. You listed item#, but I suspect the "#" would cause a problem at some point in time.
You are right, I just changed that.


Quote:
Originally Posted by mab
If you are essentially building a table, the following would be more efficient then the above method -
PHP Code:

<?php
include('onesqlcoma.php');

$result nosql_selectAllFrom("one");

echo 
"<table border = 1><tr><td>Item Name<td/><td>Rental Price<td/><td>Sale Price<td/><tr/>";
while (
$record=nosql_fetch_array($result)){
echo 
"<tr><td>$record[name]<td/><td>$record[rental]<td/><td>$record[sale]<td/><tr/>";
}
echo 
"<table />";

?>
OK, your latest code works great. However, it seems to be designed to print the entire contents of the csv file. I can see a use for that soon, but not yet. I will even have a need to print only those items in a particular category. But for now, I need to pull individual parts from the csv as needed.

When I use the following code
PHP Code:

<?php
include('includes/onesqlcoma.php');

// define simple function to return row from "one.csv" given the item_no
function get_row($item_in){
$result nosql_selectAllFromWhere("ami_productlist","item_no","=",$item_in);
if (
$record=nosql_fetch_array($result)){
return 
$record;
} else {
return 
"value not found";
}
}

?>

<b>Item #:</b> <?php $row get_row("5656");echo $row[item_no]; ?><br>
<b>Daily Rental #:</b> <?php $row get_row("5656");echo $row[rental]; ?><br>
<b>Sale Price:</b> <?php $row get_row("5656");echo $row[sale]; ?><br>
<b>Item Name:</b> <?php $row get_row("5656");echo $row[name]; ?>
I get the results of.

Item #: 5656
Daily Rental #: $1
Sale Price: $9
Item Name: Dave's Bear

Why is it not showing the full rental price of $1,250.00 and sale price of $9,500.00 like it is in my csv file?

Also, when excel exports out to a csv file, there are quotes in the file, how do I get the php to strip them out? Or is that not important?

Last edited by pcinfoman; 02-24-06 at 06:07 PM.
Reply With Quote