Bonjour,
Comment afficher les données d'une base mysql dans un tableau html sous la forme suivante :
* le tableau possède 2 lignes et 4 colonnes
* si toutes les données de ma base mysql ne rentrent pas toutes dans le 1er tableau html, alors un autre tableau se forme dessous le 1er avec toujours 2 lignes et 4 colonnes
Voici mon code php :
<?php
echo '<div class="parameter1">';
echo '<div style="float:left"><strong>';
echo JText::_( 'CATEGORY' );
if ($db->f("parameter_description" )) {
echo " ";
echo mm_ToolTip($par_tran->parameter_description,$VM_LANG->_('PHPSHOP_PRODUCT_TYPE_PARAMETER_FORM_DESCRIPTION'));
}
echo " :</strong></div>";
$dropdown->render_control('',' name="category_id"');
echo '</div>';
$q = "SELECT * FROM #__{vm}_product_type_parameter ";
$q .= "WHERE product_type_id=$product_type_id ";
$q .= "ORDER BY parameter_list_order";
$db->setQuery($q);
$records = $db->_database->loadObjectList('');
// show list of parameters
echo "\n\n<!-- Default list of parameters - BEGIN -->\n";
foreach ($records as $field_num => $par_orig){
$par_tran = $records[$field_num];
if (in_array($par_orig->parameter_name,$skipparameter))
continue;
echo '<div class="parameter1">';
$parameter_type = $par_orig->parameter_type;
if ($parameter_type!="B" ) {
echo '<div style="float:left"><strong>';
echo $par_tran->parameter_label;
if ($db->f("parameter_description" )) {
echo " ";
echo mm_ToolTip($par_tran->parameter_description,$VM_LANG->_('PHPSHOP_PRODUCT_TYPE_PARAMETER_FORM_DESCRIPTION'));
}
echo " :</strong></div>";
$parameter_values= $par_orig->parameter_values;
$parameter_names = $par_tran->parameter_values;
$item_name = "product_type_$product_type_id"."_".$par_orig->parameter_name;
$get_item_value = vmGet($_REQUEST, $item_name, "" );
$get_item_value_comp = vmGet($_REQUEST, $item_name."_comp", "" );
// comparison
echo '<div style="float:right">';
if (!empty($parameter_values) && $par_orig->parameter_multiselect=="Y" ) {
if ($parameter_type == "V" ) { // type: Multiple Values
// Multiple section List of values - comparison FIND_IN_SET
echo "<input type=\"hidden\" name=\"".$item_name."_comp\" value=\"find_in_set_any\">";
}
else { // type: all other
// Multiple section List of values - no comparison
echo "<input type=\"hidden\" name=\"".$item_name."_comp\" value=\"in\" />\n";
}
}
else {
switch( $parameter_type ) {
case "C": // Char
if (!empty($parameter_values)) { // List of values - no comparison
echo "<input type=\"hidden\" name=\"".$item_name."_comp\" value=\"eq\" />\n";
break;
}
case "I": // Integer
case "F": // Float
case "D": // Date & Time
case "A": // Date
case "M": // Time
echo "<select class=\"inputbox\" name=\"".$item_name."_comp\">\n";
echo "<option value=\"lt\"".(($get_item_value_comp=="lt" )?" selected":"" )."><</option>\n";
echo "<option value=\"le\"".(($get_item_value_comp=="le" )?" selected":"" )."><=</option>\n";
echo "<option value=\"eq\"".(($get_item_value_comp=="eq" )?" selected":"" ).">=</option>\n";
echo "<option value=\"ge\"".((empty($get_item_value_comp)||$get_item_value_comp=="ge" )?" selected":"" ).">>=</option>\n";
echo "<option value=\"gt\"".(($get_item_value_comp=="gt" )?" selected":"" ).">></option>\n";
echo "<option value=\"ne\"".(($get_item_value_comp=="ne" )?" selected":"" )."><></option>\n";
echo "</select>";
break;
case "T": // Text
if (!empty($parameter_values)) { // List of values - no comparison
echo "<input type=\"hidden\" name=\"".$item_name."_comp\" value=\"texteq\" />\n";
break;
}
echo "<select class=\"inputbox\" name=\"".$item_name."_comp\">\n";
echo "<option value=\"like\"".(($get_item_value_comp=="like" )?" selected":"" ).">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_IS_LIKE')."</option>\n";
echo "<option value=\"notlike\"".(($get_item_value_comp=="notlike" )?" selected":"" ).">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_IS_NOT_LIKE')."</option>\n";
echo "<option value=\"fulltext\"".(($get_item_value_comp=="fulltext" )?" selected":"" ).">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_FULLTEXT')."</option>\n";
echo "</select>";
break;
case "V": // Multiple Value
echo "<input type=\"hidden\" name=\"".$item_name."_comp\" value=\"find_in_set\" />\n";
break;
case "S": // Short Text
default: // Default type Short Text
if (!empty($parameter_values)) { // List of values - no comparison
echo "<input type=\"hidden\" name=\"".$item_name."_comp\" value=\"texteq\" />\n";
break;
}
echo '<input type="hidden" name="'.$item_name.'_comp" value="like">';
}
}
echo '</div>';
echo '<br style="clear:both" />';
// List of values
if (!empty($parameter_values)) {
$fields=explode(";",$parameter_values);
$names = explode(";",$parameter_names);
echo "<select class=\"inputbox\" name=\"$item_name";
if ($par_orig->parameter_multiselect == "Y" ) {
$size = min(count($fields),6);
echo "[]\" multiple size=\"$size\">\n";
$selected_value = array();
$get_item_value = vmGet($_REQUEST, $item_name, array());
foreach($get_item_value as $value) {
$selected_value[$value] = 1;
}
foreach($fields as $key2=>$field) {
echo "<option value=\"$field\"".(($selected_value[$field]==1) ? " selected>" : ">" ). $names[$key2]."</option>\n";
}
}
else {
echo "\">\n";
echo "<option value=\"\">".$VM_LANG->_('PHPSHOP_SELECT')."</option>\n";
foreach($fields as $key2=>$field) {
echo "<option value=\"$field\"".(($get_item_value==$field) ? " selected>" : ">" ). $names[$key2] ."</option>\n";
}
}
echo "</select>";
}
else { // Input field
switch( $parameter_type ) {
case "I": // Integer
case "F": // Float
case "D": // Date & Time
case "A": // Date
case "M": // Time
echo "<input type=\"text\" class=\"inputbox\" name=\"$item_name\" value=\"$get_item_value\" size=\"20\" />";
break;
case "T": // Text
echo "<textarea class=\"inputbox\" name=\"$item_name\" cols=\"35\" rows=\"6\" >$get_item_value</textarea>";
break;
case "C": // Char
echo "<input type=\"text\" class=\"inputbox\" name=\"$item_name\" value=\"$get_item_value\" size=\"5\" />";
break;
case "S": // Short Text
default: // Default type Short Text
echo "<input type=\"text\" class=\"inputbox\" name=\"$item_name\" value=\"$get_item_value\" size=\"50\" />";
}
}
echo " ".$db->f("parameter_unit" );
switch( $parameter_type ) {
default:
break; // we don't need this trash output
case "D": // Date & Time
echo " (".$VM_LANG->_('PHPSHOP_PRODUCT_TYPE_PARAMETER_FORM_TYPE_DATE_FORMAT')." ";
echo $VM_LANG->_('PHPSHOP_PRODUCT_TYPE_PARAMETER_FORM_TYPE_TIME_FORMAT')." )";
break;
case "A": // Date
echo " (".$VM_LANG->_('PHPSHOP_PRODUCT_TYPE_PARAMETER_FORM_TYPE_DATE_FORMAT')." )";
break;
case "M": // Time
echo " (".$VM_LANG->_('PHPSHOP_PRODUCT_TYPE_PARAMETER_FORM_TYPE_TIME_FORMAT')." )";
break;
}
}
else { // Break line (type == "B" )
echo "<hr>";
}
echo '</div>';
}
echo "\n<!-- Default list of parameters - END -->\n\n";
// Add search according to price:
if (false)
{
$item_name = "price";
$get_item_value = vmGet($_REQUEST, $item_name, "" );
$get_item_value_comp = vmGet($_REQUEST, $item_name."_comp", "" );
echo "<tr>\n <td width=\"35%\" height=\"2\" valign=\"top\"><div align=\"right\"><strong>";
echo $VM_LANG->_('PHPSHOP_CART_PRICE')." :</strong></div>\n </td>\n";
// comparison
echo "<td width=\"10%\" height=\"2\" valign=\"top\" align=\"center\">\n";
echo "<select class=\"inputbox\" name=\"price_comp\">";
echo "<option value=\"lt\"".(($get_item_value_comp=="lt" )?" selected":"" )."><</option>\n";
echo "<option value=\"le\"".((empty($get_item_value_comp)||$get_item_value_comp=="le" )?" selected":"" )."><=</option>\n";
echo "<option value=\"eq\"".(($get_item_value_comp=="eq" )?" selected":"" ).">=</option>\n";
echo "<option value=\"ge\"".(($get_item_value_comp=="ge" )?" selected":"" ).">>=</option>\n";
echo "<option value=\"gt\"".(($get_item_value_comp=="gt" )?" selected":"" ).">></option>\n";
echo "<option value=\"ne\"".(($get_item_value_comp=="ne" )?" selected":"" )."><></option>\n";
echo "</select></td>";
// input text
echo "\n<td> <input type=\"text\" class=\"inputbox\" name=\"price\" value=\"$get_item_value\" size=\"20\" /></td>\n</tr>";
}
// Search Button
?>
<p></p>
<input type="submit" class="button" name="search" value="<?php echo $VM_LANG->_('PHPSHOP_SEARCH_TITLE') ?>">
<?php
} // end - There is a published Product Type
/** Changed Product Type - End */
?>
</form>
<p></p>
<?php
echo "<form action=\"".$sess->url( "option=com_virtuemart" ). "\" method=\"post\" name=\"reset\" style=\"display:inline;\">\n";
echo "<input type=\"submit\" class=\"button\" name=\"reset\" value=\"";
echo $VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_RESET_FORM') ."\">\n</form>";
?>
Les 2 variables qui m'intéressent, et dont je voudrais extraire les résultats sont :
parameter_name
et
parameter_values
La première variable irait afficher les résultats dans la 1ère ligne de mon tableau html et la deuxième variable irait afficher les résultats dans la 2ème ligne. Et donc à chaque nouveaux résultats à afficher, se crée une nouvelle colonne dans mon tableau html.
Si vous avez quelques pistes, merci !