Forum Moderators: coopster

Message Too Old, No Replies

how to see all records in my browser?

all,records,togather

         

aamir vaheed

1:54 am on Aug 29, 2005 (gmt 0)

10+ Year Member



hi
i want to know how can i see all my records in my ie browser?
i have put these codes in my search form but only one record is displayed:
<html>
<body>

<?php
// listing script

// connect to the server
mysql_connect( 'localhost', 'aamir', 'abc' )
or die( "Error! Could not connect to database: " . mysql_error() );

// select the database
mysql_select_db( 'mkats' )
or die( "Error! Could not select the database: " . mysql_error() );

// get the id from the URL request
$id = $_REQUEST['id'];

// retrieve the row from the database
$query = "SELECT * FROM `tajneed` WHERE `first_name` LIKE '$id'";

$result = mysql_query( $query );

// print out the results
if( $result && $tajneed = mysql_fetch_object( $result ) )
{
// print out the info
$firstName = $tajneed -> first_name;
$lastName = $tajneed -> last_name;
$fname = $tajneed -> father_name;
$dob = $tajneed -> dob;
$hno = $tajneed -> house_no;
$bno = $tajneed -> block_no;
$sector = $tajneed -> sector;
$phh = $tajneed -> phone_home;
$phm = $tajneed -> mobile_no;
$bg = $tajneed -> blood_group;
$education = $tajneed -> education;
$mstat = $tajneed -> m_status;
$will = $tajneed -> will_no;
$ned = $tajneed -> noor;
$wa = $tajneed -> work_address;
$wt = $tajneed -> work_type;
$phw1 = $tajneed -> work_phone1;
$phw2 = $tajneed -> work_phone2;
$sc = $tajneed -> school_college;
$email = $tajneed -> email;
$salary = $tajneed -> salary_pm;
?>

<table border="1" cellpadding="3" cellspacing="3">
<tr>
<th align="left">First Name</th>
<td align="left"><?php echo ucwords($firstName)?></td>
</tr>
<tr>
<th align="left">Last Name</th>
<td align="left">
<?php echo ucwords($lastName)?>
</td>
</tr>
<tr>
<th align="left">Fathers Name</th>
<td align="left">
<?php echo ucwords($fname)?>
</td>
</tr>
</table>
<?php
}
else
{
die( "Error: Value can not found in database! ".mysql_error() );
}

?>

</body>
</html>

omoutop

5:06 am on Aug 29, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



hi!

Welcome to webmasterworld!
it is logical to get only one record that way, in order to get all records you must do a while loop which is very simple..do you know how to do a while loop?

dreamcatcher

10:42 am on Aug 29, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As omoutop mentioned you need a loop.

Try changing this line:

if( $result && $tajneed = mysql_fetch_object( $result ) )

to this:

while ($tajneed = mysql_fetch_object( $result ) )

dc

aamir vaheed

1:01 am on Sep 3, 2005 (gmt 0)

10+ Year Member



hi
thank you very much, the prob is solved now.
thanks a lot.
best regards
aamir