Hi,
Thanks for replying but I dont know whats the problem. I have attached my code. Please have a look
Code:
<?
$db_host = "localhost";
$db_username = "root";
$db_password = "ashwita";
$database = "form";
$link=mysql_connect($db_host,$db_username,$db_password) or die("Could not connect to database");
mysql_select_db($database) or die ("Could not select database");
function show($val)
{
$res=mysql_query("select * from auction_details where auctionid=$_GET[id]");
if(mysql_num_rows($res)>0)
{
$r = mysql_fetch_array($res);
$str=$r['CategoryName'];
$arr=explode(",",$str);
}
foreach($arr as $key)
{
if($key==$val)
{
echo "Checked";
return;
}
}
}
?>
<SCRIPT language=Javascript>
if (top.location != self.location)
{
top.location = self.location.href
}
</SCRIPT>
<SCRIPT language=JAVASCRIPT><!--
function myvoid() {
}
//--></SCRIPT>
<SCRIPT language=JAVASCRIPT><!--
function disableForm(theform)
{
if (document.all || document.getElementById)
{for (i = 0; i < theform.length; i++)
{var tempobj = theform.elements[i];
if (tempobj.type.toLowerCase() == "submit" || tempobj.type.toLowerCase() == "reset")
tempobj.disabled = true;
}
//setTimeout('alert("Your form has been submitted. Notice how the submit and reset buttons were disabled upon submission.")', 2000);
return true;
}
else {//alert("The form has been submitted. But, since you're not using IE 4+ or NS 6, the submit button was not disabled on form submission.");
return false;
}
}
//--></SCRIPT>
<SCRIPT language=JavaScript type=text/javascript>
// -- toggle links //
function toggle( targetId ){
if (document.getElementById){
target = document.getElementById( targetId );
if (target.style.display == "none"){
target.style.display = "";
} else {
target.style.display = "none";
}
}
}
function showDiv( targetId )
{
if (document.getElementById){
target = document.getElementById( targetId );
target.style.display = "";
}
}
function HideDiv( targetId ){
if (document.getElementById){
target = document.getElementById( targetId );
target.style.display = "none";
}
}
</SCRIPT>
<BODY text=#000000 vLink=#0000ff aLink=#daa520 link=#000080 bgColor=white stats="1" style="font-family: Verdana; font-size: 10pt">
<form action="" name="frm">
<TABLE id=Table1 cellSpacing=0 cellPadding=0 width="540" border=0>
<TBODY>
<TR height=1>
<TD height=1></TD></TR>
<TR>
<TD vAlign=top align=middle width=*>
<p align="left"><TR>
<TD vAlign=top align=middle width=*>
<p align="left"><TR><!--Logo-->
<TD vAlign=top align=middle width=* rowSpan=2><p> </p>
<DIV align=center>
<CENTER><!-----main content table----->
<TABLE id=Table6 cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD><!---user content start-->
<CENTER>
<TABLE id=Table1 cellSpacing=0 cellPadding=0 border=0 width="540" bgcolor="#FFFFCC">
<TBODY>
<TR>
<TD colSpan=2>
<table border="0" cellspacing="0" width="100%" id="AutoNumber2">
<tr>
<td width="42%" valign="top">
</td>
<td width="58%">
</td>
</tr>
<tr>
<td width="42%" valign="top"><hr color="#FFFFFF" size="5"></td>
<td width="58%"><hr color="#FFFFFF" size="5"></td>
</tr>
<tr>
<td width="42%" valign="top">
</td>
<td width="58%">
</td>
</tr>
</table>
</TD></TR>
<TR>
<TD colSpan=2><hr color="#FFFFFF" size="5"></TD></TR>
<TR>
<TD colSpan=2><FONT size=2>
<CENTER>
<b>CATEGORIES</b><hr color="#FFFF00" size="1">
<?
$res=mysql_query("select * from auction_details where auctionid=$_GET[id]");
if(mysql_num_rows($res)>0)
{
$r = mysql_fetch_array($res);
$str=$r['CategoryName'];
$arr=explode(",",$str);
foreach($arr as $key)
echo "$key<br>";
}
?>
</CENTER></FONT></TD></TR>
<TR bgColor=#FFFFCC>
<TD colSpan=2>
<p align="justify"><font face="Verdana" size="1">If you are unsure
what to choose...start with the "Web" category for Internet
projects or the "Computer Platforms" category for Windows and
Linux projects.</font><FONT size=1><BR> </FONT></TD></TR>
<TR bgColor=#FFFFCC>
<TD vAlign=top><!--left side-->
<TABLE id=Table2>
<TBODY>
<TR>
<TD width=111 colSpan=2>
<?
//Resultset from database
$resultParent=mysql_query("select * from categories order by catid");
$resultChild=mysql_query("select * from categories order by catid");
$tempResult=mysql_query("select * from categories order by catid");
//Number of rows for parent
$num_rows_parent = mysql_num_rows($resultParent);
//Number of rows for child
$num_rows_child = mysql_num_rows($resultChild);
$count = 0;
$flag = 0;
if ($num_rows_parent){
for($parent=0; $parent<$num_rows_parent;$parent++){
for($child=0; $child<=$parent;$child++){
//setting the resultset position
mysql_data_seek($resultParent, $parent);
mysql_data_seek($resultChild, $child);
//fetching rows from the resultset
$myrowParent = mysql_fetch_row($resultParent);
$myrowChild = mysql_fetch_row($resultChild);
$categoryId = $myrowParent[0];
$categoryName = $myrowParent[1];
//If isSubCategory is 0 in Categories Table, means it's a parent row
if ($myrowParent[2] == 0 && $myrowChild[2] == 0) {
if ($parent != 0) {
?>
</TBODY></TABLE></DIV>
<?
}
if ($count%9 == 0) {
?>
</TD>
<TD width=111 colSpan=2 valign=top>
<?
}
//Printing the parent childs, like Computer Platform, Database
?>
<TABLE id=Table5 cellSpacing=0 cellPadding=0 border=0 width="100%">
<TBODY>
<TR>
<TD vAlign=top noWrap width="100%">
<FONT size=1><INPUT onclick="toggle('<?= $categoryId?>');" type=checkbox <? show("$categoryName"); ?> name='chkCategory<?= $categoryId ?>'></FONT>
<font face="Verdana" size="2"><b><?= $categoryName?> </b></font>
<font face="Verdana" size="1"><A title="more specific" onclick="toggle('<?= $categoryId?>');return false;" href="">(more specific)</A></font><FONT size=1> </FONT>
</TD>
</TR>
</TBODY>
</TABLE>
<DIV class=feature id='<?= $categoryId?>' style="DISPLAY: none">
<TABLE id=Table6>
<TBODY>
<?
$count++;
break;
}
//Printing the child nodes and sub childs, work for every condition
if ($myrowParent[2] == 1 && $myrowParent[3] == $myrowChild[0]) {
$flag = 0;
//providing one more loop to find out the sub-childs of childs to make the childs heading bold
for ($temp=$parent+1;$temp<$num_rows_parent;$temp++){
mysql_data_seek($tempResult, $temp);
$tempRow = mysql_fetch_row($tempResult);
if ($myrowParent[0] == $tempRow[3]){
$flag = 1;
break;
}
}
?>
<TR>
<TD width=111 colSpan=2>
<TABLE id=Table5 cellSpacing=0 cellPadding=0 border=0>
<TBODY>
<TR>
<TD vAlign=top noWrap>
<FONT size=1>
<?
if ($myrowChild[3] != 0) {
?>
<?
}
?>
<INPUT type=checkbox value=ON <? show("$categoryName"); ?> name='chkCategory<?= $categoryId ?>'>
<?
if ($flag == 1) {
?>
<b><?= $categoryName?></b>
<?
}
else {
?>
<?= $categoryName?>
<?
}
?>
</FONT></TD></TR></TBODY></TABLE></TD></TR>
<?
break;
}
}
}
}
?>
</TBODY></TABLE></DIV></TD></TR></TBODY></TABLE>
</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></DIV></TD></TR></table>
<!--end both sides-->
<table border="0" cellspacing="1" width="540" id="AutoNumber1">
<tr>
<td width="50%"> </td>
</tr>
<tr>
<td width="50%">
<table border="0" cellspacing="1" width="100%" id="AutoNumber5">
<tr>
<td width="5%" align="right">
</td>
<td width="95%"> </td>
</tr>
</table>
</td>
</tr>
</table>
<table border="0" cellspacing="1" width="100%" id="AutoNumber1">
<tr>
<td width="50%"> </td>
<td width="50%"> </td>
</tr>
<tr>
<td width="50%">
<p align="right"><FONT face=Verdana>
<input type="hidden" name="step" value="step41">
</FONT></td>
<td width="50%"> </td>
</tr>
</table>
</form>
</BODY></HTML>
If I give
Code:
$resultParent=mysql_query("select * from categories order by catid");
$resultChild=$resultParent;
$tempResult=$resultParent;
then the code doesn't work otherwise works perfectly fine. Please have a look and I would appreciate if you tell me whats the problem. Struglling since last so many hours.
Thanks a ton in advance!!
Best Regards,
Inderpal Singh
Bookmarks