jazzman1
Staff Alumni-
Posts
2,713 -
Joined
-
Last visited
-
Days Won
12
Everything posted by jazzman1
-
Do you use this div in other pages on the project? I think, it's a CSS issue. Don't touch anything on the php script if you don't understand.
-
post multiple fields with the same name into a database
jazzman1 replied to mrooks1984's topic in PHP Coding Help
Does the table "store_option$variation_id", it has been updated correctly? I'm seeing a syntax error in the code. -
Congrats Jesi Now, I have to be much more careful than before when I'm writing English
-
Wow..... never ever do this Give me descriptions of these tables. EXPLAIN `RequirementTypes` EXPLAIN `OrderTicketRequirements`
-
Don't use too long names, assign $_GET['id'] to a variable $id = intval($_GET['id']); Try, $query = "SELECT `r`.`RequirementType` FROM RequirementTypes AS `r` JOIN `OrderTicketRequirements` AS `o` ON `r`.`RequirementType` = `o`.`OrderTicketRequirement ` WHERE `o`.`OrderTicketID` = $id"
-
@stubarny, may be the Barand's example is a little bit complex for you, take a look at mine: You have 3 tables - users, purchases, products USERS: +----+-------+ | id | name | +----+-------+ | 1 | David | | 2 | Sam | | 3 | Geoff | | 4 | Peter | | 5 | Tim | +----+-------+ PURCHASES +----+-----------------+--------------------+ | id | purchase_userID | purchase_productID | +----+-----------------+--------------------+ | 1 | 1 | 1 | | 2 | 1 | 2 | | 3 | 2 | 2 | | 4 | 2 | 3 | | 5 | 3 | 1 | | 6 | 3 | 4 | | 7 | 4 | 2 | | 8 | 4 | 4 | | 9 | 5 | 4 | | 10 | 5 | 5 | +----+-----------------+--------------------+ PRODUCTS +----+-------------+ | id | productName | +----+-------------+ | 1 | Lawn Mower | | 2 | Greenhouse | | 3 | Paving slab | | 4 | BBQ | | 5 | Chainsaw | +----+-------------+ Let us say, we want to retrieve all purchase_productID and count them from all users which id is no 5. Our query is gonna be like this: SELECT `p`.`id` , `pr`.`productName` , COUNT( `p`.`purchase_productID` ) AS `total` FROM `purchases` AS `p` JOIN `products` AS `pr` ON `pr`.`id` = `p`.`purchase_productID` WHERE `p`.`purchase_userID` IN ( 1,2,3,4 ) GROUP BY `p`.`purchase_productID` ORDER BY `p`.`id` DESC; If you want the result IN (1,2,3,4) to be dynamic, you could use a subquery like this: SELECT `p`.`id` , `pr`.`productName` , COUNT( `p`.`purchase_productID` ) AS `total` FROM `purchases` AS `p` JOIN `products` AS `pr` ON `pr`.`id` = `p`.`purchase_productID` WHERE `p`.`purchase_userID` IN ( SELECT `u`.`id` FROM `users` AS `u` WHERE `u`.`id` <>5 ) GROUP BY `p`.`purchase_productID` ORDER BY `p`.`id` DESC; RESULT: +----+-------------+-------+ | id | productName | total | +----+-------------+-------+ | 6 | BBQ | 2 | | 4 | Paving slab | 1 | | 2 | Greenhouse | 3 | | 1 | Lawn Mower | 2 | +----+-------------+-------+ If you want to see what purchases David was made (him id is 1) : SELECT `p`.`id` , `pr`.`productName` , COUNT( `p`.`purchase_productID` ) AS `total` FROM `purchases` AS `p` JOIN `products` AS `pr` ON `pr`.`id` = `p`.`purchase_productID` WHERE `p`.`purchase_userID` IN ( SELECT `u`.`id` FROM `users` AS `u` WHERE `u`.`id` = 1 ) GROUP BY `p`.`purchase_productID` ORDER BY `p`.`id` DESC; RESULT: +----+-------------+-------+ | id | productName | total | +----+-------------+-------+ | 2 | Greenhouse | 1 | | 1 | Lawn Mower | 1 | +----+-------------+-------+
-
If you want you retrieve product's name and count all of them except Tim's products, there's my suggest. Tip: Tim's id is 5. SELECT `pr`.`name` , COUNT( * ) AS tot FROM `product` AS `pr` WHERE `pr`.`product_id` IN (SELECT `p`.`product_id` FROM `purchase` AS `p` WHERE `p`.`user_id` <> 5 ) GROUP BY `pr`.`name` ORDER BY tot DESC
-
The type: ALL of a ResignLogin table is not good, where you joined this table with 401369 rows inside of it.. Try to index `LoginID` and `ResignDate` as David and Jesi mentioned above. ALTER TABLE `ResignLogin` ADD INDEX index_on_name (`LoginID`,`ResignDate`)
-
You can do this, but tell us more about tables structure. Do they have IDs, a foreign key, etc....
-
I agree with Jesi about a cron job, but....check this out: http://stackoverflow.com/questions/6327155/how-to-increase-a-field-value-of-mysql-table-every-some-minutes-automatically
-
Ah...obviously you like simple things By the way, Barand's solution is the best for me and array_chunk() is very helpful when constructing db tables with a known number of columns but an unknown number of values.
-
Hi Agreaves, your topic sounds to me like - How to make a good song? I don't want to be rude, but you posted here tons of code without to make even little debugging and expect from us to give you a correct answer. My question is, have you tried dumping the code, if so what errors did you get?
-
Very nice, Barand. I like this
-
Hi vinpkl, it was too late last night for me. Check this out -> http://stackoverflow.com/questions/2478748/can-i-render-in-tabular-form-with-ul-and-li-in-html In your example: <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Untitled Page</title> <style type="text/css"> ul{ margin: 0 auto; padding: 0; } /* The wider the #list_wrapper is, the more columns will fit in it */ #list_wrapper{ width: 200px } /* The wider this li is, the fewer columns there will be */ ul.multiple_columns li{ text-align: left; float: left; list-style: none; height: 30px; width: 100px; } </style> </head> <body> <form id="form1" runat="server"> <div> <div id="list_wrapper"> <ul class="multiple_columns"> <?php //$leftrow=mysql_fetch_array($leftresult); while($leftrow = mysql_fetch_array($leftresult)): ?> <?php echo '<li><a href=#>'.$leftrow['item_name'].'</a></li>';?> <?php endwhile;?> </ul> </div> </div> </form> </body> </html>
-
Ah, this is a different and is to late to thing by the way this is a valid html structure <ul style="padding-bottom: 20px"> <?php for($i = 0; $i < 10; $i++): ?> <?php //$leftrow=mysql_fetch_array($leftresult); while($row = mysql_fetch_array($result)) { echo "<li><a class='leftnav' href='http://localhost/products.php?category_id=10&dealer_id=22'>» " .$row['name']. "</a></li>"; if (($i % 2) == 0) echo "</ul><ul style=padding-top: 20px>"; } ?> <?php endfor;?> </ul> PS, Christian is right, you can use CSS in this case.
-
Try, $leftqry="select * from itemstable where item_catg='men'"; $leftresult=mysql_query($leftqry); for($i = 0; $i < 10; $i++): ?> <ul style="padding-bottom:20px;"> <?php //$leftrow=mysql_fetch_array($leftresult); while($leftrow = mysql_fetch_array($leftresult)) { echo "<li>" . "<a class='leftnav' href='http://localhost/products.php?category_id=10&dealer_id=22'>» " .$leftrow['item_name']. "</a></li>"; if (($i % 2) == 0) echo("</ul><ul>"); } ?> </ul> <?php endfor;?>
-
Someone has to better explain you in proper English, about all problems. I could not provide you examples, b/s too much issues have to be done.
-
Exactly, you have to grab user id from DB and put it in a url link, and when somebody click on this url to get all posts belong to this user by category id. Do you see this ID in the link ?
-
Include the file on the top of script and doing this:
-
Did you include this file to the file with your queries ?
-
Where is this part of code in your script ?
-
Everything is just fine, I got a correct result: The query is, where $id = 1 SELECT `t`.`id` , `t`.`subject` , `p`.`date` , `p`.`name` , `t`.`cat` FROM `forumtopics` AS `t` , `forumposts` AS `p` WHERE `t`.`cat` =1 ORDER BY `t`.`id` DESC LIMIT 1
-
Nice to hear from you my friend. Welcome home Is there a date field in the forumposts table?