-
Posts
24,565 -
Joined
-
Last visited
-
Days Won
822
Everything posted by Barand
-
get new num_rows count after filtering mysqli_fetch_array rows via php
Barand replied to seany123's topic in PHP Coding Help
What filtering are you doing in the PHP function? -
get rows where dob between 2 dates from mysqli
Barand replied to seany123's topic in PHP Coding Help
You need to specify the earlier date of the range first (BETWEEN earlier AND later) You can do it entirely in the SQL WHERE dob BETWEEN CURDATE() - INTERVAL 99 YEAR AND CURDATE() - INTERVAL 18 YEAR -
I've changed the join condition for pm2 SELECT DISTINCT pm1.meta_value AS 'ORDER No' , pm1.post_id AS 'TICKET No' , pm2.meta_value AS 'Guest Name' FROM $wpdb->postmeta pm INNER JOIN $wpdb->postmeta pm1 ON pm.post_id = pm1.post_id AND pm1.meta_key = '_tribe_wooticket_order' INNER JOIN $wpdb->postmeta pm2 ON pm1.meta_value = pm2.post_id AND pm2.meta_key LIKE '% Attendee Name' WHERE pm.meta_key = '_tribe_wooticket_event' AND pm.meta_value = 263;
-
What a mess! Sometimes the meta_value is the OrderNo, at other times the postID is the OrderNo. Then you need to match postID, which looks like an INT field, with integer values held in a char field. Ugh!
-
It would help if you posted some sample data so we can see what it looks like and help us navigate those meta-keys and meta-value fields
-
I think it should be something like this SELECT pm1.meta_value AS 'ORDER No' , pm1.post_id AS 'TICKET No' , pm2.meta_value AS 'Guest Name' FROM $wpdb->postmeta pm INNER JOIN $wpdb->postmeta pm1 ON pm.post_id = pm1.post_id AND pm1.meta_key = '_tribe_wooticket_order' INNER JOIN $wpdb->postmeta pm2 ON pm.post_id = pm2.post_id AND pm2.meta_key LIKE '% Attendee Name' WHERE pm.meta_key = '_tribe_wooticket_event' AND pm.meta_value = 263 LIMIT 0 , 30
-
PHP & MySQL - Calculation before inserting data into table
Barand replied to rvdveen27's topic in PHP Coding Help
Don't put the quotes around column names - SQL will treat them as strings. SELECT price, costs, cargodamage, price - costs - cargodamage as profit FROM drive_routes -
PHP & MySQL - Calculation before inserting data into table
Barand replied to rvdveen27's topic in PHP Coding Help
I agree with ginerjm's basic tenet except I wouldn't restrict the advice to same table only. For example you wouldn't store a total when the total can be got by SUMming a related table. Don't store data that is derived from other data. -
Select the four categories that you want to list in your query. For example SELECT ... WHERE catID IN (1,3,5,6)
-
Don't hijack other peoples posts.
-
Can't insert data to the database in phpmyadmin.... help plz
Barand replied to samovich's topic in PHP Coding Help
You are not posting anything that has the name "Submit" so $_POST['Submit'] is never set. -
Fastest way to count mysql rows using mysqli (or another method)
Barand replied to jamesjmann's topic in MySQL Help
I use $res = $mysqli->query("SELECT COUNT(*) FROM table"); list($count) = $res->fetch_row(); -
Is there a way to format the date output of a function?
Barand replied to OGBugsy's topic in PHP Coding Help
I wasn't aware bind_result() could have "?" placeholders -
How do I modify this code to include date range?
Barand replied to sonnieboy's topic in PHP Coding Help
You could introduce a couple of new search types into your array gte (greater than or equal to) lte (less than or equal to -
Is there a way to format the date output of a function?
Barand replied to OGBugsy's topic in PHP Coding Help
Just curious, Psycho, but would would you use the same argument in (2) above when it comes to using prepared statements and bind_result()? -
Is there a way to format the date output of a function?
Barand replied to OGBugsy's topic in PHP Coding Help
Storing in the database as you do now is the correct way. Format the date as required on output using the code blacknight provided ($date in his code would be your date field from the database record). Alternatively, you can format the date in your sql query using the mysql function DATE_FORMAT http://dev.mysql.com/doc/refman/5.6/en/date-and-time-functions.html#function_date-format -
Which is a case-study in why you should not stored derived data (like totals) in tables as it can easily get out of sync. You should always query the original data to get the total. Just my 0.02 worth.
-
Now we see why you're using arrays - your data is stored like a spreadsheet. Does "normalization" mean anything to you?
-
import csv file into mysql with file path in a textbox
Barand replied to iojbr's topic in PHP Coding Help
You also need to look at how to upload a file. http://php.net/manual/en/features.file-upload.post-method.php -
Do you want us to use our crystal balls and tell you which column names you should be using instead of the ones you are currently storing in the array?
-
Not much I can add to Gizmola's reply and I don't know how your application is processing the table. If you find a lot of the scores in each record are unused, or only one score is updated at any one, time then instead of +--------+-----+-----+-----+--------+--------+-----+---------+ | userid | X | Y | Z | score1 | score2 | ... | score90 | +--------+-----+-----+-----+--------+--------+-----+---------+ you could consider putting the used scores in a separate table, one score per row USER TABLE +--------+-----+-----+-----+ | userid | X | Y | Z | +--------+-----+-----+-----+ | | +----------------+ | | SCORE TABLE +---------+---------+---------+ | userid | scoreid | score | +---------+---------+---------+
-
PHP Active Directory Get displayName Field for Current User
Barand replied to djollie029's topic in PHP Coding Help
I found the ADLDAP class a great help when working on intranets with active directory https://github.com/adldap/adLDAP -
You need ($hours + $minutes/60) * $pay
-
cyberRobot - How do you, or any of us, know what will be of use when we don't know how s/he is storing the data?