Jump to content

CroNiX

Staff Alumni
  • Posts

    1,469
  • Joined

  • Last visited

  • Days Won

    12

Posts posted by CroNiX

  1. The form controls need to be located within the form open (<form>) and close (</form>) tags.



    <form action = "test.php" method = "post">
    <select name="Words">
    <?php
    FOREACH($ddArray1 AS $word){
        PRINT '<option value="'.$word.'">'.$word.'</option>';
    }
    ?>
    </select>
    </form>

    • Like 1
  2. It's being swapped because that's what you are telling it to do.

    INSERT INTO event_calendar (title,event_date,description)
    VALUES (:title, :description, :event_date)')

    Your insert is saying (in order), title, event_date, description

     

    but your VALUES (in order) are :title, :description, :event_date.

     

    Swap the :description and :event_date placeholders in the VALUE.

  3. Barand has a better solution, but mine was something like:

    $count = 0; //keep track of where we are in the array
    $separate = 4; //number of entries before new ul
    echo '<ul>';
    while($row = $results->fetch(PDO::FETCH_ASSOC))
    {
      //If we hit $separate by checking modulus operator, close ul and start a new one
      if ($x%$separate == 0)
      {
        echo '</ul><ul>';
      }
    
      //output li's
      echo '<li>Mileage: '.number_format($row["Mileage"]).'</li>';
      echo '<li>Engine size: '.$row["EngineSize"].'cc</li>';
    
      //increment counter
      $count++;
    }
    echo '</ul>';
  4. Since $files is an array, $i should start at 0, not 1 in the for() loop. You're skipping the first image.

     

    Please also note that the mysql extension is deprecated, meaning it will no longer be available in php in the future. If you want to write code that will work on future versions of php without having to rewrite all of your queries, it's highly suggested you use the PDO or mysqli extension.

  5. It's most likely on your server but just not enabled. Look in your php.ini in the extensions section and look for

    ;extension=php_mysqli.so (or .dll if windows)

    remove the ; from the front of the line and restart apache.

  6. I believe your data is correct. An order can have many products, correct? What you'd need to do is in your loop when you are outputting the data, check to see if the order_id is the same as the last order_id, if not display the order_id, if so it's part of the same order and output a   in the <td>.

     

    You'd probably want to ORDER your query by (orders.order_id, orders.company_id, orders.order_for)

    some pseudocode:

    $last_order_id = null; //store the last order_id
    while($row = $query->fetch_array())
    {
      //check to see if this is a new order or part of the same one
      if ($row['order_id'] != $last_order_id)
      {
        //nope, it's a new order, store as $last_order_id and output the order_id
        $last_order_id = $row['order_id'];
        echo '<td>' . $row['order_id'] . '</td>';
      }
      else
      {
        //it's part of the same order, output a space for this td
        echo '<td> </td>';
      }
    }

    You'd need to do the same thing for anything else you don't want to repeat

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