This scripts lists some artists and gives a link to their cds!
For debugging reasons i put an
echo"z= $z";
after if(step==0)
and while it should have an integer value, it gives the output z= Array
(!Why?)
I have to say that the first step of the code (first view of the list-5 artists)
is executed well.
The second step which allows the user to browse through pages of records now cannot be executed!
As you can easily notice the second step is a modification of the first step!
I look forward for any suggestion!
Code: Select all
<?php
if($topic=='artist'){
$id[1]='';
$artist[1]='';
$min=0;//I tried to put it also here
function displayResultsArtistIndex($result,$counter,$artist,$topic)//3eroume ari8mo eggrafwn apo to $counter
{
$min=0;
if($counter-5>0)
{$min=$counter-5;}else{$min=0;}
printf("<table width=400 height=122 border=0><tr>
<td width=100> </td>
<td width=186 bgcolor=#ECE6DA><div align=left>");
for( $i=$counter;$i>$min;$i-- )
{
printf("<p><span class=style3><a href="maincode.php?step=1&topic=artist_diskoi&artist_id=%s"><strong>%s</strong></a><br></span></p>",$artist[$i],$artist[$i]);
}//telos for
printf("</div></td>
<td width=100> </td>
</tr>
</table>");
if($counter>=5)
{
printf("<br><br><strong><font color="#000000" size="2" face="Arial">Σελίδες αποτελεσμάτων: [ </font></strong>");
$x=0;
$y=0;
for($z=$counter;$z>0;$z-=5)
{
$y++;
if($y==1)
{
printf("<strong><font color="#000000" size="3" face="Arial">(%s) </font><strong>", $y); //to $id einai to eidos anazitiseis, to $z einai o header pou deixnei apo poia eggrafi arxizoume
}else{
printf("<a href="maincode.php?step=0&z=%s&topic=%s&x=%s" style="text-decoration: none">
<strong><font color="#000000" size="2" face="Arial">%s </font><strong>
</a>", $z , $topic, $y , $y); //to $id einai to eidos anazitiseis, to $z einai o header pou deixnei apo poia eggrafi arxizoume
}
}
printf("]");
}
}//telos function
function displayResultsArtistIndex0($result,$counter,$composer,$z,$x,$topic)//3eroume ari8mo eggrafwn apo to $counter
{
echo"z= $z";
if($z-5>0)
{$min=$z-5;}else{$min=0;}
printf("<table width=400 height=122 border=0><tr>
<td width=100> </td>
<td width=186 bgcolor=#ECE6DA><div align=left>");
for( $i=$z;$i>$min;$i-- )
{
printf("<p><span class=style3><a href="maincode.php?step=1&topic=composer_diskoi&composer_id=%s"><strong>%s</strong></a><br></span></p>",$composer[$i],$composer[$i]);
}//telos for
printf("</div></td>
<td width=100> </td>
</tr>
</table>");
if($counter>=5)
{
printf("<br><br><strong><font color="#000000" size="2" face="Arial">Σελίδες αποτελεσμάτων: [ </font></strong>");
$y=0;
for($z=$counter;$z>0;$z-=5)//epanaxrhsimopoihsh tou $z!!
{
$y++;
if($y==$x){
printf("<strong><font color="#000000" size="3" face="Arial">(%s) </font><strong>",$y); //to $id einai to eidos anazitiseis, to $z einai o header pou deixnei apo poia eggrafi arxizoume
}else{
printf("<a href="maincode.php?step=0&z=%s&topic=%s&x=%s" style="text-decoration: none">
<strong><font color="#000000" size="2" face="Arial">%s </font>
<strong></a>" ,$z , $topic , $y, $y ); //to $id einai to eidos anazitiseis, to $z einai o header pou deixnei apo poia eggrafi arxizoume
}
}
printf("]");
}
}//telos function
if($step==1)//eleghos an pame gia tin prwti selida
{
require_once ("../../w/connect.inc");
$query = "SELECT composer FROM diskoi GROUP BY composer ";
$result = mysql_query ($query) or die("Αδυναμία εκτέλεσης ερωτήματος");
$counter=0;//metritis stis array
while ($row = @ mysql_fetch_array($result))
{
$counter++;
$composer[$counter]=$row['composer'];
}
displayResultsArtistIndex($result,$counter,$composer,$topic); //edw stelnoume tin pragmatiki katigoria oxi omadopoihseis
}//telos if($step==1)
if($step==0)//eleghos an pame gia polles selides
{
require_once ("../../w/connect.inc");
$query = "SELECT composer FROM diskoi GROUP BY composer ";
$result = mysql_query ($query) or die("Αδυναμία εκτέλεσης ερωτήματος");
$counter=0;//metritis stis array
while ($row = @ mysql_fetch_array($result))
{
$counter++;
$composer[$counter]=$row['composer'];
}
displayResultsArtistIndex0($id,$result,$counter,$composer,$z,$x,$topic); //edw stelnoume tin pragmatiki katigoria oxi omadopoihseis
}//telos if($step==0)
}//telos if(topic==...
?>z= Array
Fatal error: Unsupported operand types in /home/.../www/music/artist.php on line 61