Jump to content

wavix

New Members
  • Posts

    7
  • Joined

  • Last visited

Posts posted by wavix

  1. Is there any other way to get this?

    $oneTime = preg_replace('/[^0-9]/', '', $one);
    $twoTime = preg_replace('/[^0-9]/', '', $two);
    $threeTime = preg_replace('/[^0-9]/', '', $three);
    
    
    if($oneTime == '') {
        $oneTime = '1 month';
    }
    if($oneTime == '7') {
        $oneTime = '7 days';
    }
    if($oneTime == '24') {
        $oneTime = '24 hours';
    }
    if($twoTime == '') {
        $twoTime = '1 month';
    }
    if($twoTime == '7') {
        $twoTime = '7 days';
    }
    if($twoTime == '24') {
        $twoTime = '24 hours';
    }
    if($threeTime == '') {
        $threeTime = '1 month';
    }
    if($threeTime == '7') {
        $threeTime = '7 days';
    }
    if($threeTime == '24') {
        $threeTime = '24 hours';
    }
  2. include('config.php');
    
    $sql = "SELECT * FROM `".$_POST['page']."`";
    $mysql = mysql_query($sql); // This was wrong, you tried to run query on $select, which doesn't exist.
    while($row = mysql_fetch_array($mysql)) {
      $id = $row['id'];
      echo $id;
    }
    

    As for how to make the ajax change, well that's another issue.  There are good ways to do it, but I need more of your jquery code that tells the page to run the ajax, so the click event and stuff.

     

    I forgot to change $select, sorry.

    AJAX code is above, included in index.php between <script></script> tags, on document ready.

  3. include('config.php');
    
    $sql = "SELECT * FROM `today`";
    $mysql = mysql_query($select);
    while($row = mysql_fetch_array($mysql)) {
      $id = $row['id'];
      echo $id;
    }

    I want today to be replaced with index.php $_GET var, ex.: index.php?page=yesterday to change $sql in "SELECT * FROM `yesterday`".

  4. I don't know how to do.

     

    So, I have index.php?page=yesterday, how can I send yesterday to content.php?

     

    Tried this:

    $.ajax({
      type: 'POST',
      url: 'content.php',
      data: {
        page: 'yesterday'
      },
      success: function(data) {}
    });
     
    no success.
  5. Without knowing a bit more about how you are building the $currentPage var or how you are directing people to the other pages, it's kind of hard to say for sure.  Here is an example though using $_GET vars to decide what page it needs to ajax info for.

    $currentPage = (!empty($_GET['page'])) ? $_GET['page'] : '';
    
    $difference = (empty($currentPage)) ? 'index' : $currentPage;
    
    $select = "SELECT * FROM `".$difference."`";
    

    BUT, links that are for anything besides the index would need to have a $_GET var attached.  So like index.php?page=tomorrow.

    Also based on the single $select string I can tell that your DB structure is highly flawed.  I am sure you are just learning at this point, so we don't have to get to deep into that right now.  I also assume you are using the basic mysql functions, if so, I would highly suggest stopping that practice now before you learn to much of the wrong thing.  The mysql functions have now been deprecated and will be removed from PHP in the coming versions.  You should learn mysqli of more preferably PDO.  If you're learning, then now is the time to get in good habits.

     

    Lastly, I truly hope that this is just practice code, cause it's not secure in any fashion.  It's also not common to use a var to indicate a table name to gather FROM.  It can be done but it's usually for very specific reasons and with several lines of code to ensure it's secure to do so.

     

     

    Thank you.

    But how can I send $_GET var to content.php?

     

    It is just example code, in fact I don't have $currentPage. This is what I need.

  6. Hello.

     

    I have index.php containg a div with AJAX content via content.php.

     

    Now, I need yesterday.php and tomorrow.php, like index.php, the only difference will be a variable in content.php.

    Something like:

    if($currentPage == 'yesterday.php') {
      $difference = 'yesterday';
    }
    if($currentPage == 'index.php') {
      $difference = 'today';
    }
    if($currentPage == 'tomorrow.php') {
      $difference = 'tomorrow';
    }
    
    $select = "SELECT * FROM `".$difference."`";

    It is possible to obtain $currentPage that I need using a single file (index.php)? How should I do?

    Hope you understand. Thanks!

×
×
  • 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.