Jump to content

WinstonLA

Members
  • Posts

    23
  • Joined

  • Last visited

Posts posted by WinstonLA

  1. Change name for second variable in the foreach

    foreach ($swap["sims"] as $swap)

    foreach ($swap["sims"] as $swap)

     

     

    This formatting looks better :)

    <select name="sim_for_swap[]">
        <?php foreach ($swap["sims"] as $item): ?>
            <option value="<?php echo $item['voice']; ?>">
                <?php echo $item['voice']; ?>
            </option>
        <?php endforeach; ?>
    </select>
  2. OK. Try comment this line $anime = $file = str_replace(' ', '\ ', $anime);

    And after line $anime = "Sous-titres/".$anime."/"; write var_dump(file_exists($anime)); this will show that is there that directory. If so than uploading should be successful, if no, you need find that path that is will be returned true by file_exists() function.

  3. I just looked at http://php.net/manua....preg-match.php but didn't really understand it

    Regular expressions is a magiс, not all can understand it xD

     

    In the end I need a string (it can be one of the array elements)

    You can get access to the string in array specify array key index. No problem

     

    link me to a good source of info on preg_match

    You need not preg_match() but regular expressions before. Good book about it http://shop.oreilly.com/product/9780596528126.do

  4. $page = file_get_contents("http://www.curse.com/mc-mods/minecraft/railcraft");
    preg_match('#<li class="newest-file">(.*?)</li>#is', $page, $version);
    echo '<pre>' . htmlspecialchars(print_r($version, 1)) . '</pre>';

    The result is

    Array
    (
        [0] => <li class="newest-file">Newest File: Railcraft 9.4.0.0</li>
        [1] => Newest File: Railcraft 9.4.0.0
    )

    Or like this

    preg_match('#<li class="newest-file">.*([0-9\.]++).*</li>#Uis', $page, $versionNum);
    echo $versionNum[1]; //9.4.0.0
    If you need only version number
  5. Try like this

    for ($i = 0; $i < $k; $i++) {
        $z = $i + 1;
        
        //fetch data from database
        $id               = 'the id of the row that the entry/item is at';
        $item_name        = 'the name of the item';
        $current_quantity = 'the current quantity of the item';
        //create a table of entries
        echo '<tr>
    <td>' . $z . '</td>
    <td>' . $item_name . '</td>
    <td>' . $current_quantity . '</td>
    <td>
    
    
    <select id="quantity' . $i . '" name="quantity">
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    </select>
    
    
    </td>';
        echo '<td>
     <button type="button" value="' . $id . '" name="updatebtn" class="quantity_updatebtn">Update Quantity</button>
    </td>';
        echo '</tr>';
    }
    $(document).ready(function(){
     $('body').on('click', '.quantity_updatebtn', (function(){
    
    
        //i use this value to find the exact entry in the database
        var id = $(this).attr('value');
    
    
        var quantity_selected = $(this).closest('tr').find('select[id^="quantity"] option:selected').val();
    
    
        $.ajax({
    type: "POST",
    url: "js/ajax/updatequantity.php",
    data: {id: id, new_quantity: quantity_selected}
    
    
    });
    
    
    
    
       //this is for testing        
       alert('ok');
    
    
     });
    });

     

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