Page 1 of 1
which datatype?
Posted: Mon May 26, 2003 3:10 am
by jamrop
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
But why to change
Posted: Mon May 26, 2003 4:11 am
by coolpravin
But why youi want to change that man !!!!!
You can consider this 0 as blank.
Hence whenever you find it 0 consider it 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.

Posted: Mon May 26, 2003 4:21 am
by jamrop
ok thanks for that, but how would i stop it from showing 0 in php
I am listing all the anime, and i get
naruto 1 - 0
instead i want it
naruto 1
many thanks
Just replace before echo
Posted: Mon May 26, 2003 4:28 am
by coolpravin
Ok.Just try to replace it with blank before echo.
I am listing all the anime, and i get
naruto 1 - 0
instead i want it
naruto 1
if suppose thsi is your code
Code: Select all
<?php
$start=$row["ep_start"];
$end=$row["ep_end"];
echo"naruto ".$start."-".$end;
?>
Then now use this one
Code: Select all
<?php
$start=$row["ep_start"];
$end=$row["ep_end"];
if(!$end)
$end="";
echo"naruto ".$start."-".$end;
?>
And this will work well.
Please clarufy is it working or not.?
Posted: Mon May 26, 2003 5:02 am
by jamrop
hey
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
}
?>
It is displaying all my anime titles, so
thinking abuot the code u put, if i put at the top
Code: Select all
<?php
$start=$row["ep_start"];
$end=$row["ep_end"];
?>
but as for the rest, i am not sure how to imply that
so the bottom bit
Code: Select all
<?php
if(!$end)
$end="";
echo"naruto ".$start."-".$end;
?>
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
?>
Correct
Posted: Mon May 26, 2003 5:08 am
by coolpravin
Yes you are very correct
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
Posted: Mon May 26, 2003 5:14 am
by jamrop
My hosting server is down atm, so i can not test it,
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
}
?>
it should work?
Many thanks
?>
Posted: Tue May 27, 2003 6:59 am
by jamrop
Thanks
For worked gr8
Just one thing tho
what if i wanted
if they is an ep end
naruto 1 - 2
if there is no ep end
and i wanted just
naruto 1
not having the -
How would i stop that from displaying?
many thanks
Just do this
Posted: Tue May 27, 2003 7:17 am
by coolpravin
Instead of
use
Code: Select all
<?php
if($end)
$end=" - ".$end;
else
$end="";
?>
And In place of
Code: Select all
<?php
<td><font size="-1"><?php echo $start; ?> - <font size="-1"><?php echo $end; ?></td>
?>
Use
Code: Select all
<?php
<td><font size="-1"><?php echo $start; ?> <?php echo $end; ?></td>
?>
Is it worked?
Posted: Tue May 27, 2003 5:58 pm
by jamrop
thanking you