Jump to content

jimfog

Members
  • Posts

    1,803
  • Joined

  • Last visited

Posts posted by jimfog

  1. Well if you kept to the same subject, and not go off on another tangent, but! Not quite another tangent cause you have remnants of the previous subject, we would know where we are, wouldn't we.

    yes you are right...when you mentioned about testing test.html.php....at that point I Misunderstood.

    So,now here we are...I hope we can get a solution here.

  2. This is mod rewrite code

     

    RewriteRule ^/?test.html$ test.php [L]
    
    I don't know where you got the redirect 301 from?

     

    let me clarify some things....

    the redirect command is NOT from you....I found it in the web to make some testing.

    and inside the htaccess file it is only this and ONLY this...I have removed your code.

     

    Are we OK now?

    As I said it is for testing purposes...and later on I will examine the rewrite case.

  3. The redirect you are using is nothing to do with the mod rewrite code, mixing the two will cause it to fail, that simpler redirect which I TOLD YOU NOT TO INCLUDE YET! Should be placed above the opening tag that contain and will run mod rewrite code.

     

    Add nothing else, get it! Do the test.php/html first get it to work, try page1.php with 3 query string, see how that works before going any further. You also mentioned nothing about clearing cache/history. Failing to do THIS evertime you make an amendment to .htaccess means your results won't truly refect current change and probably give impression it did not work, whereas it probably would have, you then amend it again wrongly and end up going round and round in circles.

     

    One by one:

    I know that the redirect has nothing to do mod_rewrite...I do not mix them...here is the file as we speak:

    
    RewriteBase /Appointments/Frontend/ 
    Redirect 301 /blog_dtl/genga.php http://www.example.org/newpage.html
    
    

    You mean I should clear the browser cache?You are right I did not try that.

    I suppose browser history will be gone...

    confirm this please before continuing

  4. I cannot make .htaccess work...inside it I have placed this redirection syntax

    Redirect 301 /genga.php http://www.example.org/newpage.html
    

    this is the link I click

    http://localhost/Appointments/Frontend/blog_dtl/genga.php

     

    And here is the dir structure where I indicate the folder where this .htaccess is located

    https://onedrive.live.com/redir?resid=BE27434B2AAC8130!454&authkey=!AO71ww8Tkksk6hc&v=3&ithint=photo%2cPNG

     

    I always restart Apache...

     

    I do not know what is wrong....

  5. I am going to ask again...so I can have it clear in my mind.

    The link in the HTML file is it going to be dirty?

     

    If the user views the source of the file what URL will be there...forger mod_rewrite for a second and what is displayed in the address bar.

     

    You are describing me the end result....before reaching there I am trying to understand it step by step.

     

    And if you are wondering why I am insisting so much take a look at the read more links here https://taxibeat.com/blog/

  6. I'm just explaining HOW Wordpress which YOU mentioned which IS a CMS works, that could involve the use of a plugin depending on the url required, now it is for YOU, to attempt to recreate, the same result now I've explained what it involves.

    I suppose you mean that the issue now is for a different topic.

  7. I do not use a CMS so the idea of a plugin is not suitable here.

    regarding mod_rewrite...

     

    I do not know how to use it...especially in this case.

     

    For example...the link in the HTML file(that the user will click) is it going to be in the user-friendly form and then transformed to the "dirty" form by mod_rewrite?

    I do not want to go further...answer this for now.

  8. The string "easter-holidays" is probably a unique identifier for the article.

    so...you are saying that the retrieval of the article from the database is based on this unique-identified.

    Are you assuming this is the case or you know it?

  9. I have observed that read more links of blog articles in Wordpress have this user friendly form:

    https://domain.gr/2016/04/26/easter-holidays/

    For the date part I am not sure...probably it is optional

    I do not use Wordpress....I make a custom blog and I want my read more links to have the same form.

    How am I going to achieve this?

    Furthermore I do not see some kind of ID in the url that will aid in retrieving the article from the Database.
    So there is this issue too.

     

    The only thing that I can think of is that the title of the article is used to retrieve the article from the database.

     

    What do you think?

  10. I have these 2 files:

    file1.php

    namespace names;
    
    function t()
    {
        
        echo 'john';
    }
    
    

    file2.php

         use names;
          
    header('Content-type: text/plain');
    echo t();        
          
    

    so.I try to run file2.php and here is what I get:

     

    <br />
    <b>Warning</b>: The use statement with non-compound name 'names' has no effect in <b>C:\Apache24\htdocs\Appointments\nm_spacetest\file2.php</b> on line <b>2</b><br />
    <br />
    <b>Fatal error</b>: Call to undefined function t() in <b>C:\Apache24\htdocs\Appointments\nm_spacetest\file2.php</b> on line <b>5</b><br />

     

    What am I doing wrong...I first import the namespace and then try to run the code that is "registered" to it.

  11. If the amount of data is small enough that downloading it all does not cause a noticeable reduction in load time, that probably means it fits on one page of paginated data. If you don't like to see pagination buttons on your page, you can program it not to display the buttons if there's only one page.

    Exactly....the data is small enough so as to justify such a decision-to download all the data.

  12. I think the best solution is to have a PHP pagination system which is overridden by AJAX.

     

    That means that at no point do you download all the data at once which is a cause of slow page loading.

    I do not think pagination will be needed here since 2-5 services(for now) must be shown to the user....not much data.

    So...assuming no pagination, you suggest that I download the data with PHP after all?

     

    And hide it of course till the user "asks" them of course...

  13. I am building a web app where the user has the option of storing favorites business users where each one of them offers some services.

     

    These services must be seen but the user...whenever he/she clicks on one of the favorites business user.

     

    Here is the question:

    What do you think it is better....prefetch the services with PHP, hide them and make them visible when the user "asks" for them or

    bring them with ajax the moment the user "asks" them.

     

    P.S when I say asks them...I mean a user action such as clicking a button...

  14. This array structure is not ideal for that situation. You're going to have to first construct a temporary data structure to point to the data you want to delete.

    $existing = [The array you currently have]
    
    /* Step 1. Create a new data structure */
    $temp = array();
    foreach($existing as $index => $data) {
      // A key to group times from the same date
      $key = $data['date'];
    
      // A timestamp to measure which dates are more recent
      $timestamp = strtotime($data['date'] . ' ' $data['time']);
    
      // If there aren't any times for this date yet, store this one
      if(!isset($temp[$key])) {
        $temp[$key] = array(
          'index' => $index,
          'timestamp' => $timestamp
        );
    
      // If the largest stored time for this date is earlier than the time of the current element then store the current element 
      } else if($temp[$key]['timestamp'] < $timestamp) {
        $temp[$key]['index'] = $index;
        $temp[$key]['timestamp'] = $timestamp;
      }
    }
    
    /* Step 2. Delete items based on the new data structure */
    foreach($temp as $value) {
      $index = $value['index'];
      unset($existing[$index]);
    }
    
    /* Step 3. Remove gaps left by unset() */
    $existing = array_values($existing);
    

    This kind of task, though, seems ideal for a database to do rather than putting the work on PHP. Databases are highly optimized for searching and manipulating data like this.

    The above code seems to do the job...thanks.

  15. This kind of task, though, seems ideal for a database to do rather than putting the work on PHP. Databases are highly optimized for searching and manipulating data like this.
    

    First of all....the array you see above is taken out of a database...either way.

    To understand better:

    All these times/days you see represent the schedule of a business(hair salon for example)...ex.Friday, from 10:00-15:00.

    From this schedule the available appointments slots are shown to the user...which of course must fall within this time frame.

     

    The only problem is that the last time must not be shown to the user since at that time the store closes and it is not considered an available time-slot.

     

    That is why I want to remove the last time segment from each day....I have not found a way to do it in the DB level(with a query)...as such I am trying to do it using application code.

  16. I have a multidimensional array...it goes like this:

    array(112) {
      [0]=>
      array(4) {
    ["title"]=>
    string(8) "11:00:00"
    ["day"]=>
    string(6) "friday"
    ["date"]=>
    string(10) "2015-12-04"
    ["time"]=>
    string(8) "11:00:00"
          }
          [1]=>
    array(4) {
    ["title"]=>
    string(8) "11:30:00"
    ["day"]=>
    string(6) "friday"
    ["date"]=>
    string(10) "2015-12-04"
    ["time"]=>
    string(8) "11:30:00"
    }
    [2]=>
    array(4) {
    ["title"]=>
    string(8) "12:00:00"
    ["day"]=>
    string(6) "friday"
    ["date"]=>
    string(10) "2015-12-04"
    ["time"]=>
    string(8) "12:00:00"
    }
    
    [3]=>
      array(4) {
    ["title"]=>
    string(8) "12:30:00"
    ["day"]=>
    string(6) "friday"
    ["date"]=>
    string(10) "2015-12-04"
    ["time"]=>
    string(8) "12:30:00"
      }
      [4]=>
      array(4) {
    ["title"]=>
    string(8) "09:00:00"
    ["day"]=>
    string(6) "monday"
    ["date"]=>
    string(10) "2015-12-07"
    ["time"]=>
    string(8) "09:00:00"
      }
    

    it lists the weekdays covering an entire month...every day corresponding to a date and for title I have times(I know this is misleading but I cannot explain now the story behind it)

    The goal:
    For each weekday I want to delete the last array member

    Let me explain:
    In the example above Friday is mentioned for times 11:00...11:30...12:00...12:30...I just want to delete the array member for 12:30....leaving times 11:00...11:30....12:00.

    It has to be a loop..but apart from that I do not know how to proceed....

  17. If you only want rows that exist in both tables then you would use an inner join.

    yes...inner join was the solution after all....nonetheless there is something else yet

    This INNER JOIN gives me the available booking slots for a hair salon(for example)-since I am making an appointments app.

    I must also add the criteria to exclude the already booked appointments stored in this table:

    CREATE TABLE `appointments` (
      `apID` int(11) unsigned NOT NULL AUTO_INCREMENT,
      `Bookfrom` varchar(45) DEFAULT NULL 
      `bookedfor` mediumint(11) unsigned DEFAULT NULL 
      `appont_close_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
      `startDate` date NOT NULL,
      `startime` time NOT NULL,
      `endDate` date NOT NULL,
      `endTime` time NOT NULL,
      `apps_origin` enum('frontend','backend') NOT NULL,
      `staffID` int(11) unsigned DEFAULT NULL,
      `deleted` tinyint(1) unsigned NOT NULL DEFAULT '0',
      PRIMARY KEY (`apID`),
      KEY `fk_appointments_user1_idx` (`Bookfrom`),
      KEY `bokkedfor` (`bookedfor`),
      KEY `fk_appointments_staff1_idx` (`staffID`)
    ) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8
    

    I think here we need a LEFT JOIN with the result of the inner join.

     

    I can perform LEFT JOIN between the avai_apps table and(have already done that) the appointments table....but I am stuck in performing a left join between the result of the above INNER JOIN and the appointments table so that I can get the available timeslots that will take into account the schedule and the already booked app.

     

    Thanks

  18. Could be either, depending on which table you make the left table or the right table.

    can you give me an example of how I could accomplish my goal...using LEFT or RIGHT join.

    What interests me more though is finding out which columns must be NULL in this case...this is what troubles most.

×
×
  • Create New...