RE: [PHP-DB] Re: Array help needed :-(
You may want to revisit your db design, but if it is like that for reason
then it is simple enough to associate these items with each other in an
array.
Just put together a query then get the row and split it by the commas then
put it into an array as follows.
$ar = Array('small' => '1.99', 'medium' => '2.99', 'large' => '3,99');
Then you can access these values by the following.
$smvalue = $ar['small']
This example is a simple array, if you had a lot of products you could use a
multi dimensional array like this.
$ar = Array( 'hotdogs' => Array('small' => '1.99', 'medium' => '2.99',
'large' => '3,99'),
'burgers' => Array('small' => '2.99', 'medium' => '4.99',
'large' => '6,99'))
Then access them like this
$smallburger = $ar['burger']['small']
Hope this helps.
Simon
-Original Message-
From: David Robley [mailto:[EMAIL PROTECTED]]
Sent: 8 October 2002 06:49
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Re: Array help needed :-(
In article <000801c26e10$a2128510$f7fea8c0@chris>, [EMAIL PROTECTED]
says...
> Hi there everyone,
>
> I have a problem i'm trying to figure out but i'm not too good with
> arrays, just know the basics, if anyone could help me out on this it
> would be wonderful :-)
>
> I have two sets of data in columns of a MySQL DB, these items are size
> and price.
>
> Size is seperate by comma's in the first column, and I have it split
> into a dropdown box no problem to read (For example):
>
> small
> medium
> large
>
> but then I have a price field, which contains 1.99,2.99,3.99 etc .
> what I need to do is when someone selects an item from the dropdown -
> say small as an example, it would know how to get 1.99 from the price
> entry in the DB. I guess what I need to do is somehow associate each
> entry in the price field with those in the size, but I have no idea
> how to do it :-(
>
> Any help would be really appreciated as this stumps the hell out of
> me.
>
> Thanks
>
> Chris
I think you may have a problem with your database design? Can you explain
a little more exactly what it is you are trying to do and perhaps someone
can advise on how your data might best be structured.
--
David Robley
Temporary Kiwi!
Quod subigo farinam
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] access DB via PHP classes
Well, what about building a basic class without any database conection in the constructor and then have a inherited class with the needed database conection? and then use whichever you need to generate the pages. You can even just have the basic class and execute some code in the constructor that connects or not to the database depending on a parameter you pass to it. As I told you before, I'm very newbie to OOP as well, but think that may work well. Hope it helps Bye *** Wilmar Pérez Network Administrator Library System Tel: ++57(4)2105145 University of Antioquia Medellín - Colombia 2002 *** -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] need help
I have Mysql set up on the same machine as the apache server. There is a database name inventory_db with a table product_info which have the two row id and name. I know there are three records in the table. However when ever I place this script below into a webpage I get just a blank page. What can I do to correct it. Thank you "); } ?> /*" The gospel is meant to comfort the afflicted and afflict the comfortable." Garrison Keillor*/
Re: [PHP-DB] need help
Remove all of the @ for one, so you can see if there are any errors. You're using $rs as two different variables, also. Check mysql_error() after your query to see if an error is returned. ---John Holmes... - Original Message - From: "Frederick Belfon" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, October 08, 2002 12:19 PM Subject: [PHP-DB] need help I have Mysql set up on the same machine as the apache server. There is a database name inventory_db with a table product_info which have the two row id and name. I know there are three records in the table. However when ever I place this script below into a webpage I get just a blank page. What can I do to correct it. Thank you "); } ?> /*" The gospel is meant to comfort the afflicted and afflict the comfortable." Garrison Keillor*/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Dynamic data from user file
Greetings: I currently am using the fgetcsv function to read in fields from a user-defined file. The delimited file is read and displayed just fine. Firstly, what I'm trying to accomplish: The MySQL database has a table with about 30 fields. The user-defined file may contain only some of these fields and in no particular order. I'm trying to achieve a way for the user to specify what each field is so the insert into MySQL is done correctly. (An analogy would be a custom import. The problem I'm having is finding the best way to go about this. I've been able to read in the data via fgetcsv and dynamically displaying a drop down box above each field with all possible choices but am unable to create a way to link the two for each field successfully. Been looking for solutions as well as trial and error to no avail. Any suggestions? -Sean. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] FLAT FILE database questions.
Hello All, Well, I'm in a situation where I would like to ONLY use a flat file database. I have searched hi and low, though could not find too many resources. So, I am creating my own libraries utilizing arrays. Does anyone have any good links for FLAT FILE databases. Thanks alot. :-) John Negretti Web Applications Developer Cox Communications -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] FLAT FILE database questions.
How about the dbm or dbase functions in the manual? You can create flat file databases with them and possibly have a little more built in functionality that you won't have to program. I've never used them, but check the manual and see if they'll suit you needs. Chapter XVII. Database (dbm-style) abstraction layer functions Chapter XIX. dBase functions Chapter XX. DBM Functions ---John Holmes... > -Original Message- > From: Negretti, John (CCI-San Diego) [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, October 08, 2002 6:28 PM > To: [EMAIL PROTECTED] > Subject: [PHP-DB] FLAT FILE database questions. > > Hello All, > > Well, I'm in a situation where I would like to ONLY use a flat file > database. I have searched hi and low, though could not find too many > resources. So, I am creating my own libraries utilizing arrays. Does > anyone have any good links for FLAT FILE databases. Thanks alot. :-) > > John Negretti > Web Applications Developer > Cox Communications > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] access DB via PHP classes
Thank you again, Wilmar. As a newbie for OOP, I will keep my option open when I design this application. I have not come to a conclusion which way is better than another (I wish I had time to test all possibilities). I appreciate your comments, and will keep them in mind. Regards Ruth - Original Message - From: "Wilmar Perez" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, October 09, 2002 12:10 AM Subject: Re: [PHP-DB] access DB via PHP classes > Well, what about building a basic class without any database conection in the > constructor and then have a inherited class with the needed database > conection? and then use whichever you need to generate the pages. > > You can even just have the basic class and execute some code in the > constructor that connects or not to the database depending on a parameter you > pass to it. > > As I told you before, I'm very newbie to OOP as well, but think that may work > well. > > Hope it helps > > Bye > > *** > Wilmar Pérez > Network Administrator >Library System > Tel: ++57(4)2105145 > University of Antioquia >Medellín - Colombia > 2002 > *** > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Php-Beautify
This program says: Extract the files and put them in a directory, where they can be executed by PHP. My Php is in C:\Program Fileswhere should I extract these files to? Russell Griechen -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Advanced search scripts
I was wondering if anyone has some resources (links or scripts) on 'advanced site searches'. Something that is similar to the way regular search engines process requests. ie. "phrase or two" word +required -"not included" Also, returning details of that search, say for example returning 10 words before and 10 words after and displaying it in search results. The ability to search similar words (eg. ignoring punctuation) would be cool aswell. I am interested in this for database (all text fields), and also searching text files on filesystem. Now, I'm not trying to recreate Google or anything, and this is just for my own research (at this time), but I eventually would like to be able to create a smarter site searching engine. Can anyone give suggestions? or any links to tutorials (or books) I have used regex a little bit before, but not in PHP (only ASP and JavaScript). Adam
