• Problems

    This line enable URL Rewriting . It must be enabled via the RewriteEngine directive! and if your .htaccess file is going to use rewrite rules, you should always include this line. Otherwise, you can’t be sure if its enabled or not. The string “on” is case insensitive.

Reading data from tables of database is a vital process from developing database driven website.
For clear understanding you must have to go through following steps:
STEP1: SELECT THE DATAs YOU WANT TO READ.: THis is done by using SELECT statement statement.

SELECT:
SELECT is the main command you nedd to get information out of a sql database .The basic synatax is extremely simple:
 SELECT field1 , field2 , field3
 FROM table
 WHERE condition ;

That’s no harder than asking your coworker to get you last month’s sales records from the file cabinet in the hallway.

In some cases, you’ll want to ask for entire records instead of picking out individual pieces
of information. This practice is deprecated for very good reasons (it may be slower than
requesting just the data you need, and it can lead to problems if you redesign the table), but
it is still widely used and, therefore, we need to mention it. A whole record is called for by
using the wildcard (asterisk) symbol:

SELECT *
FROM my_table
WHERE ID <= 100;

FOR EXAMPLE:
$result = mysql_query("SELECT * FROM subject");
if (!$result)
{
die("Database query field :".mysql_error());
}
2)FETCHING DATA AS ARRAY : Next step is to fetch data in an array.This is done in the following way.
$row = mysql_fetch_array($result)

The above code store selected data in $row array

2)DISPLAYING SELECTED DATA:IF you have select only one row of data , then it is easy to display.

echo $row['id'];

But if you have select rows of data(i.e more than one row) . You must apply conditional loop:

while ($row = mysql_fetch_array($result)){
echo " <li >".$row['id']."<ul >"; }

No comments:

Post a Comment