watsmyname
-
Posts
226 -
Joined
-
Last visited
Posts posted by watsmyname
-
-
What is the data type of your amountFrom and amountTo columns?
It would need to be an INT for math comparisons to work. Also, by putting the '1000' inside of single-quotes in the query, that makes it a string and strings are compared character by character starting with the left-most character.
Oh thanks, got it the single quotes was causing a problem, thanks a lot
-
SELECT pointtoIncrease FROM your_table WHERE amount BETWEEN amountFrom AND amountTo
Thanks for the reply, i think query is not working. The query is
SELECT pointtoIncrease FROM sa_mileagepoints WHERE '1000' BETWEEN amountFrom AND amountTo
So, it should result 5 only, but the query is returning 3 rows, 1,5 and 0
and if amount is 550, it returns two rows 3 and 0
-
Hello,
Suppose i have a table structure
mID pointtoIncrease amountFrom amountTo
1 0 0 99
2 1 100 499
3 3 500 999
4 5 1000 1499
I have to select "pointoIncrease" for given amount. Like i have amount 550, then the point is 3 because 550 lies between amountFrom=500 and amountTo=999. Sounds simple but i m not being able to write a query for that, can anyone please help me.
Thanks
-
Is it possible to have a field (int) to start with 2 zeros?
eg,
00123
I have tried inputting the above value, but the sql table automatically rids them and inputs 123??
datatype should be varchar for that. By the way you can prefix "00" in code, while you fetch data from the database
-
Thanks again,
The great tips, much appreciated. What i came up with is that, we creates attributes for the subcategories, then create a new database table for that subcategory, say "tbl_apartments", and these attributes are saved in this table, simultaneously, we create two xmls for each subcategory, one will be used to create a search form and another to post new product form in the client side. I thought of creating xmls because, suppose there would be a combobox required which might have 100 of options, but we store just one selected value in the table "tbl_apartments" we created. But your idea of creating individual table for each sub-category is nice idea, the search would be pretty faster.
Thanks
Watsmyname
-
Thanks a ton gizmola,
I think creating individual table for each subcategories will be effective. Like first we create a table where we list all the subcategories and name of the tables related to those subcategories. And while creating sub-categories from back end, we'll have option to specify the attributes [properties]. Once done, we'll save the name of subcategory and the name of the new table to the indexing table. and we create a new table with attributes we mentioned from the back end. Am i right?
But i m still confused how we create a search form or product posting form on client side depending upon the created sub category table?? Like for apartment we need Area [textbox], Number of Bedrooms [Combobox], Pets Allowed [Checkbox].. How we manage these form fields dynamically depending upon the sub categories??
Thanks a lot
Watsmyname
-
Another question, the suggestion i want.
The project i m working is little more like ebay.com [but its not the ecommerce site, we will just have discussion and comparision of products], in a sense that we have hundreds of categories and subcategories, and for each subcategories we have different properties. For example for real estate we might have no. of bed rooms, garages etc. For car, we might have VIN number, mileage, etc. Like each of the hundreds sub categories have different properties. And we have search form for items in each subcategories. Search form is different for each categories as we have different properties. So creating search form manually for each subcategories is not possible. So my plan is first from back end i add subcategory say "Apartments/Real Estates". After this we'll have a place where we can add properties like bedrooms, garages, kitchens, pets allowed or not etc. We'll add different properties as required for different sub-categories.
Any suggestion or any comment whether i am going right or not??
Thanks
-
thanks guys,
well actually i am much concerned about search functionality in my site. I went through craiglist and the search functionality is pretty fast. The search functionality in Facebook is too fast as well, I guess they've used full text search functionality of mysql. Beside this are they using anything else to optimize search speed??
Thanks
watsmyname
-
Thanks a lot Thorpe and fenway
@Thorpe, well the informations are based on most user interaction, you can say its a custom forum where user discuss about a popular products in the market, the cost they paid it, the after sales service they got, etc, etc. Several millions of users will be discussing in the topic, they will also be comparing price of products from different states, cities, countries or even continents. In the same time several millions users may be just browsing the forum and see the discussion on the same time.
@fenway
How craiglist manage their database? do they have single database to maintain all the classifieds?? What technic they are using? can you please throw a light upon it?
In my some project, mysql database used to crash when the table had several thousands of rows. So does performance of Mysql server depends upon the system specification??
Thanks
watsmyname
-
Hello,
I have a website which deals with products sales. The site has products listed on the basis of country, states and even cities. There would be estimated 50 million hits per month and same amount of mysql rows of products , details and reviews related to it per month. So, i m sure that if i maintain everything in single database my database will crash too often because of several million rows. So my thought is that i will make database based on countries. So for United States, there will be one database and everything related to US will be put in this database, similarly for Canada, i will have another database, everything related to canada will be kept in this database...and so on.
I will appreciate the suggestion for this purpose. what should i do?
Thanks
watsmyname
-
Hello,
I want some suggestion on the report generator for PHP. I m working on project and i need to generate reports on CSV, XLS, HTML, and PDF
CSV, XLS and HTML is not a problem but generating report on PDF format is what i need.
I used HTML2PDF [its a component of famous fpdf class] it can be used but, i have to show grid on report with some design and this html2pdf doesnt seem to generate report with proper designs like grid background, table width etc.
Is there any php class which can generate a report in pdf without tampering the HTML designs?
Thanks
watsmyname
-
I got it working here is my code
update tablename SET fieldname=TRIM(BOTH ',' from (select replace(CONCAT(',',fieldname,','), ',76,', ',67,'))) WHERE FIND_IN_SET('76',fieldname)>0
-
Thanks mate
My problem is that i have to work with database made by someone else long ago. The reason a field have comma separated value is because a song might have two artists, so in song table they've put the value in comma separated form.
Next your mysql code works, but it adds extra comma like ,176,65,34,67. And next time when i search for 176, its position will be 2 not 1, isn't there another work around??
-
well it wont work always, say i have set 176,65,34,76 above sql code replaces first string too along with matching last one. That is it will change set to 167,65,34,67
can anybody help??
-
Well i came up with this code and seems to work, but not sure if it work always can anybody tell me
update tablename SET fieldname=(select replace(fieldname,'76','67')) WHERE FIND_IN_SET('76',fieldname)>0
-
Hey there
I m sorry if its a repost, i tried to search with no results.
I have mysql table and i have a field which holds value something like sometimes 65, sometimes 65,34, sometimes 65,34,76 and so on. All i need is that i have to match certain value in these comma separated fields [finding i know, we use FIND_IN_SETS], but my problem is i have to find particular value and replace with another
For instance, i have to search 76 and its found in 65,34,76. Now i have to replace this 76 with 67 to make our set look like 65,34,67.
I hope my query is clear, can any body show me the way to achieve this with mysql?
Thanks
-
Is there any particular reason you have chosen to use php to create these dumps? MySql is quite capable of doing this alone.
@thorpe
you seem to be online, can you help me on this, i m not being able to get it work... I also noticed that blob content exported by phpmyadmin and my code are different. When i execute the insert statment generated by phpmyadmin, it works well with blob field binary/image data
-
Help would be much appreciated Anybody please??
-
may be you can use backtick operator?? I m not sure this gonna work for you...you can try though.
<?php $output = `c:\mybat.bat`; // NOTE THAT ` ` ARE NOT SINGLE QUOTES. PHP WILL ATTEMPT TO EXECUTE BACKTICKS AS A SHELL COMMAND echo "<pre>$output</pre>"; ?>
-
Thanks for the reply, i have backend control panel for the website. I dont have to backup whole database or even a whole table, my client just chooses a date and a ID, and rows matching his selection will be generated as SQL file with insert statement of each matching rows.
Hope this makes you bit clear.
-
Hello,
well, my database has a table in which i have longblob field, where images and other files are saved in binary format. My necessity is to generate a .sql file that contains insert statement of the rows. I have used fopen and fputs function for that, but the problem is that when i execute back the query from generated sql file, the longblob field contains plain text instead of Binary/image format. So please anybody help me with this!
<? $bid_doc_sql2="SELECT * from tbl_bid_document WHERE tender_bid_id='1'"; $brs2=mysql_query($bid_doc_sql2) or die(mysql_error()); if(mysql_num_rows($brs2) > 0){ $openfile=fopen("data_backups/".$filename,"w"); while($row2=mysql_fetch_array($brs2)) { $content .="insert into `tbl_bid_document_additional` (`tender_b_id`, `tender_bd_id`, `document_f`, `document_c`, `document_t`, `document_s`, `document_time`) values(`$row2[tender_b_id]`, `$row2[tender_bd_id]`, `$row2[document_f]`, `$row2[document_c]`, `$row2[document_t]`, `$row2[document_s]`, `$row2[document_time]`);\n"; } } fputs($openfile,$content); fclose($openfile); // where document_c is the longblob field ?>
Thanks
watsmyname
-
hello,
well my server has limitation that i can run maximum upto 10 cron jobs. But i need to run more than 10 files. Is there anyway to execute PHP files without Cron jobs ??? may be using exec command? or any other way beside requesting host to allow running more than 10 cron jobs??
thanks
watsmyname
-
Hello
i m passing a files like say "myaudio/1.mp3" and "myvideo/2.wmv", to ZipArchive class, for creating a zip. The class works well and creates a zip file, but it has folders inside it. Isnt there a way so that result zip contains files [1.mp3 and 2.wmv] only ??
Thanks
-
@thorpe
Thanks a ton mate, that is exactly what i wanted.
@oni-kun
Thanks for you help as well
Redirecting non existing subdomains to root domains
in Apache HTTP Server
Posted
Well
i have tried searching my problem but couldnt find, so i m posting it. I want to redirect non existing subdomain to the root domain. But if the subdomain exist then it goes to subdomain. like the subdomain http://mysub.mysite.com doesnot exist so if user enters this url in the browser i want to redirect them to http://www.mysite.com via htaccess. How can i achieve this??
Thanks
Watsmyname