-
Posts
2,134 -
Joined
-
Last visited
-
Days Won
42
Everything posted by benanamen
-
mutliple conditions for same join for same column
benanamen replied to Destramic's topic in MySQL Help
As I said, there is still something wrong with his DB design. The condition of an item is not an attribute of the item. It is more of an item status that should go as an int in the items table tied to a status_options table, IE new, used. same thing with the condition. That is not an attribute, it is a condition status that should also be a key in the items table, IE: fair, poor, good, excellent, etc.., not in the attributes table. Using a clock, attributes would be like analog, digital, round, square, electric, battery operated, pendulum, wind up..etc -
mutliple conditions for same join for same column
benanamen replied to Destramic's topic in MySQL Help
One too many joins and you probably want a LEFT join SELECT i.title FROM items i LEFT JOIN item_attributes ia ON ia.item_id = i.item_id WHERE ia.attribute = 'Clock Type' AND ia.value = 'Wall Clock' AND ia.attribute = 'Condition' AND ia.value = 'New' I dont think you need the Clock Type and condition in there. Post your current DB schema. Something still not right. Perhaps more like SELECT i.title FROM items i RIGHT JOIN item_attributes ia ON ia.item_id = i.item_id WHERE ia.value = 'Wall Clock' AND ia.value = 'New' Even still, something wrong there due to your DB design. -
mutliple conditions for same join for same column
benanamen replied to Destramic's topic in MySQL Help
Glad your getting some direction, but your latest query is still not right. Your item to attributes should be joined on the item id in both tables, not this "right join select" you have going on. You have THREE querys. You only need ONE. And like I already told you, there are no "Sub Categorys". Everything is a category, Each category is either a parent or a child of another category. -
mutliple conditions for same join for same column
benanamen replied to Destramic's topic in MySQL Help
For the best feedback, detail out about the site and the functionality desired and how it should work. Based on your posts, it appears to be some sort of auction application. -
mutliple conditions for same join for same column
benanamen replied to Destramic's topic in MySQL Help
Why do you insist on trying to get a bad design to work? Stripped or not, what you have is simply no good. -
mutliple conditions for same join for same column
benanamen replied to Destramic's topic in MySQL Help
Just like building a house or a building, you need to have a solid foundation before you hammer the first nail. The place to start right now is getting your database correct and then building upon that otherwise you are just going to have problems down the road -
mutliple conditions for same join for same column
benanamen replied to Destramic's topic in MySQL Help
I am going to give a minute for others to chime in, but this DB Schema is just no good. Off hand, a category is a category is a category, just that some have parent categories and others dont. You also have some timestamp issues. `sub_category_id` INT(11) NOT NULL, `sub_sub_category_id` INT(11) DEFAULT NULL, `sub_sub_sub_category_id` INT(11) DEFAULT NULL, Really? Sub sub sub? enum('Town/City','County','Country','Continent','MENA Region','Worldwide') Enum??? You only have one table that has any foreign keys. Not sure if you stripped them out or not. This is just really bad. But dont worry, it will get straightened out on this forum. * I think it would be helpful for you to google shopping cart DB schemas in the images tab. -
mutliple conditions for same join for same column
benanamen replied to Destramic's topic in MySQL Help
How about we start at the beginning. Post an SQL dump of your DB so we can make sure your DB is correct. It appears everyone is replying to how YOU think the joins should be done. Give us the DB and the expected output and let us fill in the "How". On a quick glance, it doesn't look right to me. -
Question about deleting where no matching record to join
benanamen replied to sKunKbad's topic in MySQL Help
the a and the C just shortcuts to the table names -
mutliple conditions for same join for same column
benanamen replied to Destramic's topic in MySQL Help
Ahh yes, I had that little brain tickle that something was slightly amiss. -
mutliple conditions for same join for same column
benanamen replied to Destramic's topic in MySQL Help
I believe you answered your own question. AND (sv.value = 'Alarm Clock' AND s.specific_id = '15') OR (sv.value = 'New' AND s.specific_id = '19') -
Surprised you dont know, and yet you are fully aware of it. *PS: What happened to your google? http://xyproblem.info/
-
Allow me to be the first to ask, why? What are you doing? Sounds a lot like the XY problem
-
If you used the correct if($_SERVER['REQUEST_METHOD'] == 'POST') you would not have had that problem in the first place. There are other threads in this forum that discuss why not to do it any other way. Depending on the submit button will completely fail in certain circumstances with Internet Explorer.
-
Header() not working, and sessions not starting
benanamen replied to ryanmetzler3's topic in PHP Coding Help
Your going to have to post more code than that. Show the code for the whole page. -
day BETWEEN 1 AND 4
-
I guess it would help to precisely see the query you are trying to run or the page you get the error on. We are not going to dig through your entire project to find your problem.
-
if ($_SERVER['REQUEST_METHOD'] == 'POST')
-
Dont use if(isset($_POST['submit'])) It can fail in certain circumstances in Internet Explorer. Your quotes outside the numbers are messing you up. It is trying to insert a single value as 5,6,7
-
Why are you putting your connection in a function? All you need to do is require database.php in the pages that need a connection. (Less the function code) And you dont want to output connection error details to the user.
-
Un Checked check boxes do not submit any data whatsoever.
-
That is still a mess of duplicate code. DRY: Don't Repeat Yourself. * Still could be improved.
-
Okay, I guess I am touching this.. Here is a start
-
I am not even going to touch this except to say that the font tag is deprecated. You need to use the span tag for an inline style. You have about 50% more code than what you need.
-
Auto generate a number based on three from an array with rules
benanamen replied to bluefrog's topic in PHP Coding Help
Yes, the purpose. The process as seen from outside the code would be helpful. LIke:User clicks button and based on code calculation X number of numbers are displayed to user...... * Where does this array come from?