SQL PHP HTML ASP JavaScript articles and free scripts to download

Collecting more than one record from table

WE can collect more than one record from a table by using sql query. For example list of all states of USA from the country list. Our table have two columns one is country and other is associated states.

$sql="select state from table_name WHERE state='USA'";

echo "<table>";
foreach ($dbo->query($sql) as $row) {
echo "<tr ><td>$row[state]</td></tr>";
}
echo "</table>";

Let us add some style command to this code like this.

$i=1;
echo "<table class='t1'>";
foreach ($dbo->query($sql) as $row) {$m=$i%2;
echo "<tr class='r$m'><td>$row[state]</td></tr>";
$i=$i+1;}
echo "</table>";


Google+
Post Comment This is for short comments only. Use the forum for more discussions.
Name
Email( not to be displayed)Privacy Policy
1+2=This is to prevent automatic submission by spammers. Please enter the result of the sum as asked



Join Our Email List
Email:  
For Email Newsletters you can trust
HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us

©2000-2014 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer