Reply
please check this php coding..
Old 05-09-2007, 02:58 AM please check this php coding..
Novice Talker

Posts: 12
below are the php coding that i used to display a data in the table form..
what i want to do is the number which is .$row['number']. will be automatically increment when there is a new data in the table..
how to do it by using loop...

<?php

$query="SELECT * FROM asset";
$result = mysql_query($query);
if (!$result)
echo "<h3>Cannot Process Query</h3>";
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{

echo "<tr>";
echo "<td class=style6>".$row['number']."</td>";
echo "<td class=style6>".$row['unit']."</td>";
echo "<td class=style6>".$row['asset']."</td>";
echo "<td class=style6>".$row['quantity']."</td>";
echo "</tr>";
}
}
?>
blue_meteor is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 05-09-2007, 03:40 AM Re: please check this php coding..
Average Talker

Posts: 29
Name: Amit Soni
<?php
$i=0; // Or start from 1 if you prefer.
$query="SELECT * FROM asset";
$result = mysql_query($query);
if (!$result) {echo "<h3>Cannot Process Query</h3>";}
while ($row = mysql_fetch_assoc($result)
{
echo "<tr>";
echo "<td class=style6>".$i++."</td>"; //Is this what you wanted ??
foreach ($row as $key => $value)
{
echo "<td class=style6>$value</td>";
}
echo "</tr>";
}
?>

Last edited by Zitku : 05-09-2007 at 03:41 AM. Reason: forgot to initialize $i.
Zitku is offline
Reply With Quote
View Public Profile Visit Zitku's homepage!
 
Old 05-09-2007, 08:20 AM Re: please check this php coding..
Skilled Talker

Posts: 60
Name: bilton
how about autoincrement the 'number' field of asset table while creating the table. If not the above method should wrk
bil
niceguy_81333 is offline
Reply With Quote
View Public Profile
 
Old 05-09-2007, 09:29 AM Re: please check this php coding..
jito's Avatar
MY LIFE IS 'i' LIFE

Posts: 551
Name: surajit ray
Location: inside the heart of my friends
I think amit is right and he is talking about the html table.
__________________
Think+, work +, but not HIV + :)
jito is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to please check this php coding..
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.13196 seconds with 12 queries