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

    estrarre dal db per categorie

    Ciao a tutti
    avendo ereditato un sito con delle pagine in php mi trovo di fronte al problema di estrarre delle foto presenti sul db, per categoria
    il codice è il seguente:
    <?php
    mysql_select_db ("nome_db");
    $qr5 = mysql_query("SELECT * FROM foto order by cate");
    $rows5=mysql_num_rows($qr5);
    $idx5 = 0;
    $azzera = 0;
    ?>


    <?php
    while($idx5< $rows5){
    $sql_array5 = mysql_fetch_object($qr5);
    $foto=$sql_array5->foto;
    $testo=$sql_array5->testo;
    $cate=$sql_array5->cate;
    $dirfoto = "../imgpg/th_".$foto;
    $dirgrande = "../imgpg/".$foto;
    if((($azzera%3)==0) && ($idx5!=0) && ($azzera!=0)) {
    $azzera = 0;
    print("</tr>
    <tr>
    ");
    }
    if($idx5==0){
    print("<td colspan=3></td></tr>
    <tr><td colspan=3><font color='#009900'>$cate</font></td></tr>
    <tr>
    ");
    print("<td width='33%' class=testo_foto>[img]$dirfoto[/img]

    $testo</td>
    ");
    $catediv=$cate;
    }
    else{
    if($catediv==$cate){}
    else{
    if($azzera == 0){}
    else{
    while($azzera< 4){
    print("<td width='33%'></td>");
    $azzera++;
    }
    $azzera=0;
    }
    print("</tr>
    <tr><td colspan=3><font color='#009900'>$cate</font></td></tr>
    <tr>");
    }
    print("<td width='33%' class=testo_foto>[img]$dirfoto[/img]

    $testo</td>
    ");
    $catediv=$cate;
    }
    $azzera++;
    $idx5++;
    }
    while($azzera< 4){
    print("<td width='33%'></td>
    ");
    $azzera++;
    }
    ?>

    ho provato a cambiare la query con SELECT * FROM foto where cate='nome_categoria'
    e altre mille cose
    grazie mille per l'aiuto
    hola

  2. #2
    Dovresti dire anche com'è formato il DB, perché ti possa aiutare

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.