if statement maybe?
Posted: Mon May 19, 2003 6:59 am
HEy
can anyone help me
The web site is at http://members.lycos.co.uk/jamroponline/
When u click on anime list, list.php is loaded which gathers info from mysql.
if u click on info of the titles, u get another page with a picture and the type of series.
Just one query tho that i am confused abuot.
I have table anime, anitype(weak entity), type.
An anime titles can have 1 or more types, so for example
Anime table
anime_id anime_name
1 Alien 09
Aniype Table
anime_id Type_id
1 1
1 2
Type Table
Type_id Type
1 sci-fi
2 kiddy
When i click on info on alien 09 i put the code
This works fine but the only problem is that 2 pictures of the same series appears.
I understand that cause it has 2 types, it is doing a loop till it ends, and i think to stop the 2 pictures and display just the one picture that i will need an if statement, but i am not sure how to work around this.
I hope u can help, cause i have been trying to sort this out all day. I have books on php, but it seems to not give guildance on this kind of problem.
Many thanks again
can anyone help me
The web site is at http://members.lycos.co.uk/jamroponline/
When u click on anime list, list.php is loaded which gathers info from mysql.
if u click on info of the titles, u get another page with a picture and the type of series.
Just one query tho that i am confused abuot.
I have table anime, anitype(weak entity), type.
An anime titles can have 1 or more types, so for example
Anime table
anime_id anime_name
1 Alien 09
Aniype Table
anime_id Type_id
1 1
1 2
Type Table
Type_id Type
1 sci-fi
2 kiddy
When i click on info on alien 09 i put the code
Code: Select all
<?php
$db =mysql_connect("localhost","jam", "");
mysql_select_db("jam_uk_db",$db);
$sql = "select anime.Anime_Name,type.type_name from anime,anitype,type
where anime.Anime_id=anitype.Anime_id
and anitype.type_id=type.type_id
and anime.Anime_id='$Anime_id' ";
$rs=mysql_query($sql,$db);
$numofrows=mysql_num_rows($rs);
?>
<table border="0"><tr><th>Type </th>
<?php
for ($x = 0; $x <$numofrows; $x++)
{
$row = mysql_fetch_array($rs);
?>
<td><font size="-1"><?php echo $row['type_name'];?></td>
<img src = "image/<?php echo ($row['Anime_Name'])?>.jpg">
<?php
}
?>I understand that cause it has 2 types, it is doing a loop till it ends, and i think to stop the 2 pictures and display just the one picture that i will need an if statement, but i am not sure how to work around this.
I hope u can help, cause i have been trying to sort this out all day. I have books on php, but it seems to not give guildance on this kind of problem.
Many thanks again