Jump to content

Barand

Moderators
  • Content Count

    21,579
  • Joined

  • Last visited

  • Days Won

    555

Barand last won the day on April 11

Barand had the most liked content!

Community Reputation

1,650 Excellent

9 Followers

About Barand

  • Rank
    Sen . ( ile || sei )

Profile Information

Recent Profile Visitors

66,161 profile views
  1. Truck numbers beginning with "F" evaluate to (int)0 Change if ($loadid != 0) { to if ($loadid !== 0) {
  2. First thing you should do is turn on error reporting and clear all your syntax errors. Then you can worry about getting the query right.
  3. Form inputs need a name attibute <select class="form-control" id="seller" name="seller"> You can then retrieve it in the receiving page from $_POST['seller'] (or $_GET['seller'] if your form method is "GET") Anything in the query string is retrieved from $_GET array eg $_GET['month']. If you form method is POST, I would put the date in a hidden form input value so all you date will be in the $_POST array.
  4. I'll eat my words. I couldn't resist the challenge so, having slept on it, I wrote a an SQL function "isConsecutive(dates)" to find records where there are fewer than 10 dates and they are consecutive. TEST DATA and QUERY TABLE: ahtest +----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | id | adates
  5. In a couple of weeks time, when your scalp is bleeding from all the head-scratching trying to do it with only SQL, have a go with this PHP/SQL hybrid. // // GENERATE TEST DATA // $pdo->exec("DROP TABLE IF EXISTS ahtest"); $pdo->exec("CREATE TABLE ahtest( id int not null auto_increment primary key, adates varchar(255))"); $data = []; for ($i=0; $i<20; $i++) { $numdates = rand(8,12); $dt = new DateTime('2021-04-01'); $dates = []; $incs = [1,1,1,1,1,2,1,1,1,1,1,2]; // 16.6% chance of non-consecutive dates for ($j=0; $j<$numdates; $j++) { $inc = $in
  6. Then normalize your data and you stand a chance. Or, as previously stated, be prepared to use php arrays. Arrays/delimited strings of data and SQL don't play nice. Fine if all you want to do is store them as string and retrieve them as a string. You might be able to extract the dates using SUBSTRING_INDEX but I wouldn't attempt it with so many dates and especially when the number of dates is variable.
  7. try echo "<table>"; while ($row = odbc_fetch_array($result)) { if($row['UOMPTRUCKNUMBER'] != $loadid) { if ($loadid != 0) { echo "<tr style='background:#eee'> <td colspan='4'>TOTAL</td> <td>$TotalPcs</td> <td>&nbsp;</td> <td>$LoadTotal</td> </tr>"; } echo "<tr style='background:#82fbfd'>"; echo '<th>'.$row['UOMPTRUCKNUMBER']."</th
  8. If you store data in that manner you deserve to have problems. You can use a query to get those with < 10 dates but you will need to resort to php arrays for the rest.
  9. I use MySQL Workbench (it's free and I hate phpMyAdmin)
  10. Not much modification required. I've commented the changes needed. while ($row = odbc_fetch_array($result)) { echo "<table>"; echo "<tr style='background:#82fbfd'>"; if($row['UOMPTRUCKNUMBER'] != $loadid) { if ($loadid != 0) { # ADD // OUTPUT PREVIOUS TRUCK TOTAL HERE # ADD } # ADD echo '<th&g
  11. Now you have told us the actual context it makes a lot more sense than having reusable member IDs. You also introduced a couple of other attributes that would be stored in the "berth" table (renamed from member_no) viz. Size and Pier. Size required would need to be known at time of allocation to a member. Reallocation of a different berth would need to be a custom transaction, allocation on insert could be a trigger function, de-allocation could be a foreign key cascade option. Your assertion that a member is deleted when their boat changes is FUBAR. Change, or add, a record
  12. I would created a pre-populated table "member_no" which contains a row for each of those values. create table member_no ( memno varchar(3) not null primary key, member_id int ); The "member" table would have a conventional auto_incremented numeric id (not re-used). TABLE member_no TABLE member +----------+------------+ +-----------+------------------+------ | memno | member_id | | member_id | name | etc. +----------+------------+ +-----------+------------------+----- | 01 | 1 | |
  13. Given that for any piece of work, 90% of the task takes 90% of the effort. The final 10% takes another 90%. I'd go with the maximum and double it 😀
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.