problem regarding for rech loop
Posted by: renuka masih
Date: December 09, 2012 11:45PM
Date: December 09, 2012 11:45PM
Hi,
I am using foreach loop to retrieve particular information from database.But it iterate single record 14 time.Can anyone help me.Below is the code.
<?php
$conn = odbc_connect('','','');
if ($conn)
{
//the SQL statement that will query the database
$result= odbc_exec($conn,"select * from tab_advertisementservices");
$count=odbc_num_rows($result);
echo "$count";
if ( $count )
{
while( $rows = odbc_fetch_array( $result))
{
foreach ($rows as $row)
{
echo "<h3>".$rows['companyname']."</h3>";
echo '</br>';
echo "<b>Contact Number : </b> ".$rows['call'];
echo '</br>';
echo "<b>Address : </b>".$rows['Address'];
echo '</br>';
echo "<b>Contact Person : </b> ".$rows['contactperson'];
echo '</br>';
echo "<b>Email ID : </b>".$rows['email'];
echo '</br>';
echo "<b>Website : </b> ".$rows['website'];
echo '</br>';
echo "<b>Additional Information : </b> \n ".$rows['detail'];
}
}
//close the connection
odbc_close ($conn);
}
else
echo "No record found";
}
else echo "server not connected";
?>
getting output as follows:
asdasd
Contact Number : sdfsdf
Address : sdfsdfsdf
Contact Person : dfsdf
Email ID : sdfsdf
Website :
Additional Information :
asdasd
Contact Number : sdfsdf
Address : sdfsdfsdf
Contact Person : dfsdf
Email ID : sdfsdf
Website :
Additional Information :
asdasd
Contact Number : sdfsdf
Address : sdfsdfsdf
Contact Person : dfsdf
Email ID : sdfsdf
Website :
Additional Information :
asdasd
Contact Number : sdfsdf
Address : sdfsdfsdf
Contact Person : dfsdf
Email ID : sdfsdf
Website :
Additional Information :
asdasd
Contact Number : sdfsdf
Address : sdfsdfsdf
Contact Person : dfsdf
Email ID : sdfsdf
Website :
Additional Information :
asdasd
Contact Number : sdfsdf
Address : sdfsdfsdf
Contact Person : dfsdf
Email ID : sdfsdf
Website :
Additional Information :
asdasd
Contact Number : sdfsdf
Address : sdfsdfsdf
Contact Person : dfsdf
Email ID : sdfsdf
Website :
Additional Information :
asdasd
Contact Number : sdfsdf
Address : sdfsdfsdf
Contact Person : dfsdf
Email ID : sdfsdf
Website :
Additional Information :
AGRAWAL CONSTRUCTION CO.
Contact Number : (0755) 2576220, 4077790
Address : BUILDERS, PROMOTERS & COLONIZERS ) SAGAR PLAZA, 250, ZONE-II, M.P. NAGAR, BHOPAL - 462011
Contact Person : Mr. Manish Agrawal
Email ID : agrawalconstruction@rediffmail.com
Website : www.agrawalconstruction.com
Additional Information : Welcome to the City of Lakes BHOPAL.
AGRAWAL CONSTRUCTION CO.
Contact Number : (0755) 2576220, 4077790
Address : BUILDERS, PROMOTERS & COLONIZERS ) SAGAR PLAZA, 250, ZONE-II, M.P. NAGAR, BHOPAL - 462011
Contact Person : Mr. Manish Agrawal
Email ID : agrawalconstruction@rediffmail.com
Website : www.agrawalconstruction.com
Additional Information : Welcome to the City of Lakes BHOPAL.
AGRAWAL CONSTRUCTION CO.
Contact Number : (0755) 2576220, 4077790
Address : BUILDERS, PROMOTERS & COLONIZERS ) SAGAR PLAZA, 250, ZONE-II, M.P. NAGAR, BHOPAL - 462011
Contact Person : Mr. Manish Agrawal
Email ID : agrawalconstruction@rediffmail.com
Website : www.agrawalconstruction.com
Additional Information : Welcome to the City of Lakes BHOPAL.
AGRAWAL CONSTRUCTION CO.
Contact Number : (0755) 2576220, 4077790
Address : BUILDERS, PROMOTERS & COLONIZERS ) SAGAR PLAZA, 250, ZONE-II, M.P. NAGAR, BHOPAL - 462011
Contact Person : Mr. Manish Agrawal
Email ID : agrawalconstruction@rediffmail.com
Website : www.agrawalconstruction.com
Additional Information : Welcome to the City of Lakes BHOPAL.
AGRAWAL CONSTRUCTION CO.
Contact Number : (0755) 2576220, 4077790
Address : BUILDERS, PROMOTERS & COLONIZERS ) SAGAR PLAZA, 250, ZONE-II, M.P. NAGAR, BHOPAL - 462011
Contact Person : Mr. Manish Agrawal
Email ID : agrawalconstruction@rediffmail.com
Website : www.agrawalconstruction.com
Additional Information : Welcome to the City of Lakes BHOPAL.
AGRAWAL CONSTRUCTION CO.
Contact Number : (0755) 2576220, 4077790
Address : BUILDERS, PROMOTERS & COLONIZERS ) SAGAR PLAZA, 250, ZONE-II, M.P. NAGAR, BHOPAL - 462011
Contact Person : Mr. Manish Agrawal
Email ID : agrawalconstruction@rediffmail.com
Website : www.agrawalconstruction.com
Additional Information : Welcome to the City of Lakes BHOPAL.
AGRAWAL CONSTRUCTION CO.
Contact Number : (0755) 2576220, 4077790
Address : BUILDERS, PROMOTERS & COLONIZERS ) SAGAR PLAZA, 250, ZONE-II, M.P. NAGAR, BHOPAL - 462011
Contact Person : Mr. Manish Agrawal
Email ID : agrawalconstruction@rediffmail.com
Website : www.agrawalconstruction.com
Additional Information : Welcome to the City of Lakes BHOPAL.
AGRAWAL CONSTRUCTION CO.
Contact Number : (0755) 2576220, 4077790
Address : BUILDERS, PROMOTERS & COLONIZERS ) SAGAR PLAZA, 250, ZONE-II, M.P. NAGAR, BHOPAL - 462011
Contact Person : Mr. Manish Agrawal
Email ID : agrawalconstruction@rediffmail.com
Website : www.agrawalconstruction.com
Additional Information : Welcome to the City of Lakes BHOPAL.
AGRAWAL CONSTRUCTION CO.
Contact Number : (0755) 2576220, 4077790
Address : BUILDERS, PROMOTERS & COLONIZERS ) SAGAR PLAZA, 250, ZONE-II, M.P. NAGAR, BHOPAL - 462011
Contact Person : Mr. Manish Agrawal
Email ID : agrawalconstruction@rediffmail.com
Website : www.agrawalconstruction.com
Additional Information : Welcome to the City of Lakes BHOPAL.
AGRAWAL CONSTRUCTION CO.
Contact Number : (0755) 2576220, 4077790
Address : BUILDERS, PROMOTERS & COLONIZERS ) SAGAR PLAZA, 250, ZONE-II, M.P. NAGAR, BHOPAL - 462011
Contact Person : Mr. Manish Agrawal
Email ID : agrawalconstruction@rediffmail.com
Website : www.agrawalconstruction.com
Additional Information : Welcome to the City of Lakes BHOPAL.
AGRAWAL CONSTRUCTION CO.
Contact Number : (0755) 2576220, 4077790
Address : BUILDERS, PROMOTERS & COLONIZERS ) SAGAR PLAZA, 250, ZONE-II, M.P. NAGAR, BHOPAL - 462011
Contact Person : Mr. Manish Agrawal
Email ID : agrawalconstruction@rediffmail.com
Website : www.agrawalconstruction.com
Additional Information : Welcome to the City of Lakes BHOPAL.
AGRAWAL CONSTRUCTION CO.
Contact Number : (0755) 2576220, 4077790
Address : BUILDERS, PROMOTERS & COLONIZERS ) SAGAR PLAZA, 250, ZONE-II, M.P. NAGAR, BHOPAL - 462011
Contact Person : Mr. Manish Agrawal
Email ID : agrawalconstruction@rediffmail.com
Website : www.agrawalconstruction.com
Additional Information : Welcome to the City of Lakes BHOPAL.
AGRAWAL CONSTRUCTION CO.
Contact Number : (0755) 2576220, 4077790
Address : BUILDERS, PROMOTERS & COLONIZERS ) SAGAR PLAZA, 250, ZONE-II, M.P. NAGAR, BHOPAL - 462011
Contact Person : Mr. Manish Agrawal
Email ID : agrawalconstruction@rediffmail.com
Website : www.agrawalconstruction.com
Additional Information : Welcome to the City of Lakes BHOPAL.
AGRAWAL CONSTRUCTION CO.
Contact Number : (0755) 2576220, 4077790
Address : BUILDERS, PROMOTERS & COLONIZERS ) SAGAR PLAZA, 250, ZONE-II, M.P. NAGAR, BHOPAL - 462011
Contact Person : Mr. Manish Agrawal
Email ID : agrawalconstruction@rediffmail.com
Website : www.agrawalconstruction.com
Additional Information : Welcome to the City of Lakes BHOPAL.
AGRAWAL CONSTRUCTION CO.
Contact Number : (0755) 2576220, 4077790
Address : BUILDERS, PROMOTERS & COLONIZERS ) SAGAR PLAZA, 250, ZONE-II, M.P. NAGAR, BHOPAL - 462011
Contact Person : Mr. Manish Agrawal
Email ID : agrawalconstruction@rediffmail.com
Website : www.agrawalconstruction.com
Additional Information : Welcome to the City of Lakes BHOPAL.
AGRAWAL CONSTRUCTION CO.
Contact Number : (0755) 2576220, 4077790
Address : BUILDERS, PROMOTERS & COLONIZERS ) SAGAR PLAZA, 250, ZONE-II, M.P. NAGAR, BHOPAL - 462011
Contact Person : Mr. Manish Agrawal
Email ID : agrawalconstruction@rediffmail.com
Website : www.agrawalconstruction.com
Additional Information : Welcome to the City of Lakes BHOPAL.
I am using foreach loop to retrieve particular information from database.But it iterate single record 14 time.Can anyone help me.Below is the code.
<?php
$conn = odbc_connect('','','');
if ($conn)
{
//the SQL statement that will query the database
$result= odbc_exec($conn,"select * from tab_advertisementservices");
$count=odbc_num_rows($result);
echo "$count";
if ( $count )
{
while( $rows = odbc_fetch_array( $result))
{
foreach ($rows as $row)
{
echo "<h3>".$rows['companyname']."</h3>";
echo '</br>';
echo "<b>Contact Number : </b> ".$rows['call'];
echo '</br>';
echo "<b>Address : </b>".$rows['Address'];
echo '</br>';
echo "<b>Contact Person : </b> ".$rows['contactperson'];
echo '</br>';
echo "<b>Email ID : </b>".$rows['email'];
echo '</br>';
echo "<b>Website : </b> ".$rows['website'];
echo '</br>';
echo "<b>Additional Information : </b> \n ".$rows['detail'];
}
}
//close the connection
odbc_close ($conn);
}
else
echo "No record found";
}
else echo "server not connected";
?>
getting output as follows:
asdasd
Contact Number : sdfsdf
Address : sdfsdfsdf
Contact Person : dfsdf
Email ID : sdfsdf
Website :
Additional Information :
asdasd
Contact Number : sdfsdf
Address : sdfsdfsdf
Contact Person : dfsdf
Email ID : sdfsdf
Website :
Additional Information :
asdasd
Contact Number : sdfsdf
Address : sdfsdfsdf
Contact Person : dfsdf
Email ID : sdfsdf
Website :
Additional Information :
asdasd
Contact Number : sdfsdf
Address : sdfsdfsdf
Contact Person : dfsdf
Email ID : sdfsdf
Website :
Additional Information :
asdasd
Contact Number : sdfsdf
Address : sdfsdfsdf
Contact Person : dfsdf
Email ID : sdfsdf
Website :
Additional Information :
asdasd
Contact Number : sdfsdf
Address : sdfsdfsdf
Contact Person : dfsdf
Email ID : sdfsdf
Website :
Additional Information :
asdasd
Contact Number : sdfsdf
Address : sdfsdfsdf
Contact Person : dfsdf
Email ID : sdfsdf
Website :
Additional Information :
asdasd
Contact Number : sdfsdf
Address : sdfsdfsdf
Contact Person : dfsdf
Email ID : sdfsdf
Website :
Additional Information :
AGRAWAL CONSTRUCTION CO.
Contact Number : (0755) 2576220, 4077790
Address : BUILDERS, PROMOTERS & COLONIZERS ) SAGAR PLAZA, 250, ZONE-II, M.P. NAGAR, BHOPAL - 462011
Contact Person : Mr. Manish Agrawal
Email ID : agrawalconstruction@rediffmail.com
Website : www.agrawalconstruction.com
Additional Information : Welcome to the City of Lakes BHOPAL.
AGRAWAL CONSTRUCTION CO.
Contact Number : (0755) 2576220, 4077790
Address : BUILDERS, PROMOTERS & COLONIZERS ) SAGAR PLAZA, 250, ZONE-II, M.P. NAGAR, BHOPAL - 462011
Contact Person : Mr. Manish Agrawal
Email ID : agrawalconstruction@rediffmail.com
Website : www.agrawalconstruction.com
Additional Information : Welcome to the City of Lakes BHOPAL.
AGRAWAL CONSTRUCTION CO.
Contact Number : (0755) 2576220, 4077790
Address : BUILDERS, PROMOTERS & COLONIZERS ) SAGAR PLAZA, 250, ZONE-II, M.P. NAGAR, BHOPAL - 462011
Contact Person : Mr. Manish Agrawal
Email ID : agrawalconstruction@rediffmail.com
Website : www.agrawalconstruction.com
Additional Information : Welcome to the City of Lakes BHOPAL.
AGRAWAL CONSTRUCTION CO.
Contact Number : (0755) 2576220, 4077790
Address : BUILDERS, PROMOTERS & COLONIZERS ) SAGAR PLAZA, 250, ZONE-II, M.P. NAGAR, BHOPAL - 462011
Contact Person : Mr. Manish Agrawal
Email ID : agrawalconstruction@rediffmail.com
Website : www.agrawalconstruction.com
Additional Information : Welcome to the City of Lakes BHOPAL.
AGRAWAL CONSTRUCTION CO.
Contact Number : (0755) 2576220, 4077790
Address : BUILDERS, PROMOTERS & COLONIZERS ) SAGAR PLAZA, 250, ZONE-II, M.P. NAGAR, BHOPAL - 462011
Contact Person : Mr. Manish Agrawal
Email ID : agrawalconstruction@rediffmail.com
Website : www.agrawalconstruction.com
Additional Information : Welcome to the City of Lakes BHOPAL.
AGRAWAL CONSTRUCTION CO.
Contact Number : (0755) 2576220, 4077790
Address : BUILDERS, PROMOTERS & COLONIZERS ) SAGAR PLAZA, 250, ZONE-II, M.P. NAGAR, BHOPAL - 462011
Contact Person : Mr. Manish Agrawal
Email ID : agrawalconstruction@rediffmail.com
Website : www.agrawalconstruction.com
Additional Information : Welcome to the City of Lakes BHOPAL.
AGRAWAL CONSTRUCTION CO.
Contact Number : (0755) 2576220, 4077790
Address : BUILDERS, PROMOTERS & COLONIZERS ) SAGAR PLAZA, 250, ZONE-II, M.P. NAGAR, BHOPAL - 462011
Contact Person : Mr. Manish Agrawal
Email ID : agrawalconstruction@rediffmail.com
Website : www.agrawalconstruction.com
Additional Information : Welcome to the City of Lakes BHOPAL.
AGRAWAL CONSTRUCTION CO.
Contact Number : (0755) 2576220, 4077790
Address : BUILDERS, PROMOTERS & COLONIZERS ) SAGAR PLAZA, 250, ZONE-II, M.P. NAGAR, BHOPAL - 462011
Contact Person : Mr. Manish Agrawal
Email ID : agrawalconstruction@rediffmail.com
Website : www.agrawalconstruction.com
Additional Information : Welcome to the City of Lakes BHOPAL.
AGRAWAL CONSTRUCTION CO.
Contact Number : (0755) 2576220, 4077790
Address : BUILDERS, PROMOTERS & COLONIZERS ) SAGAR PLAZA, 250, ZONE-II, M.P. NAGAR, BHOPAL - 462011
Contact Person : Mr. Manish Agrawal
Email ID : agrawalconstruction@rediffmail.com
Website : www.agrawalconstruction.com
Additional Information : Welcome to the City of Lakes BHOPAL.
AGRAWAL CONSTRUCTION CO.
Contact Number : (0755) 2576220, 4077790
Address : BUILDERS, PROMOTERS & COLONIZERS ) SAGAR PLAZA, 250, ZONE-II, M.P. NAGAR, BHOPAL - 462011
Contact Person : Mr. Manish Agrawal
Email ID : agrawalconstruction@rediffmail.com
Website : www.agrawalconstruction.com
Additional Information : Welcome to the City of Lakes BHOPAL.
AGRAWAL CONSTRUCTION CO.
Contact Number : (0755) 2576220, 4077790
Address : BUILDERS, PROMOTERS & COLONIZERS ) SAGAR PLAZA, 250, ZONE-II, M.P. NAGAR, BHOPAL - 462011
Contact Person : Mr. Manish Agrawal
Email ID : agrawalconstruction@rediffmail.com
Website : www.agrawalconstruction.com
Additional Information : Welcome to the City of Lakes BHOPAL.
AGRAWAL CONSTRUCTION CO.
Contact Number : (0755) 2576220, 4077790
Address : BUILDERS, PROMOTERS & COLONIZERS ) SAGAR PLAZA, 250, ZONE-II, M.P. NAGAR, BHOPAL - 462011
Contact Person : Mr. Manish Agrawal
Email ID : agrawalconstruction@rediffmail.com
Website : www.agrawalconstruction.com
Additional Information : Welcome to the City of Lakes BHOPAL.
AGRAWAL CONSTRUCTION CO.
Contact Number : (0755) 2576220, 4077790
Address : BUILDERS, PROMOTERS & COLONIZERS ) SAGAR PLAZA, 250, ZONE-II, M.P. NAGAR, BHOPAL - 462011
Contact Person : Mr. Manish Agrawal
Email ID : agrawalconstruction@rediffmail.com
Website : www.agrawalconstruction.com
Additional Information : Welcome to the City of Lakes BHOPAL.
AGRAWAL CONSTRUCTION CO.
Contact Number : (0755) 2576220, 4077790
Address : BUILDERS, PROMOTERS & COLONIZERS ) SAGAR PLAZA, 250, ZONE-II, M.P. NAGAR, BHOPAL - 462011
Contact Person : Mr. Manish Agrawal
Email ID : agrawalconstruction@rediffmail.com
Website : www.agrawalconstruction.com
Additional Information : Welcome to the City of Lakes BHOPAL.
AGRAWAL CONSTRUCTION CO.
Contact Number : (0755) 2576220, 4077790
Address : BUILDERS, PROMOTERS & COLONIZERS ) SAGAR PLAZA, 250, ZONE-II, M.P. NAGAR, BHOPAL - 462011
Contact Person : Mr. Manish Agrawal
Email ID : agrawalconstruction@rediffmail.com
Website : www.agrawalconstruction.com
Additional Information : Welcome to the City of Lakes BHOPAL.
AGRAWAL CONSTRUCTION CO.
Contact Number : (0755) 2576220, 4077790
Address : BUILDERS, PROMOTERS & COLONIZERS ) SAGAR PLAZA, 250, ZONE-II, M.P. NAGAR, BHOPAL - 462011
Contact Person : Mr. Manish Agrawal
Email ID : agrawalconstruction@rediffmail.com
Website : www.agrawalconstruction.com
Additional Information : Welcome to the City of Lakes BHOPAL.
Subject
Written By
Posted
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.