-
Posts
24,572 -
Joined
-
Last visited
-
Days Won
824
Everything posted by Barand
-
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?
-
If you are submitting form data you can put it in a hidden field, otherwise you can use AJAX call to pass it to the server
-
Note that doing it that way only works for your table with username and email as unique keys and will require separate code for each table with unique keys, whereas maxxd's solution will work with any table
-
You said they should be visible when the page reloads so you know they start off visible. If you need to know the state store it in a JS variable (which would be initially set to "visible") and set to "hidden" when a link is clicked.
-
To use jquery you need the jquery library EG <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> Also PHP has finished by the time the javascript executes so you cannot use php expressions within javascript
-
The function would go in your PHP file with the HTML output, not in phpMyAdmin. example.php: <?php $db = new mysqli(localhost,XXXXXXXX,XXXXXXXXX,XXXXXXXX); function salesmenOptions($db) { $opts = "'<option value=''>- select salesmen -</option>\n"; $sql = "SELECT id, last_name, first_name FROM salesmen ORDER BY last_name"; $res = $db->query($sql); while (list($id, $last_name, $first_name) = $res->fetch_row()) { $opts .= "<option value='$id'>$first_name $last_name </option>\n"; } return $opts; } ?> <html> <head> <title>Example</title> </head> <body> <select name='salesmen'> <?php echo salesmenOptions($db); ?> </select> </body> </html>
-
try getting the error message (or error info) as well as the error code
-
With MySQL the error message will tell you which key. What RDBMS are you using?
-
Then it's time to re-read the early bits of the PHP manual http://php.net/manual/en/language.basic-syntax.php
-
Here's an example for you The data mysql> SELECT * FROM timetest; +----+----------+---------------------+---------------------+ | id | staff_id | start_time | end_time | +----+----------+---------------------+---------------------+ | 1 | 1 | 2015-04-06 08:35:00 | 2015-04-06 17:35:00 | | 2 | 1 | 2015-04-07 08:30:00 | 2015-04-07 17:50:00 | | 3 | 1 | 2015-04-08 09:35:00 | 2015-04-08 17:55:00 | | 4 | 1 | 2015-04-09 08:30:00 | 2015-04-09 17:20:00 | | 5 | 1 | 2015-04-10 08:20:00 | 2015-04-10 17:50:00 | | 6 | 2 | 2015-04-06 08:15:00 | 2015-04-06 18:10:00 | | 7 | 2 | 2015-04-07 08:25:00 | 2015-04-07 18:50:00 | | 8 | 2 | 2015-04-08 08:30:00 | 2015-04-08 17:20:00 | | 9 | 2 | 2015-04-09 08:10:00 | 2015-04-09 17:00:00 | | 10 | 2 | 2015-04-10 08:00:00 | 2015-04-10 17:00:00 | +----+----------+---------------------+---------------------+ The query to total the times SELECT staff_id , DATE(start_time) , SEC_TO_TIME(SUM(TIMESTAMPDIFF(SECOND, start_time, end_time))) as tot FROM timetest GROUP BY staff_id, DATE(start_time) WITH ROLLUP; The results +----------+------------------+----------+ | staff_id | DATE(start_time) | tot | +----------+------------------+----------+ | 1 | 2015-04-06 | 09:00:00 | | 1 | 2015-04-07 | 09:20:00 | | 1 | 2015-04-08 | 08:20:00 | | 1 | 2015-04-09 | 08:50:00 | | 1 | 2015-04-10 | 09:30:00 | | 1 | NULL | 45:00:00 | <- TOTAL FOR staff 1 | 2 | 2015-04-06 | 09:55:00 | | 2 | 2015-04-07 | 10:25:00 | | 2 | 2015-04-08 | 08:50:00 | | 2 | 2015-04-09 | 08:50:00 | | 2 | 2015-04-10 | 09:00:00 | | 2 | NULL | 47:00:00 | <- TOTAL FOR staff 2 | NULL | NULL | 92:00:00 | <- GRAND TOTAL +----------+------------------+----------+
-
you don't want the the : after case: and you dont need those internal {..}s switch ($_GET['page']) { case 'home': echo "<center><h1>Home Page</h1></center>"; break; case 'Language': echo "<center><h1>LanguagePage</h1></center>"; break; }
-
user login - if user =xxx then login to table xxx
Barand replied to Grumps's topic in PHP Coding Help
You don't even need to reconnect to query another database - the connection is to the server. -
I am assuming you have a table of materials. EG +----------------------+ | id | material | +----+-----------------+ | 1 | wool | | 2 | steel | | 3 | paper | +----+-----------------+ Create a function to build the options from the table $db = new mysqli(HOST,USERNAME,PASSWORD,DATABASE); function materialOptions($db) { $opts = "'<option value=''>- select material -</option>\n"; $sql = "SELECT id, material FROM material ORDER BY material"; $res = $db->query($sql); while (list($id, $mat) = $res->fetch_row()) { $opts .= "<option value='$id'>$mat</option>\n"; } return $opts; } Then <html> <body> <select name='material'> <?php echo materialOptions($db); ?> </select> </body> </html>
-
Sounds like you need an UPDATE query UPDATE users SET trial_date_ended = 'expired' WHERE trial_date_started < CURDATE() - INTERVAL 30 DAY
-
try SELECT DISTINCT s.store_id , s.zip_code FROM store s INNER JOIN merchandise m1 ON s.store_id = m1.storeID AND m1.description = 'clock' INNER JOIN merchandise m2 ON s.store_id = m2.storeID AND m2.description = 'paper' INNER JOIN merchandise m3 ON s.store_id = m3.storeID AND m3.description = 'food'
-
Relational theory says it is necessary - the only things that should appear in multiple records are ids (keys). The shop table saves you from repeating the shop name in thousands of records. Does this work for you? UPDATE babyfoontest JOIN ( SELECT minprice.eancode as ean , webshop.price , webshop.producturl , webshop.shopnaam FROM webshop INNER JOIN ( SELECT eancode , MIN(price) as price FROM webshop GROUP BY eancode ) as minprice USING (eancode,price) ) wsrec USING (ean) SET babyfoontest.prijs = wsrec.price , babyfoontest.deeplink = wsrec.producturl; WHERE wsrec.shopnaam = 'babypark'
-
I would set it up as shown below. Then with "... WHERE cat_name = 'television' ..." you automatically include all webshop records for shops that sell televisions.
-
If there are over a 1m records then there's going to be a lot of shops. If you use the shop names in the WHERE clause, how can you be sure you include all the shops that sell televisions? Also, by doing it the way you propose, you are are going to process every product that those shops sell - not just televisions but mouse-mats, dvds, microwaves etc