Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    Problema impostazione tabella per stampare una query

    Avrei un problemino col php, spero ci sia qualcuno in grado di illuminarmi!
    Dunque, c'è la pagina php che esegue una query che prende tipo foto, titolo descrizione dal database.
    Poi viene creata una tabella con cui ad ogni ciclo si aggiunge una riga con quei dati suddivisi in colonne.
    Io voglio fare questa stessa cosa però in una griglia dove c'è la tabella, per ogni riga ad esempio 4 colonne. In ogni colonna foto descrizione e titolo insieme. Ma facendo così ovviamente l'immagine è uguale per tutte e 4 le colonne.. che potrei fare? Mi serve un risultato tipo questo alla fine: http://www.vintagerollsroycecars.com/

  2. #2

    Re: Problema impostazione tabella per stampare una query

    Originariamente inviato da findingnerd
    ...
    Ma facendo così ovviamente l'immagine è uguale per tutte e 4 le colonne..
    ...
    E perchè mai?! Se scorri il resultset in ongi record ci sarà l'immagine associata al record considerato.
    "Mai discutere con un idiota. Ti trascina al suo livello e ti batte con l'esperienza." (Oscar Wilde)

  3. #3
    Codice PHP:
    <?php  /**   * @version 1.5   * @package VehicleManagerTop   * @copyright 2009 OrdaSoft   * @author 2009 Sergey Drughinin-OrdaSoft(Sergey.dru@gmail.com)   * @license [url]http://www.gnu.org/copyleft/gpl.html[/url] GNU/GPL   * @description VehicleTop for VehicleManager Component  */    /** ensure this file is being included by a parent file */  defined'_JEXEC' ) or die( 'Restricted access' );  $database = &JFactory::getDBO();    if( !function_exists'sefreltoabs')) {    function sefRelToAbs$value ) {      //Need check!!!        // Replace all &amp; with & as the router doesn't understand &amp;      $url = str_replace('&amp;', '&', $value);      if(substr(strtolower($url),0,9) != "index.php") return $url;      $uri    = JURI::getInstance();      $prefix = $uri->toString(array('scheme', 'host', 'port'));      return $prefix.JRoute::_($url);    }  }    //Common parameters  $sort_top_by    = $params->def('sort_by_top', 0);        //Get how to sort the top items  $show_published    = $params->def('only_published', 1);    //Get if we only show published items  $show_covers     = $params->def('covers', 0 );             //Get if we Real Estate  photos  $cover_height    = $params->def('cover_height', "50");     //Get Real Estate  photos  $show_extra        = $params->def('extras', 1 );             //Get if we show second column with additional info  $show_ranking    = $params->def('ranking', 0 );             //Get if we show the ranking next to them  $showprice    = $params->get ('price', 1);  //Individual parameters  $count_vehicle= intval($params->def('books',1));       //Definition of Sorts  switch($sort_top_by)   {      case 0:          $sql_sort_top = "hits";          break;      case 1:          $sql_sort_top = "date";          break;     // case 2:       //   $sql_sort_top = "rating";     //     break;  }    //Check if only display published items  if ($show_published==1) {      $sql_published = "WHERE published=1";  } else {      $sql_published = "";  }      if($count_vehicle!='' && $count_vehicle!=0) {    $selectstring = "SELECT vtitle,id,image_link,hits,catid,price FROM #__vehiclemanager_vehicles  "      .$sql_published." ORDER BY ".$sql_sort_top." DESC LIMIT 0, $count_vehicle;";    $database->setQuery($selectstring);    $rows_vehicle= $database->loadObjectList();  }      $selectstring = "SELECT id FROM #__menu WHERE link='index.php?option=com_vehiclemanager'";      $database->setQuery($selectstring);      $ItemId_tmp = $database->loadResult();          function DisplayVM($rows, $name, $show_ranking, $show_covers, $show_extra, $cover_height, $ItemId_tmp,$showprice) {          $rank_count = 0;          $span=0;          if($show_ranking!=0) $span++;          if($show_covers!=0) $span++;          if($show_extra!=0) $span++;      ?>              <table cellpadding="0" cellspacing="0" class="moduletable" width="100%" border="0">                           <?php foreach ($rows as $row) {          $rank_count $rank_count 1;    //start ranking          $link1 ="index.php?option=com_vehiclemanager&amp;task=view&amp;id="            .$row->id."&amp;catid=".$row->catid."&amp;Itemid=".$ItemId_tmp;                      $imageURL = $row->image_link ;            if($imageURL != '' && substr($imageURL,0,4) != "http")          {            $imageURL = "./components/com_vehiclemanager/photos/".$row->image_link;           }          if($imageURL == ''){            $imageURL = "./components/com_vehiclemanager/images/no-img_eng.gif";          }         ?>      <tr>         <?php if($show_ranking==1) { echo "<td>".$rank_count.":</td>"; } //Add Column for Ranking if param set ?>             <?php if ($show_covers==1) {?>            <td>              [img]<?php echo $imageURL?>[/img]vtitle; ?>" hspace="2" vspace="2" border="0"                  height="<?php echo $cover_height?>" />            </td>             <?php  ?>            <td width="160" <?php if($span!=0)  echo "colspan='$span'";?>>                  [url="<?php echo sefRelToAbs$link1 ); ?>"]<?php echo $row->vtitle?>[/url]           <?php               if ($showprice == "1") {                  echo "
    "
    .$row->price;               } else {                  echo "";              }                 ?>            </td>              <?php if($show_extra==1) {?>            <td align="right">                 <font class='small'>(<?php echo $row->hits?>)</font>            </td>              <?php ?>       </tr>  <?php ?>          </table>  <?php  }      ?>         <?php   if(count($rows_vehicle)) { DisplayVM($rows_vehicle"Top  Vehicles"$show_ranking$show_covers$show_extra,$cover_height$ItemId_tmp,$showprice); }       ?>  <div style="text-align: center;">[url="http://ordasoft.com"]Powered by OrdaSoft![/url]</div>
    ecco il codice iniziale, poi l'ho modificato un po:
    Codice PHP:
    <?php  /**   * @version 1.5   * @package VehicleManagerTop   * @copyright 2009 OrdaSoft   * @author 2009 Sergey Drughinin-OrdaSoft(Sergey.dru@gmail.com)   * @license [url]http://www.gnu.org/copyleft/gpl.html[/url] GNU/GPL   * @description VehicleTop for VehicleManager Component  */    /** ensure this file is being included by a parent file */  defined'_JEXEC' ) or die( 'Restricted access' );  $database = &JFactory::getDBO();    if( !function_exists'sefreltoabs')) {    function sefRelToAbs$value ) {      //Need check!!!        // Replace all &amp; with & as the router doesn't understand &amp;      $url = str_replace('&amp;', '&', $value);      if(substr(strtolower($url),0,9) != "index.php") return $url;      $uri    = JURI::getInstance();      $prefix = $uri->toString(array('scheme', 'host', 'port'));      return $prefix.JRoute::_($url);    }  }    //Common parameters  $sort_top_by    = $params->def('sort_by_top', 0);        //Get how to sort the top items  $show_published    = $params->def('only_published', 1);    //Get if we only show published items  $show_covers     = $params->def('covers', 0 );             //Get if we Real Estate  photos  $cover_height    = $params->def('cover_height', "50");     //Get Real Estate  photos  $show_extra        = $params->def('extras', 1 );             //Get if we show second column with additional info  $show_ranking    = $params->def('ranking', 0 );             //Get if we show the ranking next to them  $showprice    = $params->get ('price', 1);  //Individual parameters  $count_vehicle= intval($params->def('books',1));       //Definition of Sorts  switch($sort_top_by)   {      case 0:          $sql_sort_top = "hits";          break;      case 1:          $sql_sort_top = "date";          break;     // case 2:       //   $sql_sort_top = "rating";     //     break;  }    //Check if only display published items  if ($show_published==1) {      $sql_published = "WHERE published=1";  } else {      $sql_published = "";  }      if($count_vehicle!='' && $count_vehicle!=0) {    $selectstring = "SELECT vtitle,id,image_link,hits,catid,price FROM #__vehiclemanager_vehicles  "      .$sql_published." ORDER BY ".$sql_sort_top." DESC LIMIT 0, $count_vehicle;";    $database->setQuery($selectstring);    $rows_vehicle= $database->loadObjectList();  }      $selectstring = "SELECT id FROM #__menu WHERE link='index.php?option=com_vehiclemanager'";      $database->setQuery($selectstring);      $ItemId_tmp = $database->loadResult();          function DisplayVM($rows, $name, $show_ranking, $show_covers, $show_extra, $cover_height, $ItemId_tmp,$showprice) {          $rank_count = 0;          $span=0;          if($show_ranking!=0) $span++;          if($show_covers!=0) $span++;          if($show_extra!=0) $span++;      ?>              <table cellpadding="0" cellspacing="0" class="moduletable" width="100%" border="0">                           <?php foreach ($rows as $row) {          $rank_count $rank_count 1;    //start ranking          $link1 ="index.php?option=com_vehiclemanager&amp;task=view&amp;id="            .$row->id."&amp;catid=".$row->catid."&amp;Itemid=".$ItemId_tmp;                      $imageURL = $row->image_link ;            if($imageURL != '' && substr($imageURL,0,4) != "http")          {            $imageURL = "./components/com_vehiclemanager/photos/".$row->image_link;           }          if($imageURL == ''){            $imageURL = "./components/com_vehiclemanager/images/no-img_eng.gif";          }         ?>      <tr>         <?php if($show_ranking==1) { echo "<td>".$rank_count.":</td>"; } //Add Column for Ranking if param set ?>             <?php if ($show_covers==1) {?>            <td>              [img]<?php echo $imageURL?>[/img]vtitle; ?>" hspace="2" vspace="2" border="0"                  height="<?php echo $cover_height?>" />            </td>             <?php  ?>            <td width="160" <?php if($span!=0)  echo "colspan='$span'";?>>                  [url="<?php echo sefRelToAbs$link1 ); ?>"]<?php echo $row->vtitle?>[/url]           <?php               if ($showprice == "1") {                  echo "
    "
    .$row->price;               } else {                  echo "";              }                 ?>            </td>              <?php if($show_extra==1) {?>            <td align="right">                 <font class='small'>(<?php echo $row->hits?>)</font>            </td>              <?php ?>       </tr>  <?php ?>          </table>  <?php  }      ?>         <?php   if(count($rows_vehicle)) { DisplayVM($rows_vehicle"Top  Vehicles"$show_ranking$show_covers$show_extra,$cover_height$ItemId_tmp,$showprice); }       ?>  <div style="text-align: center;">[url="http://ordasoft.com"]Powered by OrdaSoft![/url]</div>

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.