Jump to content

asgozzi

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

asgozzi's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. the query works fine, I believe the problem comes when trying to access the array cells..
  2. thanks jerastraub but I can't make your code work. my problem comes where you have $ProductID, $BigImage and $Name: I have a single column array and I can't make the pointer go to the next value DOWN the column. the array is built with [/b]$pic_code = mysql_fetch_array($result);[/b] and accessing it like $pic_code[0],$pic_code[1],... doesn't work
  3. This is one of the db tables: [code] CREATE TABLE `avi` ( `id` INT( 4 ) NOT NULL AUTO_INCREMENT , `code` VARCHAR( 6 ) NOT NULL , `description` VARCHAR( 200 ) , `views` INT( 3 ) , PRIMARY KEY ( `id` ) ) TYPE = MYISAM ; [/code]
  4. still nothing. now it can't even get the first picture code. it's like if you couldn't access the array cells, but I can't understand why..
  5. Hi. I'm trying to write a script that fetchs image codes from a mysql database to display them into a 3 columns html table. I got this so far: [code] $selection = $_GET['scelta']; // Leggi il contenuto della variabile che determina la gallery $query  = 'SELECT code FROM `'. $selection.'`;'; // Codice SQL per la query $result = mysql_query($query); // E' necessario contare le righe risultanti della query per poi controllare che la tabella grafica abbia sempre 3 colonne $rows_nb = mysql_num_rows($result); print($rows_nb); // Genero l'array associativo dalla query e inizializzo a 0 la variabile che conterĂ  le immagini $pic_num = 0; $pic_code = mysql_fetch_array($result); print('<table width="60%" border="0" align="center">'); // Stampo l'intestazione HTML della tabella while ($row = mysql_fetch_assoc($result)) { print('<tr>'); // Costruzione della riga for ($tb_rows=0;$tb_rows<3;$tb_rows++) { if ($pic_num < $rows_nb) // Controllo per essere sicuri di non aver sforato con il numero di immagini { // Creo la cella, seleziono l'immagine giusta e inserisco il il tag e il link print('<td><div align="center"><a href="show.php?code='. $pic_code[$pic_num] .'&gallery='. $selection .'"><img src="imagedb/thumbs/'.$pic_code[$pic_num] .'-small.jpg" border="1" /></a></div></td>'); /* DEBUGGING START */ print('<p>PIC_CODE: '. $pic_code[$pic_num] .'</p>'); /* DEBUGGING STOP */ $pic_num++; // Aumento il contatore delle foto inserite } else { print('<td></td>'); } } } [/code] I'm sorry for the comments in italian but I didn't have time to delete them. Anyway, the problem is that the [b]$pic_code[$pic_num][/b] trick doesn't work: only the first picture gets displayed and all the other are broken. This is what happens in the generated page (first & second pics): [code] <td><div align="center"><a href="show.php?code=a_011"><img src="imagedb/thumbs/a_011-small.jpg" border="1" /></a></div></td> <td><div align="center"><a href="show.php?code="><img src="imagedb/thumbs/-small.jpg" border="1" /></a></div></td> [/code] You can see that the link and location of the first image are ok but all the other aren't. I tried printing out the [b]$pic_code[$pic_num][/b] value under each picture but apart from the first all are empty. What should I do?
×
×
  • 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.