Here is my code:
Expand|Select|Wrap|Line Numbers
- function search_product($types, $makes, $orgProd, $orgName){
- require_once ('../mysqli_connect.php');
- $makesId=count($makes);
- $typesId=count($types);
- echo '<form action="proccessIt.php" method="post" > ';
- echo'<fieldset>';
- for($i=0; $i<$typesId; $i++){
- echo ' type_i: '. $type=$types[$i];
- for($i=0; $i<$makesId; $i++){
- $make=$makes[$i];
- //print product type as header
- // Retrieve product model and id:
- echo $q = "SELECT model AS product_model, id_product AS id_product FROM product WHERE id_brand=$make AND id_type=$type;";
- $r =mysqli_query ($dbc, $q) or die(mysqli_error($dbc)); // Run the query.
- if ($r) { // If it ran OK, display the records.
- echo' <table align="center" cellspacing="3" cellpadding="3" width="75%">
- <tr><td align="left"><b><div id="prodName"> '.$typeLoop.' </div><br/></b></td></tr>
- ';
- // Fetch and print all the records:
- while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) {
- echo '<tr> <td align="left">' .
- ' <input type="checkbox" name="checkbox[]checkbox2[]" value="'. $row['id_product'] .'" value="'. $row['product_model'] .'">
- '. $row['product_model'] .'
- </b> </td> </tr>
- ';
- }//end of while
- mysqli_free_result ($r); // Free up the resources.
- } else { // If it did not run OK.
- // Public message:
- echo '<p class="error">The current request could not be retrieved. We apologize for any inconvenience.</p>';
- // Debugging message:
- echo '<p>' . mysqli_error($dbc) . '<br /><br />Query: ' . $q . '</p>';
- } // End of else.
- }//end of second for loop
- }//end of for loop
- echo '<tr> <td align="left">' .
- '<input type="hidden" name="orgProd" value="'.$orgProd.'" />
- </td> </tr>
- ';
- echo '<tr> <td align="left">' .
- '<input type="hidden" name="orgName" value="'.$orgName.'" />
- </td> </tr>
- ';
- echo '
- </table>
- <input type="submit" value="Search">
- <input type="hidden" name="submitte" value="7"/>
- </fieldset>
- </form>'; // Close the table.
- mysqli_close($dbc); // Close the database connection.
- }//end of product function