i am new in this thread..i like to know all of yours..
i am really need help to use chekbox with retrieved data from database..i dont know how...like inbox in our mail..

Recommended Answers

nothing is clear from your post, at least post your html here, explain exactly what you trying to achieve.
I guess, you trying to set or unset the checkbox in your html with some data fetched from the db.If that's the case, some like below code will help you to …

Jump to Post

#i have try this code for retrieved information from database, everything is ok..and for that case i want to use the id to display the whole of data same as i used <a href="complaint.php"> "this is for example.." but i want that row link to database as an "ID" display …

Jump to Post

All 5 Replies

nothing is clear from your post, at least post your html here, explain exactly what you trying to achieve.
I guess, you trying to set or unset the checkbox in your html with some data fetched from the db.If that's the case, some like below code will help you to do that-

<input type="checkbox" name="chk" id="chk" <? echo $row['columnName'] ==1?'checked':''; ?>  />

where $row comes from your db.
post further if you need any more help with this

<?php
    require_once('auth.php');
?>
<strong>List Of Complaint </strong><br> 

<?php 
$host="localhost"; // Host name 
$username="root"; // Mysql username 
$password=""; // Mysql password 
$db_name="complaint"; // Database name 
$tbl_name="list"; // Table name 

// Connect to server and select databse. 
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB"); 

$login = $_SESSION['SESS_FIRST_NAME'];
$result = mysql_query("SELECT ID, title, date, FROM $tbl_name WHERE login='$login'");

// Count table rows 
$count=mysql_num_rows($result); 
?> 
<table width="500" border="0" cellspacing="1" cellpadding="0"> 
<form name="form1" method="post" action="<? echo $_SERVER['REQUEST_URI']; ?>"> 
<tr> 
<td> 
<table width="717" border="0" cellspacing="1" cellpadding="0"> 


<tr bordercolor="#660066" bgcolor="#666699"> 
<td width="37" align="center"><strong> </strong></td> 
<td width="53" align="center"><strong>Id</strong></td> 
<td width="237" align="center"><strong>Title</strong></td> 
<td width="149" align="center"><strong>Date</strong></td> 
</tr> 
<?php 
while($rows=mysql_fetch_array($result))
{ 
?> 
<tr bgcolor="#FFFFFF"> 
<td align="center"><input name="check<? echo $rows['ID']; ?>" type="checkbox" id="check" value="1" 
<?php if ($rows['ONOFF'] ==1) { echo "checked";} else {} ?> 
></td>
<td align="center"><a href="complaint.php"> <input type="hidden" name="id[]" value="<? echo $rows['ID']; ?>" /><? echo $rows['ID']; ?></a></td>  
<td align="center"><input type="hidden" name="title[]" value="<? echo $rows['ID']; ?>"/><? echo $rows['title']; ?></td> 
<td align="center"><input type="hidden" name="date[]"  value="<? echo $rows['ID']; ?>"/><? echo $rows['date']; ?></td> 

</tr> 
<?php 
} 
?> 
<tr> 
<td height="24" colspan="4" align="center"><input type="submit" name="Submit" value="Submit"></td> 
</tr> 
</table> 
</td> 
</tr> 
</form> 
</table> 

i have try this code for retrieved information from database, everything is ok..and for that case i want to use the id to display the whole of data same as i used <a href="complaint.php"> "this is for example.." but i want that row link to database as an "ID" display for retrieved that row in database..that means the link is the headline to database for that row..#somebody help me....i stuck for this one...

#i have try this code for retrieved information from database, everything is ok..and for that case i want to use the id to display the whole of data same as i used <a href="complaint.php"> "this is for example.." but i want that row link to database as an "ID" display for retrieved that row in database..that means the link is the headline to database for that row..#somebody help me....i stuck for this one...

still not much is clear from this english, i guess you want to set the next page as complaint.php which will show different containts for each link you click, and will show the details for that particular id.
If that's the case, just pass the id also to this link's href like -

<a href="complaint.php?id=<? echo $rows['ID']; ?>">

later on in complaint.php you can get this id as $_GET and use it to fetch the data from the database.
I will comment on few more unnecessary things form your code, below -
<form name="form1" method="post" action="<? echo $_SERVER; ?>"> writing $_SERVER in the action will take the page that, but it will contain the url of the same page, so its not needed really it's fine to have action=''

commented: help me so much +0

still not much is clear from this english, i guess you want to set the next page as complaint.php which will show different containts for each link you click, and will show the details for that particular id.
If that's the case, just pass the id also to this link's href like -

<a href="complaint.php?id=<? echo $rows['ID']; ?>">

later on in complaint.php you can get this id as $_GET and use it to fetch the data from the database.
I will comment on few more unnecessary things form your code, below -
<form name="form1" method="post" action="<? echo $_SERVER; ?>"> writing $_SERVER in the action will take the page that, but it will contain the url of the same page, so its not needed really it's fine to have action=''

Thanks for ur help..i don't know how to explain..but u really understand..thank u..

:)have a good time

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.