Dewise 0 Newbie Poster

can someone help check the following code

<SCRIPT type="text/javascript">
<!-- 

<!-- Begin
function Check(chk)
{
if(document.myform.Check_ctr.checked==true){
for (i = 0; i < chk.length; i++)
chk[i].checked = true ;
}else{

for (i = 0; i < chk.length; i++)
chk[i].checked = false ;
}
}

</script>





   </head>
   <body>
      <?php
         extract( $_POST );

         // build SELECT query
         $query = "SELECT" . $select . "FROM writeups";
         // Connect to MySQL
         if ( !( $database = mysql_connect( "localhost",
            "root", "" ) ) )                      
            die( "Could not connect to database </body></html>" );

         // open Products database
         if ( !mysql_select_db( "aaaa", $database ) )
            die( "Could not open products database </body></html>" );

         // query Products database
         if ( !( $result = mysql_query( $query, $database ) ) ) 

         {
            print( "Could not execute query! <br />" );
            die( mysql_error() . "</body></html>" );

         }
         // end if


         mysql_close( $database );
      ?><!-- end PHP script -->
<h3>Search Results</h3>

<form action="" method="post">

      <table width="100%">
              <tr>
                  <td width="5%"><center>S/N</center></td>
                  <td width="20%"><center>Title</center></td>
                  <td width="12%"><center>Category</center></td>
                  <td width="39%"><center>Content</center></td>
                  <td width="19%"><center>Name of Writter</center></td>

                  <td width="5%"><center><input type="checkbox" name="Check_ctr" value="yes"
                           onClick="Check(document.myform.check_list)" /></center></td>
        </tr>
         <?php
            // fetch each record in result set
            for ( $counter = 0; $row = mysql_fetch_row( $result );
               $counter++ )
            {
               // build table to display results
               print( "<tr>" );

               foreach ( $row as $key => $value ) 
                  print( "<td><center>$value</center></td>");


                print("<td><center><input type='checkbox'  name='check_list' value='$title' /></center></td>");

               print( "</tr>" );

            } // end for
         ?><!-- end PHP script -->
      </table>
      <br />Your search yielded <strong>
      <?php print( "$counter" ) ?> results.<br /><br /></strong>

      <input type="submit" value="POST SELECTED TO SITE" name="posttosite" onclick=""/>
<input type="button" value="DISCARD SELECTED" onclick="" />

</form>

i wish to use each checkbox to represent the contents on each row. that is if a checkbox is checked, at the click of the of the submit or delete, the required action is taken on the contents of the row of the checkbox......

can someone help with these?

Be a part of the DaniWeb community

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