which datatype?
Moderator: General Moderators
which datatype?
Hey
Wondering if anyone can help
I have a table which has an anime name, ep start and ep end
anime name is varchar
ep start is int
ep end is int
When i insert in a new anime titles, and if there is not an ep end, say there is only 1 episode, andI leave ep end blank, but when i get the results of anime titles, i always get a 0 in ep end, is there a way to stop this, or another data type i should use to leave it blank?
many thanks
Wondering if anyone can help
I have a table which has an anime name, ep start and ep end
anime name is varchar
ep start is int
ep end is int
When i insert in a new anime titles, and if there is not an ep end, say there is only 1 episode, andI leave ep end blank, but when i get the results of anime titles, i always get a 0 in ep end, is there a way to stop this, or another data type i should use to leave it blank?
many thanks
- coolpravin
- Forum Newbie
- Posts: 20
- Joined: Mon May 19, 2003 12:56 am
- Location: India
But why to change
But why youi want to change that man !!!!!
Otherwise you can use varchar here also.
I know you may want to use
ep end =ep start
when your ep end is balnk.
Hence when it is zero use this
and thats all.Because int is always better to manipulate with numbers.
Hence i will insist on to use int.

Hence whenever you find it 0 consider it as blank.You can consider this 0 as blank.
Otherwise you can use varchar here also.
I know you may want to use
ep end =ep start
when your ep end is balnk.
Hence when it is zero use this
and thats all.Because int is always better to manipulate with numbers.
Hence i will insist on to use int.
- coolpravin
- Forum Newbie
- Posts: 20
- Joined: Mon May 19, 2003 12:56 am
- Location: India
Just replace before echo
Ok.Just try to replace it with blank before echo.
Then now use this one
And this will work well.
Please clarufy is it working or not.?
if suppose thsi is your codeI am listing all the anime, and i get
naruto 1 - 0
instead i want it
naruto 1
Code: Select all
<?php
$start=$row["ep_start"];
$end=$row["ep_end"];
echo"naruto ".$start."-".$end;
?>Code: Select all
<?php
$start=$row["ep_start"];
$end=$row["ep_end"];
if(!$end)
$end="";
echo"naruto ".$start."-".$end;
?>Please clarufy is it working or not.?
hey
i have been thinking how to integrate that code in but i am getting confused
here is my code for displaying anime
It is displaying all my anime titles, so
thinking abuot the code u put, if i put at the top
but as for the rest, i am not sure how to imply that
so the bottom bit
is saying that if ep end equals nothing then put naruto start - end?
or
is it saying that if ep end equals something than 0 then put naruto start -end
Sorry i am just trying to understand
?>
i have been thinking how to integrate that code in but i am getting confused
here is my code for displaying anime
Code: Select all
<?php
$sql = 'SELECT * FROM anime order by Anime_Name' ;
$rs=mysql_query($sql,$db);
$numofrows =mysql_num_rows($rs);
?>
<?php
for ($x = 0; $x <$numofrows; $x++)
{
$row = mysql_fetch_array($rs);
if($x % 2)
{
echo "<tr bgcolor="white">\n";
}
else
{
echo "<tr bgcolor ="green">\n";
}
?>
<td bgcolor="#FFFFCC"><font size="-1"><?php echo $row['Anime_name']; ?></td>
<td><font size="-1"><?php echo $row['Ep_Start']; ?> - <font size="-1"><?php echo $row['EP_End']; ?></td>
<td align="center"><font size="-1"><?php echo $row['Language']; ?></td>
<td align="center"><font size="-1"><?php echo $row['Complete']; ?></td>
<td align="center"><font size="-1"><?php echo $row['Discs']; ?></td>
<td align="center"><font size="-1"><?php echo $row['Formats']; ?></td>
<td align="center"><font size="-1"><?php echo $row['Quality']; ?></td>
<td align="center"><font size="-1"><a href="detail.php?Anime_id=<?php echo $row['Anime_id'];?> ">Info</a></td>
<?php
}
?>thinking abuot the code u put, if i put at the top
Code: Select all
<?php
$start=$row["ep_start"];
$end=$row["ep_end"];
?>so the bottom bit
Code: Select all
<?php
if(!$end)
$end="";
echo"naruto ".$start."-".$end;
?>or
is it saying that if ep end equals something than 0 then put naruto start -end
Sorry i am just trying to understand
?>
- coolpravin
- Forum Newbie
- Posts: 20
- Joined: Mon May 19, 2003 12:56 am
- Location: India
Correct
Yes you are very correct
now just replace your
with
Thats it
now just replace your
Code: Select all
<td><font size="-1"><?php echo $row['Ep_Start']; ?> - <font size="-1"><?php echo $row['EP_End']; ?></td>with
Code: Select all
<td><font size="-1"><?php echo $start ; ?> - <font size="-1"><?php echo $end; ?></td>Thats it
My hosting server is down atm, so i can not test it,
but if i put this
it should work?
Many thanks
?>
but if i put this
Code: Select all
<?php
$sql = 'SELECT * FROM anime order by Anime_Name' ;
$rs=mysql_query($sql,$db);
$numofrows =mysql_num_rows($rs);
?>
<?php
for ($x = 0; $x <$numofrows; $x++)
{
$row = mysql_fetch_array($rs);
$start=$row["Ep_Start"];
$end=$row["EP_End"];
if($x % 2)
{
echo "<tr bgcolor="white">\n";
}
else
{
echo "<tr bgcolor ="white">\n";
}
if(!$end)
$end="";
?>
<td bgcolor="#FFFFCC"><font size="-1"><?php echo $row['Anime_name']; ?></td>
<td><font size="-1"><?php echo $start; ?> - <font size="-1"><?php echo $end; ?></td>
<td align="center"><font size="-1"><?php echo $row['Language']; ?></td>
<td align="center"><font size="-1"><?php echo $row['Complete']; ?></td>
<td align="center"><font size="-1"><?php echo $row['Discs']; ?></td>
<td align="center"><font size="-1"><?php echo $row['Formats']; ?></td>
<td align="center"><font size="-1"><?php echo $row['Quality']; ?></td>
<td align="center"><font size="-1"><a href="detail.php?Anime_id=<?php echo $row['Anime_id'];?> ">Info</a></td>
<?php
}
?>Many thanks
?>
- coolpravin
- Forum Newbie
- Posts: 20
- Joined: Mon May 19, 2003 12:56 am
- Location: India
Just do this
Instead of
use
And In place of
Use
Is it worked?
Code: Select all
<?php
if(!$end)
$end="";
?>Code: Select all
<?php
if($end)
$end=" - ".$end;
else
$end="";
?>Code: Select all
<?php
<td><font size="-1"><?php echo $start; ?> - <font size="-1"><?php echo $end; ?></td>
?>Code: Select all
<?php
<td><font size="-1"><?php echo $start; ?> <?php echo $end; ?></td>
?>