RE: [PHP-DB] Concept help required
You wouldn't happen to have a spare ELH diagram (or two) lying around that one could take a look at, would you? Thanks. TIM -When you save for a long time to buy something, then you find that you can't afford it --- that's inflation. -Original Message- From: DL Neil [mailto:[EMAIL PROTECTED]] Sent: Wednesday, January 09, 2002 7:23 AM To: George Pitcher; [EMAIL PROTECTED] Subject: Re: [PHP-DB] Concept help required =The purpose of an ELH diagram is to take a piece of data (in your case, because we are assuming/checking normalisation, I'd 'cheat' and work at the table level - rather than something more atomic like the data-item level). Once again we draw boxes (I have some wonderful s/w for doing these tasks, but it is M$). A single label/box at the top, featuring the name of the data-unit, and I would guess a minimum of three (must be my favorite number!) boxes in the next row, representing the arrival/creation of the data, its use within the system, and the removal of the data from the system once its usefulness has subsided, respectively. The third row of boxes represents the actual, individual events in the life-cycle/daily operation of the system, and how they alter/update/use the data. Lines drawn between the boxes show how these events relate and where there may be some iteration. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] RE: Multiple select list box to search mysql database
I've done stuff like this in VBScript and haven't yet done it in PHP, so this advice may be worth what you're paying for it: 1. Make sure you've got a space in your sql string. $query .= WHERE MANUFACTURER LIKE '$manufacturername' should be $query .= WHERE MANUFACTURER LIKE '$manufacturername' (note the space before the WHERE). Otherwise your sql will be DISTINCT MANUFACTURER FROM inventoryWHERE manufacturer LIKE 'GE' ORDER BY Manufacturer ASC 2. When your form is submitted, the value of $manufacturername will be a comma-delimited list of all the values they selected. If your query will be based on this selection, then it must read: SELECT ... WHERE Manufacturer IN ('$manufacturername') 3. You can use 'size=n' to control the heigth of the form object SELECT name=manufacturername multiple size=2 TIM -The only domestic animal not mentioned in the Bible is the cat. -Original Message- From: Gisele Grenier [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 01, 2002 9:53 PM To: [EMAIL PROTECTED] Subject: Multiple select list box to search mysql database Hi everyone, This is a php and mysql question... I've spent days trying to figure this out and can only find help on one or the other.. not both things that I'm trying to do. I have a table called inventory which contains the following: manufacturer product price I have a php form that has a list box that contains distinct values from the inventory table as follows: $sql = SELECT DISTINCT MANUFACTURER FROM inventory ORDER BY MANUFACTURER ASC; // execute SQL query and get result $sql_result = mysql_query($sql,$connection) or die(Couldn't execute query.); // put data into drop-down list box while ($row = mysql_fetch_array($sql_result)) { $manufacturername = $row[MANUFACTURER]; $option_block.= OPTION value=\$manufacturername\$manufacturername/OPTION; } Then the list box is created: Select a manufacturer SELECT name=manufacturername optionAll/option ? echo $option_block; ? /SELECT All this works great when selecting only one manufacturer to display. The data is passed to: $query .= WHERE MANUFACTURER LIKE '$manufacturername' Where I'm having a problem is that I want to be able to select multiple manufacturers to search. I know that I need to add multple to the select as: SELECT name=manufacturername multiple and that's about it...I'm lost after this. can anyone shed any light on this? Thanks, Gisele Grenier -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] RE: TO TIM FOSTER - REGARDING THE ALTERNATING ROWS PULLED FROM TABLES
Thanks for the response. I too have been a programmer for about years. (sorry, I couldn't resist ;) I forgot all about testing my approach on PHP, so I went ahead and gave it a shot today. I don't remember what I posted in my pseudocode, but I only encountered a minor syntax error when I wrote it off the top of my head. I'm not sure what problems you saw earler, but here's what I came up with today (it works on my WinNT development box): html body bgcolor=#FF table border=1 ? $col = array(#FF,#EEFFEE); for ($i=0; $i10; $i++) { % tr bgcolor=?=$col[$i % 2 ]% tdrow ?=$i%, cell 1/td tdrow ?=$i%, cell 2/td tdrow ?=$i%, cell 3/td /tr ? } % /table /body /html This prints out a table that's 3 colums wide and 10 rows high, with each row alternating colors between green and white. There are a couple of reasons I offered this approach: 1. Speed. It doesnt repeatedly use a function inside the loop to determine the current color. I would think this would be desireable. I'm betting/guessing that calling a function then comparing it to a value then sticking it in an array is slower than accessing an element of an array using %. 2. Flexibility. If you need more than 2 colors, you just expand the array and change the modulus number from 2 to however many colors you want. I'm still fairly new to all things *nix, so my handling of regular expressions is simply not what it should be. When I look at the ereg() you've got... I'm scratching my head. (but I *think* I know what you're doing). TIM -Depression is merely anger without enthusiasm. -Original Message- From: Vins [mailto:[EMAIL PROTECTED]] Sent: Monday, December 03, 2001 3:27 PM To: [EMAIL PROTECTED] Subject: TO TIM FOSTER - REGARDING THE ALTERNATING ROWS PULLED FROM TABLES Hi Tim. I'm a programerr in PHP4 for about years now and just by looking at your script i can tell it wont work ! First of all, if would be dificult for a begginer developer to implement in their script. For more advanced developers it will be a great challenge for them to try to get ti to work ! I've created my own little Row Alternator for pulling rows from a table. if(ereg(1$|3$|5$|7$|9$, $i)) { $bg[$i] = #33; } else { $bg[$i] = #339966; } Place this script snipet in the function where you have detected if there is actually a result and then just call the bg like this echo TD BGCOLOR=\.$bg[$i].\\n; This sould help alot more. Please dont think that I'm hammering your scripting skills. I'm not. Just a thought. Regards Vins. [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] Re: Alternating rows pulled from database
I'm new to PHP, so I don't know if there are any substantive advantages in execution time to any particular method, but here's what I do (granted, I've never tried it in PHP, but I do it all the time in VBScript). $cols = array(#FF, #EEFFEE); for ($i=1; $i=count(mysql_num_rows($return); $i++) echo tr bgcolor=' . $cols[$i % 2] . '; //..etc next Don't crucify me if the syntax is wrong; hopefully you get the idea. I don't have PHP with me right now, so I won't be able to test it till next week. Would this actually work in PHP? The idea being that if you put it in an array and suddenly decided that you needed more than 2 colors, you just add your colors to the array and change the modulus number. Thoughts? TIM _ l i n e a r c o n c e p t s http://www.linearconcepts.com -Original Message- From: Ryan Marrs [mailto:[EMAIL PROTECTED]] I don't know if this is a better way to do it, but here's how I do it: $return = mysql_query(SELECT This FROM That WHERE This = That); Print table For($i=1;$i=count(mysql_num_rows($return);$i++) If($i % 2 == 0){$color=color1;} else {$color=color2;} Print tr bgcolor='#$color' . td$value[$i]/td . /tr ; } Print /table ; Here's what I did to get alternating row colors on a results page... I'm not sure that I follow what you are asking, but I hope this will help you: $color_one = dd; $color_two = cc; $row_count = 0; // SEND QUERY while (row = fetch array(result)) { $row_color = ($row_count % 2) ? $color_one : $color_two; other fields from DB echo tr bgcolor=$row_color; echo td; echo data out echo /td; echo /tr; $row_count++; } This is a really simple system. It uses the modulus (%) operator. If the result of the math is even it uses color_one otherwise it uses color_two.. I found it somewhere, can't remember where right now.. But at least it works and it's only a few lines of code!! SNIP Think this would work? $rowcount = 0 while($forum = $db-fetch_array($query)) { $forumlist .= ($row_count % 2) ? forum($forum, index_forum) : forum($forum, index_forum2); $rowcount++; } -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] inserting mysql data using php array???
Very interesting. I didn't know you could use SET with an INSERT. I tried this on MySQL and it worked. Dunno if it's standard SQL, but it didn't work on MSAccess and MS SQLServer (the only other DBs I have at hand to test it with). I wonder what other DBs it works on, because you could be painting yourself into a corner if you had to move to another platform. TIM -What if the Hokey-Pokey really is what it's all about? -Original Message- From: Jonathan Hilgeman [mailto:[EMAIL PROTECTED]] I actually have an easy way to do INSERTs like this. First I create the array: $MyArray[field] = value; $MyArray[name] = Jonathan; $MyArray[age] = 123; $MyArray[email] = $email_address; and then I define this function somewhere in a function library: function Array2Query($dbArray) { foreach($dbArray as $dbField = $dbValue) { $dbQuery .= $dbField='$dbValue',; } $dbQuery = substr($dbQuery,0,strlen($dbQuery)-1); return $dbQuery; } and then I just create the query: $Query = INSERT INTO table SET . Array2Query($MyArray); $Result = mysql_query($Query); Hope it helps. - Jonathan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] inserting mysql data using php array???
Interesting. A bit tiedious, I suppose. Seems like it'd be a bit more overhead than I'd care to have, but an interesting technique nonetheless. TIM -I date this girl for two years and then the nagging starts: I wanna know your name. - Mike Binder -Original Message- From: Ubaidul Khan [mailto:[EMAIL PROTECTED]] Sent: Wednesday, November 28, 2001 10:04 AM To: Tim Foster Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] inserting mysql data using php array??? Actually, there is another way of doing it. The prerequisite for this method, is that you have an auto_incremented column. If you have that, then all you have to do is insert a value into one of the columns, then grab mysql_insert_id, and update all columns, corresponding to that auto_incremented value. That's what I ended up doing. - Original Message - From: Tim Foster [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, November 28, 2001 10:37 Subject: RE: [PHP-DB] inserting mysql data using php array??? Very interesting. I didn't know you could use SET with an INSERT. I tried this on MySQL and it worked. Dunno if it's standard SQL, but it didn't work on MSAccess and MS SQLServer (the only other DBs I have at hand to test it with). I wonder what other DBs it works on, because you could be painting yourself into a corner if you had to move to another platform. TIM -What if the Hokey-Pokey really is what it's all about? -Original Message- From: Jonathan Hilgeman [mailto:[EMAIL PROTECTED]] I actually have an easy way to do INSERTs like this. First I create the array: $MyArray[field] = value; $MyArray[name] = Jonathan; $MyArray[age] = 123; $MyArray[email] = $email_address; and then I define this function somewhere in a function library: function Array2Query($dbArray) { foreach($dbArray as $dbField = $dbValue) { $dbQuery .= $dbField='$dbValue',; } $dbQuery = substr($dbQuery,0,strlen($dbQuery)-1); return $dbQuery; } and then I just create the query: $Query = INSERT INTO table SET . Array2Query($MyArray); $Result = mysql_query($Query); Hope it helps. - Jonathan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] help me on projecting some tables
A couple of questions: INSERT INTO traits VALUES(Added Chemicals,LAST_INSERT_ID(),Sugar); 1. Will LAST_INSERT_ID() work reliably in a multi-user environment? What happens if you're in the middle of inserting a dozen records and someone else inserts a record? Does MySQL keep the LAST_INSERT_ID()s separate (since the web application will see both transactions as being done by the same user)? 2. Is there any benefit to having a 3rd table to keep track of characteristics ? I guess that quesiton is best answered by examining the business needs. If the characteristics are few and don't change often, it seems to me that you'd want a 3rd table to keep them. That way, the spelling is similar, etc, and therefore you can do (accurate) queries based on the characteristics (if the need ever came up) TIM -Whenever you hear a man speak of his love for his country, it is a sure sign he expects to be paid for it. -Original Message- From: Rick Emery [mailto:[EMAIL PROTECTED]] CREATE TABLE products( product_id int auto_increment primary key, description char(50) default , quantity int not null, unit enum (each,lb,ounce,gallon,quart), price decimal(5,2) not null ) CREATE TABLE traits( characteristic char(25) default , product_id int, description char(25) ) In the above example, when you wanted to add a characteristic for a particular product, you simply add a record into traits and set traits.product_id equal to products.product_id. This will make it REAL EASY doing joins on this combo as well. For example: INSERT INTO products VALUES(NULL, Coca Cola,1,ounce,0.39); INSERT INTO traits VALUES(Liquid,LAST_INSERT_ID(),Seltzer-based); INSERT INTO traits VALUES(Added Chemicals,LAST_INSERT_ID(),Sugar); INSERT INTO traits VALUES(Added Chemicals,LAST_INSERT_ID(),Brown Dye); INSERT INTO traits VALUES(Added Chemicals,LAST_INSERT_ID(),Caramel coloring); -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] RE: what's a GOOD starting HOURLY rate for a PHP/MYSQL job?
I'd also be interested in what people are charging as I'm thinking of setting up as a contractor myself and it would be nice to have a 'ball park' figure of what the going rate is ... Pls mail replies to [EMAIL PROTECTED] Feel free to post your responses to the list. I'm curious about it too. On the ASP/VBScript side, rates can run anywhere from $40 to $125 per hour. Heck of a ballpark, true, but I guess it's better than nothing. I'm curious if PHP/MySQL rates are in the same ballpark. Quite frankly (IMHO), it boils down to your portfolio, your professionalism and your negotiation skills. Per page vs per job: I find that when taking on a job, usually the client doesn't truly understand the medium and therefore doesn't exactly know what s/he wants. I'm usually better off getting paid by the hour since the project grows when the client realizes what can be done. This can be a turnoff for some clients because there's no upper limit to the cost in sight, but by listening to the client, I can get an idea of how many hours it'll take and give them some comfort that way. The last thing you want to do is bid a fixed cost for the project and then have scope creep break you. You can try to keep scope creep under control by getting the client to commit (in writing) to your proposal (and revised proposals), but my experience is that there's always scope creep and/or enhancements that the client wants (or that the project demands). TIM -The primary function of the design engineer is to make things difficult for the fabricator and impossible for the serviceman. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] RE: what's a GOOD starting HOURLY rate for a PHP/MYSQL job?
-Original Message- From: Kodrik [mailto:[EMAIL PROTECTED]] The problem is that you have to be able to differentiate yourself from those fakes, and it can be difficult. They usually have flashy sites that move and make sound linked some database capability with access (like to catalog their dad's wine bottle so they never plan more than one simultaneous connection). I hear ya! Making the pitch to a customer that doesn't understand why your site doesn't necessarily look gee-whiz-bang, and selling them on the idea that a db-run site is cost effective can be a challenge! I was discussing that once with a guy who was proud of his site. He pays a guy $65 per hour to do all edits on his site ..and I do mean *all*: Yeah, it's real cool! The guy just goes right in, downloads the file, wham! bam! bam! and he's changed the prices on the products, uploads the file, and it's done while I'm standing right there! Hmmm.. I see. Well, the way I design my sites, using a database with a web front-end makes the task of price updates a menial chore that you give to your clerk making $7 per hour ..not your 'webmaster' making $65 per hour. I think a light came on for him. (but he likes his webmaster, so I didn't get the job ;) C'est la vie! TIM -Some people manage by the book, even though they don't know who wrote the book or even what book. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] RE: [PHP-DEV] RE: [PHP-DB] PHP and MySQL queries...
From: Chris Newbill [mailto:[EMAIL PROTECTED]] snip... (been doing VBScript on ASP for several years, tho). I feel sorry for you. :) ;) Never fear. It works, does what it needs to do (so long as it's properly patched ;) and I make a fist-full of money for moon-lighting. Can't complain too loudly, eh? If you're going to store it as an integer, why not store 10/24/2001 as MMDD A better way to do integer date is a UNIX timestamp. This will sort just as easy as the method above. By looking at the date() function you should be able to see immediately the benefit in ease-of-use (not to mention portability in the DB) and formating options available for the timestamp. http://www.php.net/date -Chris Don't get me wrong.. I'm quite comfortable with manipulating dates (well.. as far as M$ goes), and I fully intend to continue using DATE fields and functions to handle my date needs. I'm too lazy to re-invent the wheel. The crux of my question was aimed only at those who didn't want to use DATE fields and would rather use int fields instead. I wanted to make sure I wasn't missing some cool feature of PHP. ..and the feedback I'm getting indicates that my general understanding of dates in ASP is not too different with PHP. TIM -Things are more like they are today than they ever have been before. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]