[PHP-DB] Re: Print data
We faced this problem, and decided if we couldn't get a good solution to eliminate the printer. Turns out the users liked it better, and we eliminated a lot of paper. - First we wrote a report writer. - All reports go to the database. - We wrote a report file system. - The report output title shows up in the user report file system in the IN BASKET. - The user can click the file and it displays the first 5 pages to the screen. They can change the start page and number of pages. - The user can file it into other files like WEEKLY REPORTS. - They can send the report to others and it shows up in their IN BASKET. - If they delete the report it sits in the WASTE BASKET file for 10 days. This gives them the ability to file it back somewhere if it was deleted by mistake. This is fast because the reports are run on the server. Only one copy of the report is kept in the database, and the user report file system points to it. Anyway this was our solution and the users love it since they no longer have to file paper, but file reports electronically. They can carbon copy anyone. They can look at any section of the report any time. They can still print the report if they want by using the print button. HTH... Have a great day... Dan José Moreira wrote: hello, at my company we have several network printers and i was was wondering if it's possible to print directly to them using PHP, instead of showing on the screen or both ... to gain more control on what is printed, because of the nasty browsers header and footer ... whom i now how to remove ... i know that the printer IP is 192.192.1.100 and the port is 9005 ... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Mysql vs postgresql
Ditto to postgres. I agree with you. In my experience, the more complex the more compelling reason to go with postgres. Agreed.. mySQL is faster for simple queries. In my application I did comparisons in mySQL and postgres and to my amazement overall postgres was faster. The reason was similar to yours, in many cases it takes several sql statements in mySQL where I could do it in one with postgres. I rewrote the system from mySQL to postgress and in general the code was cut about 10% and in some cases cut in half. I also got rid of a lot of work around.. especially where sub-selects are needed. Maybe the new release of mySQL with sub-selects and transaction processing will compare favorably??? Donno?? Anyway that was my experience.. hope it helps. Have a great day... Dan Gabi Munteanu wrote: I would go for postgresql. Reasons? triggers,procedures,a speed almost equal to mysql. they say mysql is faster. In my experience, only the simplest sites take advantage of this great speed. Once, in a web-page I had 2 sql queries to a Postgresql engine and I had to re-write the code for Mysql: I couldn't without 5 separate queries. So, depending on the complexity of your site you shoud choose betwwen Postgreasql and MySQL. Gabi -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: New to PHP mySQL
Ray, Why not just simply give them a list of available times that meet their number of days requested starting with the day they ask for. Would look something like this. HTH. Dan. Have a great day. -- ? $req_start_date = '2002-04-01'; $req_end_date = '2002-04-20'; $limit = 10; // limit how many are listed $req_start = strtotime($req_start_date); $req_end = strtotime($req_end_date); $num_days = ceil(($req_end - $req_start) / 86400); ? $req_start_date = '2002-04-01'; $req_end_date = '2002-04-20'; $limit = 10; $req_start = strtotime($req_start_date); $req_end = strtotime($req_end_date); $num_days = ceil(($req_end - $req_start) / 86400); echo $req_start $req_end $num_daysBR; $sql = SELECT DATE_ADD(prev_end.bookin_start, INTERVAL 1 DAY) as available_start, DATE_SUB(next_beg.bookin_end, INTERVAL 1 DAY) as available_end, intervening_book.booking_start as intervening_date FROM bookings as prev_end LEFT JOIN bookings as next_beg ON next_beg.villa_id = '$req_villa_id' WHERE prev_end.villa_id = '$req_villa_id' AND (TODAYS(prev_end.booking_end) - TODAYS(next_beg.booking_start) = $num_days OR pre_end.booking_end is null) LEFT JOIN bookings as intervening_book ON intervening_book.villa_id = '$req_villa_id' AND ( intervening_book.booking_end prev_end.booking_end AND intervening_book.bookeng_start next_start.booking_start) WHERE prev_end.villa_id = '$req_villa_id' AND intervening_date is null ORDER BY availabel_start LIMIT $limit ; ? -- Ray Healy ) wrote: Hi all (details of database at then end of this message) I hope someone can give me some advice. I am trying to create a database and access via PHP for a friend of mine that has a caravan park. What I want him to be able to do is to add bookings for the caravans via a PHP page and for clients to be able to search to see if a caravan is available for rent. I have created 2 tables and have put data into it via command prompt and also retrieved the data from it and carried out a join linking the 2 tables together. Which all seems to work well. The one thing I cannot get into my head is how can you tell the database that all the days between the start and end dates are booked. Also when people search for a caravan on a specific date and say they want it for 7 day the database/PHP checks to see if the entire period is totally free for them and does not colide with another booking. I am not sure whether I should be in list list of the PHP list so sorry if I have got it wrong. Any advice or places to visit would be greatly appreciated. Thanks for all your help Ray Details of what i have done already: mysql use matrix Database changed mysqlCREATE TABLE bookings ( - booking_id SMALLINT (6) NOT NULL AUTO_INCREMENT, - booking_start DATE NOT NULL DEFAULT '-00-00', - booking_end DATE NOT NULL DEFAULT '-00-00', - villa_id SMALLINT (6) NOT NULL DEFAULT '0', - PRIMARY KEY (booking_id) - ); mysqlINSERT INTO bookings VALUES (1, '2002-04-01', '2002-04-15', 3); mysqlINSERT INTO bookings VALUES (2, '2002-03-23', '2002-04-04', 1); mysqlCREATE TABLE villas ( - villa_id SMALLINT (6) NOT NULL AUTO_INCREMENT, - vill_name VARCHAR (25) NOT NULL DEFAULT '', - PRIMARY KEY (villa_id) - ); mysqlINSERT INTO villas VALUES (1, 'Gandy'); mysqlINSERT INTO villas VALUES (2, 'Hathaway'); mysqlINSERT INTO villas VALUES (3, 'Healy'); mysqlINSERT INTO villas VALUES (4, 'Mcleod'); mysql SELECT * FROM bookings; ++---+-+-+ | booking_id | booking_start | booking_end | villa_id | ++---+-+-+ | 1 | 2002-04-01 | 2002-04-15 |3 | | 2 | 2002-03-23 | 2002-04-04 |1 | ++---+-+-+ 2 rows in set (0.17 sec) mysql SELECT * FROM villas; +--++ | villa_id | villa_name | +--++ |1| Gandy| |2| Hathaway | |3| Healy | |4| Mcleod | +--++ 4 rows in set (0.00 sec) mysql SELECT villa_name, booking_start, booking_end FROM bookings LEFT JOIN villas ON bookings.villa_id = villas.villa_id; ++---++ | villa_name | booking_start | booking_end | ++---++ | Healy | 2002-04-01 | 2002-04-15 | | Gandy | 2002-03-23 | 2002-04-04 | ++---++ 2 rows in set (0.00 sec) -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Charts...
James. Many times I find myself wanting a quick and dirty bar chart using only HTML. You can do this simply by creating a one pixel image in any color you like. That way the download is only 1 pixel. Then calculate the width or height depending on if you want vertical or horizontal bars by placing the variable in the height or width and display the one pixel image as such: echo img SRC='images/blue.gif' WIDTH=$percent HEIGHT='18' ALIGN='BOTTOM' BORDER='0'; You can stack different colors. But you only get bar graphs. HTH. Dan. James Hatridge wrote: Hi all.. I'm using SuSE 8.0, mysql, and PHP4. Is it possible to make charts with a database? If so, how about a hint on it? Thanks JIM -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: select distinct with all columns
SELECT * FROM equipement WHERE class = microphones GROUP BY type; Russ Arbuthnot wrote: I have a mysql table named equipment with 11 columns named: id, staff_member, class, type, manufacturer, model, description, picture, created, modified, and published. I'm trying to write a select statement similar to this: SELECT DISTINCT type FROM equipement WHERE class = microphones; yet shows all 11 columns of the selected rows rather than just the type column. The only way I know how to show all the columns is to use SELECT *, or to list all the columns manually like SELECT id, type, class, ... etc. But when I tried doing this: SELECT DISTINCT type, id, staff_member, class, manufacturer, model, description, picture, created, modified, published FROM equipment WHERE class = microphones; I just got the exact same answer as if i would have done this: SELECT * FROM equipment WHERE class = microphones; so it didn't help. Can anyone offer a hint? Thanks, russ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Select * from t1.id where not equal to t2.id ???
Dave, Try something like this: SELECT * FROM t1 LEFT JOIN t2 ON t2.id = t1.id WHERE t2.id is NULL HTH. Dan. Dave Carrera wrote: High all I cant seem to get this sql working. I am trying to pull everything from table 1 (t1) where t1.id is not equal to table 2 (t2) id I cant find examples anywhere. Any help or guidance with this as always is very much appreciated. Thanks in Advance Dave C -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: adding a space in mysql
Ron I do believe that placing a space in '%$var %' will do the same as a varchar and sprip it off the end. Not positive. However I believe something like this will do the trick: SELECT something FROM a_file WHERE replace(CONCAT_WS('','.',a_file.field,'.'),' ','.') LIKE '%.$var.%' HTH... Dan Ron Wallace wrote: How can I add a space to the end of a varchar string in mysql? I can't seem to do it directly, and I tried str_pad and other things, but no luck so far. The db doesnt hold the value of the space...its getting trimmed somewhere(?) The reason I want to do this is so I can search for exact matches on one word strings without stemming: ...WHERE name LIKE '$var %'. If the user types 'Wash' I don't want any matches for 'Washington', 'Washing', etc. Thank You All __ Do You Yahoo!? Yahoo! Health - Feel better, live better http://health.yahoo.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: adding a space in mysql
Ron Wallace wrote: thanks, helpers, but I think I have a simple solution: I will insert a space at the front of the string, where the db must accept and retain it. BTW, here is the SQL I am working with: // elseif ($desc==desc) { $sql=SELECT bandid, bandname, bandesc, bin_id, genre FROM bands, genre WHERE (bands.genreid=genre.genreid) AND ; while (list($key, $word)=each($wordsarray)) //$wordsarray from textbox input { $sql=$sql.(bandname LIKE '$word %' OR bandname LIKE '% $word %' OR bandname LIKE '% $word' OR bandesc LIKE '$word%' OR bandesc LIKE '% $word %' OR bandesc LIKE '% $word' OR genre LIKE '$word%' OR genre LIKE '% $word') AND ; } $sql=substr($sql, 0, (strlen($sql)-5)); $sql=$sql. ORDER BY genre.genre ASC, bandname ASC; } /// If I do bandname='$var' I would not hit the band 'Red Letter Day' if the user jusr types 'red'. Howerver if bandname was 'My name is Fred' you will get a hit, because it is LIKE '$word%' where Fred ends with 'red'; -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: n00b deleting entries from db.
Jj Harrison wrote: I know how to delete stuff from a db. Now I want to delete all the earliest entires from the database except the latest 75 entries. Is it easy or hard? I would say easy.. I know about limit but it doesn't seem to work the other way. Assuming you have nothing to associate your records with time of entry, I agree LIMIT seems to be the easiest. If you have sub query try something like this. DELETE from file limit (SELECT count(*) - 75, ',', count(*) from file) If no sub query you probably have to do it with 2 queries. One to get the number of records and the other to substitute the variable $num_records into the DELETE as DELETE from file file limit $num_records - 75, $num_records HTH Dan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Construct, Q+E, QBE
I migrated from informix some years back. This is much easier to do in PHP / mySQL than in informix, and in fact is something that is quite commonly done. Since you can create sql commands as a string, you can put together a string just about anyway you want based on conditions users enter in a form. You could use the same format that Informix uses, however I choose to make the forms somewhat more clear to the user. There are exceptions, but I usually display two input areas per field. One for greater than or equal, and one for less then or equal. They can enter either field or both. Then simply generate the SQL string based on the data entered. For example if you had two fields for price. First is beg_price and other is end_price. Upon return of the from from the user I check both fields. The code would look something like: $where_and = ' WHERE '; $beg_price .= ''; $end_price .= ''; $compare = ''; if ($beg_price '') { $compare .= $where_and price = $beg_price; $where_and = ' AND '; } if ($end_price '') { $compare .= $where_and price = $end_price; $where_and = ' AND '; } $sql = SELECT * FROM customers $compare; You could let them put in the compare such as '=' and use a single input field for price, but I found I had more problems trying to explain that to users. That's your choice. However this seemed to be the easiest for them to use. HTH. Have a great day... Dan = Fernando Ortiz wrote: I'm migrating my code from Informix 4GL to PHP, my problem now is how to give the users the ability to make a query with the facilities that the CONTRUCT verb gives in 4GL. Suppose a form field name 'price' where the users can type the search criteria If the user type ... I need to get ... 123.23 price = 123.23 100 price 100 =500price = 500 100..200price between 100 and 200 100,200 price in (100,200) In a string field named city If the user type ...I need to get sacramento city = 'SACRAMENTO' sacra* city MATCHES 'SACRA*' Wy city 'WY etc. Something like .. $qbe = qbe('city','options') $qry = select * from customers where .$qbe; and the qbe function can get the typed from $_POST[$parm1] and using the options chose between char or numeric data type , upshift or as is, matches or like, etc. Exist something like that? I'm reinventing the wheel? How are you solving this kind of problem? TIA -- Fernando Ortiz Muñoz Fabrica de Jabon la Corona, SA de CV MEXICO -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: PDF
One big question.. Do you have a compelling reason, or company policy to use PDF? Why not just display your data in a html table grid. Sounds like what you are trying to do will work find here. It's faster, simple, and avoids another level of overhead (complexity). Just wondering ... and hope this helps in some way. Have a great day... Dan Natividad Castro wrote: Hi to all, How can I display info in a PDF? All I need is to be able to read from a table and display fields into a PDF. Before, I had my DB in Microsoft Access, so I bounded all the fields in a report and then I converted it into PDF document. But now that we switch to MySQL, I don't know how to generate those PDFs. I've been reading about FDF, but I still I little bit confused. If someone has any idea, please let me know Thanks in advanced Nato -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: resizing images comming out of blobs
Andy, Yes I do it all the time. In this example, I do this with a window that has buttons across the top of a image representing size from 1 to 10. Depending on the button they select they get a image displayed from small to large. Here is a snip of code that displays the sized images. The button name is $s. They select from 1 to 10, but can be any increment. $hi = $s * 100; // size in 100 pixels. (but can be any increment) echo TABLE BORDER='15' CELLPADDING='0' CELLSPACING='0'TRTD image src='ft_image.php?imno=$image_num' BORDER=0 ALIGN='TOP' height=$hi/TD/TR/TABLE ; Note: in the 'image src' you give it a program name, not the image, and pass some way for it to read the image from the DB. In this case the program is ft_image.php and it passes imno. To didplay the photo in ft_image.php, execute the following: header(Content-type: image/jpeg); print(mysql_result($result, 0, photo_image)); photo_image is name of blob field from the DB - HTH.. Good luck.. Dan. === Andy wrote: Hi there, I am wondering how to resize an image which is stored in a mysql blob field. With files this workes just fine, but how to do this with the image comming from blob? Has anybody done this already? Thank you for any help on that, andy -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: subtracting one query from the other
Not sure what your data looks like or what exactly you are trying to do. But what is wrong with the old standard compare for NULL. Something like -- SELECT first_record.id as first_id, second_record.id as second_id FROM second_record LEFT JOIN first_record ON first_record.id = second_record.id ORDER BY something HAVING first_id = NULL Here only the second_records will be selected if there is no matching first_record. HTH.. Good luck .. Dan - Harpreet Kaur wrote: Please help, I am stuck and my mind is frozen. I want to subtrack one query from the other. I have one query that brings all the records. The second gets another set of records. I want to subtract the second query from the first one . How do i do this? First query produces like 1000 records. Second has like 800 records i want to display the other 200 that dont exist in the first query. Please help. I have this but it is too slow and doesnt work in php but does in mssql. select distinct a.playlist, a.material_id, a.destination_locator, a.destination, a.air_time, a.traffic_duration, a.comment, a.title, a.device_name, m.media_locator as source_locator, m.medium_name as source from cch_dubber_dublist_view11 a left outer join lib_copy_view m on a.material_id=m.material_id where (A.material_id is not null) and (A.material_id '') and NOT EXISTS ( select null from dev_device_view d inner join lib_copy_view c on d.device_name= c.medium_name where c.material_id = a.material_id AND c.media_locator = a.destination_locator AND d.device_name = a.device_name ) _ Send and receive Hotmail on your mobile device: http://mobile.msn.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: multiple queries
What's wrong with this or something similar: $sql= mysql_query( SELECT * FROM project WHERE project_name = '$pro_name' AND ( final_approved = 'yes' AND '$project' = 'Management Approve' ORfirst_approved = 'yes' AND '$project' = 'Pre-Approved' ORect... ; $result = mysql_query($sql); $record_count = mysql_num_rows($result); HTH Good luck Dan.. === Natividad Castro wrote: Hi to all, I have a search form where users can search project by 'Project Name' after they type in the project name, they will select which project they will like to view from a drop down menu which contains: Management Approve, Pre-Approved, Management-Not-Approved, and Pre-Not-Approved pproved. I'm using switch statement switch ($project) { case Management Approve $sql = mysql_query(select * from project where project_name='$pro_name' and final_approved='yes'); $result = mysql_query($sql); $record_count = mysql_num_rows($result); case Pre-Approved: $sql2 = mysql_query(select * from project where project_name='$pro_name' and first_approved='yes'); $result2 = mysql_query($sql2); $record_count2 = mysql_num_rows($result2); and so on... My question is: how do I call $sql, or $sql2, and $result, or $result2 to loop and put the fields into an array? The reason I'm asking is because the users will be able to navegate through the recordset, so I need to call just the query that match the criteria either '$result' or '$result2' to be able to display the right information. e.g., while($query_data = mysql_fetch_array($result)) //it can be $result2 { $project_id = $query_data[project_id]; $project_name = $query_data[project_name]; } I'm not sure if this explanation make sence to you guys, but if anybody would like to take the time and try to help me out, that would be great Thanks in advanced Nato -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php