rukshilag 0 Junior Poster

exactly.

i sent u my code above. but that doesnt work. it seems to divide off numbers, say array[2,4,6], it comes as 1,1 2,2 3,3, doesnt divide the array only the integers one by one

rukshilag 0 Junior Poster

Partition Problem
“The problem is to decide whether a given multiset of integers can be partitioned into two "halves" that have the same sum. More precisely, given a multiset S of integers, is there a way to partition S into two subsets S1 and S2 such that the sums of the numbers in each subset are equal? The subsets S1 and S2 must form a partition in the sense that they are disjoint and they cover S.”

what i need fr my code to do is
solve the partition problem
Given a set of numbers on the command line
It should check whether a solution exists and if so print the two sets

rukshilag 0 Junior Poster

i showd u waht i have done so far.

let me give u a clearer picture of the problem

http://en.wikipedia.org/wiki/Partition_problem

rukshilag 0 Junior Poster

i need Given a set of numbers on the command line (partition an array)
It should check whether a solution exists and if so print the two sets

upto now the code i have seems to parttion each integer, what i need is for it to partition the array as a whole, for example lets take the array[1,2,3] this can be divided as [1,2] and [3], we can see that these two subsets have an equal sum.

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication2;

import java.util.ArrayList;
import java.util.Collection;

public class Partition {
    private static int arrayNumber = 0;
    private static Collection<Integer> s1 = new ArrayList<Integer>();
    private static Collection<Integer> s2 = new ArrayList<Integer>();

    public static void partition(int n) {
        partition(n, n, "");
    }
    
    public static void partition(int n, int max, String prefix) {
        if (n == 0) {
            arrayNumber++;
            String[] s = prefix.split(" ");
            if (arrayNumber == 2) {
                addtoArray(s, s1);
            } else if(arrayNumber == 3) {
                addtoArray(s, s2);
            }
            //System.out.println("--------------");
            //System.out.println(prefix);

            return;
        }

        for (int i = Math.min(max, n); i >= 1; i--) {
            partition(n-i, i, prefix + " " + i);
        }
    }

    private static void addtoArray(String s[], Collection<Integer> col) {
        for (int i = 0; i < s.length; i++) {
            String numStr = s[i];
            if (numStr.equals("")) {
                continue;
            }
            int num = Integer.parseInt(numStr);
            col.add(num);
        }
    }


    public static void main(String[] args1) {
        String[] args = {"6", "2", "4"};

        for (int i = 0; i < args.length; i++) {
            arrayNumber = 0;
            String str = args[i];
            int n = Integer.parseInt(str);
            partition(n);
        } …
rukshilag 0 Junior Poster

ive been coding the plain old procedural way in php and i want to move that code to object oriented.
can i just simply use my currently written php code into a function and then call it?


pleas let me know an easy way to make my normal php code into object oriented?

rukshilag 0 Junior Poster

This is a table customization in a search form.
I need the ticked checkbox values to be passed to the pdf.php in order for the table to be customized. but the table is not filled nor is it customised.

<?php
//access incoming name, id or radio button values
$cs = $_GET['cs'];
$name=$_GET['name'];
$uni=$_GET['uni'];
$dept=$_GET['dept'];
$course=$_GET['course'];
$cd=$_GET['course_date'];
$gen=$_GET['gen'];
$sf=$_GET['selectfields'];
$title=$_GET['title'];

$con=mysql_connect("localhost", "root", "") or die ("couldnt connect");
mysql_select_db("sdc_cpds") or die ("couldnt select");

//search query

$searchquery="SELECT * FROM course_participant WHERE name LIKE '%$name%' AND gender LIKE '$gen%' AND university LIKE '%$uni%' AND facdept LIKE '%$dept%'  AND course LIKE '%$course%' AND course_date LIKE '%$cd%' AND completion LIKE '%$cs%' UNION SELECT * FROM past_participant WHERE name LIKE '%$name%' AND gender LIKE '%$gen%' AND university LIKE '%$uni%' AND facdept LIKE '%$dept%'  AND course LIKE '%$course%' AND course_date LIKE '%$cd%' AND completion LIKE '%$cs%' ORDER BY name";

$result=mysql_query($searchquery);
$num_rows=mysql_num_rows($result);

echo "<b>$num_rows</b> results found<br>"; 
//echo "<INPUT TYPE='image' SRC='http://localhost/drupal/printwebpagepdf.gif' OnClick='clickPrint()'>";
//display results(search results table)
if($num_rows >0) {

echo "<div style='width:620px; height:100%;'>";
echo "<table border='2' width='100%' id='blutable'>";
echo "<tr style='background-color:#A9D0F5'><th></th><th>Name</th><th>Address</th><th>Contact No</th><th>Email</th><th>Gender</th><th>Age</th><th>Marital Status</th><th>University</th><th>Fac/Dept</th><th>Course</th><th>Course Date</th><th>Reg. Date</th><th>Completion</th></tr>";

$i=1;

while($row = mysql_fetch_array($result)) {

$r = fmod($i,2);
if($r=="1"){
$rowclass="odd";
}
else{
$rowclass="even";
}

echo "<tr class='$rowclass'>";
//echo "<td><input type='submit' value='EDIT' onclick='editer($i)' style='width:50px; height:25px background;'/></td>";

echo "<td style='padding:1px;' valign='bottom'><INPUT TYPE='image' SRC='http://localhost/drupal/more.png' onclick='editer($i)' style='width:25px; height:25px;'/></td>";


 echo "<td nowrap><div id='cpid_$i'>";echo $row['name'];"</div></td>";
 //echo "<td><div id='cpid_$i'>";echo $row['nic'];echo "</div></td>";
 echo "<td nowrap>";echo $row['res_address'];echo "</td>";
 echo "<td>";echo $row['cont_no'];echo "</td>";
 echo "<td>";echo $row['email'];echo "</td>";
 echo "<td>";echo $row['gender'];echo "</td>";
 echo "<td>";echo $row['age'];echo "</td>";
 echo "<td>";echo $row['marital_stat'];echo "</td>";
 echo …
rukshilag 0 Junior Poster

i mean. thiis code is for creating a pdf based on a search criteria. when something is searched, based on the criteria, the entire table's fields are displayed. but when priniting something like a report we dont need all fields. user will need particular fields only, for example only name and address etc.

but when i press customise and print even tho the pdf opens its blank, how do i get that customized table to be displayed on the pdf?

for customization, once search results are displayed below is a box for customizing with checkboxes to choose what fields are needed.

please help.

rukshilag 0 Junior Poster

Im trying to customise search fields and then display in a pdf but the code just doesnt work. can someone take a look and see why exactly this is not working? if u see any mistakes?

<?php
//access incoming name, id or radio button values
$cs = $_GET['cs'];
$name=$_GET['name'];
$uni=$_GET['uni'];
$dept=$_GET['dept'];
$course=$_GET['course'];
$cd=$_GET['course_date'];
$gen=$_GET['gen'];
$sf=$_GET['selectfields'];
$title=$_GET['title'];

$con=mysql_connect("localhost", "root", "") or die ("couldnt connect");
mysql_select_db("sdc_cpds") or die ("couldnt select");

//search query

$searchquery="SELECT * FROM course_participant WHERE name LIKE '%$name%' AND gender LIKE '$gen%' AND university LIKE '%$uni%' AND facdept LIKE '%$dept%'  AND course LIKE '%$course%' AND course_date LIKE '%$cd%' AND completion LIKE '%$cs%' UNION SELECT * FROM past_participant WHERE name LIKE '%$name%' AND gender LIKE '%$gen%' AND university LIKE '%$uni%' AND facdept LIKE '%$dept%'  AND course LIKE '%$course%' AND course_date LIKE '%$cd%' AND completion LIKE '%$cs%' ORDER BY name";

$result=mysql_query($searchquery);
$num_rows=mysql_num_rows($result);

echo "<b>$num_rows</b> results found<br>"; 
//echo "<INPUT TYPE='image' SRC='http://localhost/drupal/printwebpagepdf.gif' OnClick='clickPrint()'>";
//display results(search results table)
if($num_rows >0) {

echo "<div style='width:620px; height:100%;'>";
echo "<table border='2' width='100%' id='blutable'>";
echo "<tr style='background-color:#A9D0F5'><th></th><th>Name</th><th>Address</th><th>Contact No</th><th>Email</th><th>Gender</th><th>Age</th><th>Marital Status</th><th>University</th><th>Fac/Dept</th><th>Course</th><th>Course Date</th><th>Reg. Date</th><th>Completion</th></tr>";

$i=1;

while($row = mysql_fetch_array($result)) {

$r = fmod($i,2);
if($r=="1"){
$rowclass="odd";
}
else{
$rowclass="even";
}

echo "<tr class='$rowclass'>";
//echo "<td><input type='submit' value='EDIT' onclick='editer($i)' style='width:50px; height:25px background;'/></td>";

echo "<td style='padding:1px;' valign='bottom'><INPUT TYPE='image' SRC='http://localhost/drupal/more.png' onclick='editer($i)' style='width:25px; height:25px;'/></td>";


 echo "<td nowrap><div id='cpid_$i'>";echo $row['name'];"</div></td>";
 //echo "<td><div id='cpid_$i'>";echo $row['nic'];echo "</div></td>";
 echo "<td nowrap>";echo $row['res_address'];echo "</td>";
 echo "<td>";echo $row['cont_no'];echo "</td>";
 echo "<td>";echo $row['email'];echo "</td>";
 echo "<td>";echo $row['gender'];echo "</td>";
 echo "<td>";echo $row['age'];echo "</td>";
 echo "<td>";echo $row['marital_stat'];echo "</td>";
 echo "<td nowrap>"; echo $row['university']; …
rukshilag 0 Junior Poster

Hi,
well what i need to do is, through a certain interface there are assignment upload calls given by the admin, this is that interface

<html>
<head>
<script type="text/javascript">

function remlink(num){
var rownum=num;
var rowid = "subname_"+rownum;
var sn=document.getElementById(rowid).innerHTML;

var cnfrm = confirm ("Are you sure you want to remove this link?");

if(cnfrm){
var querystring="?sn=" + sn;
window.location = "http://localhost/drupal/node/27"+querystring;
}

}

</script>
</head>


<b>NEW SUBMISSION LINK</b>
<form action="http://localhost/drupal/node/27" method="POST">
<table>
<tr><td>Submission Name</td><td><input type="text" name="sub_name"/></td></tr>
<tr><td>Maximum file size</td><td><input type="text" name="max_mb" size="1" value="2" maxlength="3"/>MB</td></tr>
<tr><td>Support File</td><td><input type="file" name="sup_file" size="30"/></td></tr>
<tr><td></td><td><input type="submit" name="sub_sub" value="OK"/></td></tr>
</table>
</form><br><br>

<?php

$sub_name=$_POST['sub_name'];
$max_mb=$_POST['max_mb'];
$sup_file=$_POST['sup_file'];

mysql_connect("localhost", "root", "");

mysql_select_db('sdc_assign');

$insertq="INSERT INTO due_subs (sub_name, max_mb, sup_file) VALUES ('$sub_name', '$max_mb' , '$sup_file')";

if(!$sub_name==""){
$res=mysql_query($insertq);
if($res){ echo "Link Created for: " . $sub_name . "<br/>"; }
else{ echo "COULD NOT CREATE LINK. LINK MAY ALREADY EXIST"; }
}

?>

<?php

$subnameid=$_GET['sn'];
if(!$subnameid==""){
$deleteq="DELETE FROM due_subs WHERE sub_name='$subnameid'";
mysql_query($deleteq);
}
?>

<br>
<b>REMOVE SUBMISSION LINK</b>
<br/><br/>
<form>
<table>

<?php
$selectq="SELECT * FROM due_subs";
$result=mysql_query($selectq);

$i=0;
while($row=mysql_fetch_array($result)){
echo "<tr><td>";
echo "<div id='subname_$i'><a href='http://localhost/drupal/node/29'>";
echo $row['sub_name'];
echo "</div>";
echo "</td><td>";
echo "<input type='button' value='REMOVE' onclick='remlink($i)'/>";
//echo "<form action='http://localhost/drupal/node/29/' method='post'><input type='button' value='CHECK' onclick=''/></form>";
echo "</td></tr>";
$i++;
}
?>


</table>
</form>

</html>

when the admin uploads a link for students to upload their assignments, students will be abel to upload.
now what i need to do is, thru that interface i have shown u, to have a link per assignment link which i can check …

rukshilag 0 Junior Poster

ok thank you.. but how can i create a more user specific upload? where the users who upload will be identified with their submission?

rukshilag 0 Junior Poster

ok i used a diff code and file gets uploaded fine

http://www.quackit.com/php/tutorial/php_upload_file.cfm

check that

do u know anytng abt ezpdf?

rukshilag 0 Junior Poster

i uploaded.
please check

rukshilag 0 Junior Poster

it seems to get saved as a .tmp file in the tmp folder..... why isnt it saving as a jpeg???

rukshilag 0 Junior Poster

i am currently using drupal - but still some error comes on that
so i tested it separately by savung the files in htdocs
this is what i get when i uploaded a jpeg file

Upload: DSC00792.JPG
Type: image/jpeg
Size: 124.9560546875 Kb
Stored in: D:\xampp\tmp\php806A.tmpInvalid fileInvalid file

whats wrong?

rukshilag 0 Junior Poster

does the file upload happen for u??
u mean copy paste what i entered here is it? it is the same thing that doesnt work right?

rukshilag 0 Junior Poster

Parse error: syntax error, unexpected T_IF, expecting ',' or ';' in D:\xampp\htdocs\drupal\upload.php on line 12

it keeps giving errors like that.

can u tell me how i can fix the file permissions???

rukshilag 0 Junior Poster

i want to create a successful file upload component in a site and i have used and gone thru countless tutorials but it does not seem to work.

here is the code i am using

<html>
<body>

<form action="upload_file.php" method="post"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file" />
<br />
<input type="submit" name="submit" value="Submit" />
</form>

</body>
</html>

and the php script is

<?php
if ($_FILES["file"]["error"] > 0)
  {
  echo "Error: " . $_FILES["file"]["error"] . "<br />";
  }
else
  {
  echo "Upload: " . $_FILES["file"]["name"] . "<br />";
  echo "Type: " . $_FILES["file"]["type"] . "<br />";
  echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
  echo "Stored in: " . $_FILES["file"]["tmp_name"];
  }
?> 

<?php
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 20000))
  {
  if ($_FILES["file"]["error"] > 0)
    {
    echo "Error: " . $_FILES["file"]["error"] . "<br />";
    }
  else
    {
    echo "Upload: " . $_FILES["file"]["name"] . "<br />";
    echo "Type: " . $_FILES["file"]["type"] . "<br />";
    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
    echo "Stored in: " . $_FILES["file"]["tmp_name"];
    }
  }
else
  {
  echo "Invalid file";
  }
?> 
<?php
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 20000))
  {
  if ($_FILES["file"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
    }
  else
    {
    echo "Upload: " . $_FILES["file"]["name"] . "<br />";
    echo "Type: " . $_FILES["file"]["type"] . "<br />";
    echo "Size: " . ($_FILES["file"]["size"] / 1024) …
rukshilag 0 Junior Poster

ok thanks but this is the form right? my problem is with the php code i think... have u anythng to sy abt how i have coded the checkboxes in the php code?

rukshilag 0 Junior Poster

@lethargiccoder
i did it in a certain way but it doesnt seem to work the html and php is separate.

<form action="http://localhost/drupal/pdf.php" method="post" style="background-color:#F2F2F2; border:1px solid; border-color:#084B8A;
width:98%; padding:10px;" >
<table>
<tr>
<td><strong>Title of Your Report:</strong></td>
<td>
<input type="text" name="title" value="" size="60" id="title" />
</td>
</tr>
<tr>
<td>
<input type="radio" name="name" value="name" checked/> Name
</td>
</tr>
<tr><td><strong>Tick Fields Required:</strong></td>
</tr>
<tr>
<td>
<input type="checkbox" name="selectfields[]" value="address" /> Address
<input type="checkbox" name="selectfields[]" value="contactnumber" /> Contact Number
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="selectfields[]" value="gender" /> Gender
<input type="checkbox" name="selectfields[]" value="age" /> Age
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="selectfields[]" value="email" /> E-Mail
<input type="checkbox" name="selectfields[]" value="maritalstatus" /> Marital Status
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="selectfields[]" value="university" /> University
<input type="checkbox" name="selectfields[]" value="facdept" /> Faculty/Department
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="selectfields[]" value="course" /> Course
<input type="checkbox" name="selectfields[]" value="cd" /> Course Date
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="selectfields[]" value="rd" /> Registration Date
<input type="checkbox" name="selectfields[]" value="completion" /> Completion
</td>
</tr>
<tr><td> </td>
<td>
<input type="submit" value="CUSTOMIZE & PRINT" style="float:right;" class="up"onmouseover="this.className='over'"onmouseout="this.className='up'" />
</td>
</tr>
</table>

this is on the same page as the search box it appears below the search results.
i used this in the search.php for thse checkboxes

echo "<input type='hidden' name='selectfields' value='$sf'/>";

can u see whats wrong?

rukshilag 0 Junior Poster

errrrr i know that... i asked becuase i can show it to one paticular person n there onwards work.. i said wat works for me.. if u do not want to help please dont, and do not jump to conclusions and accuse.

rukshilag 0 Junior Poster

hi is it possible to have one of ur skype ids or gmail ads? so can show the code then. thanks!

rukshilag 0 Junior Poster

Hi Does Anyone know how to display a table based on user selected fields?
In my search box, once the user searches lets say all the female students, all the female students will show with all the fields of that particular table. then if need to print a report i want the user to be able to select the fields they want printed, that is how do i customize the table?

please help

rukshilag 0 Junior Poster

hi - i have coded a seacrch box and its results are displayed in a tabular form.
i have also a print button which when pressed shud create a pdf based on that table that is displayed. for this i have a separate page called pdf.php. i am using ezpdf for this.
instead of writing the query twice.. is there a way for the pdf to be created based on what query combination the search user selects? do we need sessions for this?

here is the pdf.php

<?php
	session_start();
?>

<?php
# Catch the posted data, validate by getting rid of > and <
$header =$_POST['header'];
# Replace > and < with a blank space
$header = str_replace('<','',$header);
$header = str_replace('>','',$header);
$body =$_POST['body'];
# Replace > and < with a blank space
$body = str_replace('<','',$body);
$body = str_replace('>','',$body);

# Include the file that does all of the work
include ('class.ezpdf.php');

# Start a new PDF file
$pdf =& new Cezpdf();

# Select the font we'll be using. There are more fonts in the zip file.
$pdf->selectFont('./fonts/Helvetica.afm');

# include the header, then move down a couple of lines, font size 25
# justification centered (centred if you're from the UK)
$pdf->ezText($header . "\n\n",25,array('justification'=>'centre'));

# include the body after moving down 7 lines to get under the pic.
# Font size 16, justification centered.
$pdf->ezText("\n\n\n\n\n\n\n" . $body,16,array('justification'=>'centre'));

//inside
$pdf->ezText('Hello World!',20);
//--------------------------------------------------
// you will have to change these to your settings
$host = 'localhost';
$user = 'root';
$password = …
rukshilag 0 Junior Poster

Hi so i have a search box of a student database. and when searched the results are displayed in a tabular form.
i first used window.print to just print out the search results div if the users want some sort of a report. but when using window.print the css is gets very messy and seems very unprofessional
therefore i opted in using a reporting tool or maybe a php to pdf class like ezpdf.
can someone help me - i have no idea how to when clicking the print button for a pdf to be created. there is so much php involced. can someone take a look at all my code and help me out?

rukshilag 0 Junior Poster

hi below is the code i am using to try and execute a pdf report. now the following code i saved in a separate file in the website folder itself. and in the form that contains the print button, when clicked i want it to execute the code in the below mentioned code.

this is the function i used in the form. is this correct?

//print
function reportPrint(){
if(document.f1.pr.OnClick()){
$.get("http://localhost/drupal/pdf.php")
}
}

please let me know if this is incorrect how to call the function from my form itself to execute another file with a script in the same folder

Hi friends,

I am back again with another very useful piece of code. MySQL has no easy report generation tool as
Oracle has, so its always developers who have to do this.

The following code helps you in developing reports for the MySQL Database.

The code has been tested by me and is working perfectly at
http:// galileo.tamucc.edu/~sri/PDF/pdfreportdemo.php

Please let me know if there is some problem with this code. I'll be glad to help you.

Please take care of the broken lines they mess your code a lot. If you indent them properly and run
the script with the few changes required to do, I am sure it would run perfectly.

Thank you,
Srikanth Turaga.

PSS: One of the members on the site has requested me to send some more stuff on PDF file generation
using FPDF. I didn't expect to come up with …
rukshilag 0 Junior Poster

hi wats ur skype id?? i can send u the code i use!

rukshilag 0 Junior Poster

i have downloaded and extracted fpdf into my root folder site folder.. i want to know how i can generate a pdf file when i press a button called print.
please help?
and wehre do i put this fpdf code? is it in the script that contains the output?

rukshilag 0 Junior Poster

i have downloaded fpdf, dompdf and html2pdf, all just in case.. dont know how to use any - site is a drupal site - this is for a search page - wheer the serach results if requitred can be printed in a pdf form..

rukshilag 0 Junior Poster

Hi i have downloaded a php class from a website. and i want to know how i am to integrate it with my system???
i mean do i unzip the file to where?
please help!

rukshilag 0 Junior Poster

i mailed you my code - please check

rukshilag 0 Junior Poster

ok so u mean instead of this line var content_vlue = document.getElementById("formData").innerHTML; i should use
var content_vlue = document.myform.yourname.value; is it??
but then i wont need that div called formData either right?
i can just use that like u said var content_vlue = document.myform.yourname.value; continuously for all the values i want outputted right?

rukshilag 0 Junior Poster

so what do u mean i shud write a function in js is it?
if so can u give me an example?

this is all i have done so far

<script type="text/javascript">

function Clickheretoprint()
{ 
  var disp_setting="toolbar=yes,location=no,directories=yes,menubar=yes,"; 
  disp_setting+="scrollbars=yes,width=650, height=600, left=100, top=25"; 
  var content_vlue = document.getElementById("formData").innerHTML; 
  
  var docprint=window.open("","",disp_setting); 
   docprint.document.open(); 
   docprint.document.write('<html><head><title>Print Results</title>'); 
   docprint.document.write('</head><body  onLoad="self.print()"><center>');          
   docprint.document.write(content_vlue);          
   docprint.document.write('</center></body></html>'); 
   docprint.document.close(); 
   docprint.focus(); 

}
function dataprint()
{ 
  var disp_setting="toolbar=yes,location=no,directories=yes,menubar=yes,"; 
  disp_setting+="scrollbars=yes,width=650, height=600, left=100, top=25"; 

  window.opener.formname.elemname.value;
}
</script>
</head>

<?php
rukshilag 0 Junior Poster

my code has a print button and when that is clicked i want a new window to open up wit a list of details that the user edits. that is all the data of the form. (only the values)
how do i do this?

rukshilag 0 Junior Poster

working on a form to update particular user details if required. as you can see there is also a print button.
i want to know how i can print out the div=formData if print button is clicked.
according to my current code when print is pressed the whole form itself gets printed.
i need only the values that are updated to be printed.
check out my code n please help

<html>
<head>

<style type="text/css">
.up {
float:right; 
background-color:#1b5b88;
border:2px solid;
padding:4px;
color:white;
}

.over{
float:right; 
background-color:#1b5b88;
border:4px solid;
border-color:#CEE3F6;
padding:2px;
color:white;
}

</style>
<script type="text/javascript">

function Clickheretoprint()
{ 
  var disp_setting="toolbar=yes,location=no,directories=yes,menubar=yes,"; 
  disp_setting+="scrollbars=yes,width=650, height=600, left=100, top=25"; 
  var content_vlue = document.getElementById("formData").innerHTML; 
  
  var docprint=window.open("","",disp_setting); 
   docprint.document.open(); 
   docprint.document.write('<html><head><title>Print Results</title>'); 
   docprint.document.write('</head><body  onLoad="self.print()"><center>');          
   docprint.document.write(content_vlue);          
   docprint.document.write('</center></body></html>'); 
   docprint.document.close(); 
   docprint.focus(); 
}

</script>
</head>

<?php

mysql_connect("localhost", "root", "");
mysql_select_db("sdc_cpds") or die ("error can select db");

$cpname=$_GET["name"];
$cpcourse=$_GET["course"];
$cpdate=$_GET["course_date"];

$query=mysql_query("SELECT * FROM course_participant WHERE name='$cpname' AND course='$cpcourse' AND course_date='$cpdate' UNION SELECT * FROM past_participant WHERE name='$cpname' AND course='$cpcourse' AND course_date='$cpdate'");
$row=mysql_fetch_array($query);

$name=$row['name'];
$address=$row['res_address'];
$contact_no=$row['cont_no'];
$email=$row['email'];
$gender=$row['gender'];
$age=$row['age'];
$marital_status=$row['marital_stat'];
$university=$row[university];
$facdept=$row['facdept'];
$course=$row['course'];
$course_date=$row[course_date];
$reg_date=$row['reg_date'];
$completion=$row['completion'];
$current=$row['current'];

?>

<form method="POST" action="http://localhost/drupal/node/19" name="f1">

<strong>PERSONAL DATA</strong>
<div style="background-color:#F2F2F2; padding:10px; border:1px solid; border-color:#084B8A; width:650px;">
<table>
<tr>
<td>Name:</td><td width="500"><input name="name" type="text" size="60" value="<?php echo $name; ?>"/></td>
</tr>
<tr>
<td>Residential Address:</td><td width="300"><textarea cols="45" rows="5" name="resad"/><?php echo $address; ?></textarea></td>
</tr>
<tr>
<td>NIC:</td><td width="300"><input name="NIC" type="text" size="9" value="<?php echo $nic; ?>"/>V</td>
</tr>
<tr>
<td>Contact No.:</td><td width="300"><input name="contact" type="text" size="12" value="<?php echo $contact_no; ?>"/></td>
</tr>
<tr>
<td>e-mail Address:</td><td width="300"><input name="email" type="text" size="30" value="<?php echo $email; ?>"/></td> …
rukshilag 0 Junior Poster

i have used the below function to open a separate page for search results to open up in - althoug it seems that the css seems to get messy what must be the problem?
is anyone willing to help?
if so please let me know ur skype add so i can show the whole code . thanks so mcuh!

function Clickheretoprint()
{ 
  var disp_setting="toolbar=yes,location=no,directories=yes,menubar=yes,"; 
  disp_setting+="scrollbars=yes,width=1200, height=1000, left=100, top=25"; 
  var content_vlue = document.getElementById("searchResults").innerHTML; 
  
  var docprint=window.open("","",disp_setting); 
   docprint.document.open(); 
   docprint.document.write('<html><head><title>Print Results</title>'); 
   docprint.document.write('</head><body onLoad="self.print()"><center>');          
   docprint.document.write(content_vlue);          
   docprint.document.write('</center></body></html>'); 
   docprint.document.close(); 
   docprint.focus(); 
}
rukshilag 0 Junior Poster

yeah i used that.. but the entire form field names and so on get displayed. that is not what i want. i want it to print only what is entered to those fields.
example
form=edit
name - rukshila
age-22
school-ucsc

when print button is clicked what shud be printed is -
rukshila
22
ucsc

get what im saying?

rukshilag 0 Junior Poster

i want a print button to be able to print out details of a php form by connecting to a printer.
can someone explain this to me with an example code please?

rukshilag 0 Junior Poster

Doing a system in drupal using php and mysql.
Want to integrate a function for reporting - that is print out watever search result in the search page which displays in tabular form.

please help. i have only heard of jasper reports. is there something simpler? if so wat n how?

rukshilag 0 Junior Poster

Unless you have many millions of records in the table, one table and a current_student field would work okay. Adding an index or two would speed things up. The primary key will automatically get indexed, but in this case adding an index on current_student would be an excellent idea.

One table may also simplify things when you need data on past and present students in a single query.

(A field called type risks type being a reserved word in your programming language, so current or current_student is probably a better field name.)

definitely not millions of records - but wat du mean by indexing?

rukshilag 0 Junior Poster

working on a system with 2 tables both have the exact same fields - the tables are past_participant and course_participant - CP table has all current students whilst the PP has only past students.
after a course concluded, that set of students is transferred from CP to the PP table.
is this a good practice? is it better to just have one table with an extra field called type which will define if its a past or current participant?

we are having 2 tables thinking having one might just slow down the search... is this right?


is it better we are having 2 same tables which are the same or just one table with an extra field that defines the type?

rukshilag 0 Junior Poster

So here is my search query set

/all possible input combinations

//name and id combinations

if($q != '') {
	if($id != '') {
		$sql = "select * from course_participant where name LIKE '%$q%' and nic='$id'";
                $result = mysql_query($sql);
                $num_rows= mysql_num_rows($result);
	}else{
		$sql = "select * from course_participant where name LIKE '%$q%'";
                $result = mysql_query($sql);
                $num_rows= mysql_num_rows($result);
	}
}else {
	if($id != '') {
		$sql = "select * from course_participant where nic = '$id'";
                $result = mysql_query($sql);
                $num_rows= mysql_num_rows($result);
	}/*else if($sql<0){
		$sql = false;
                $result = mysql_query($sql);
                $num_rows= mysql_num_rows($result);
                echo "No Result Found!";
	}*/
}


//name and completed successfully
if($cs=='yes'){
     if($q!=''){
       $sql = "select * from past_participant where completion LIKE '%$cs%' and name LIKE '%$q%'";
          $result = mysql_query($sql);
          $num_rows= mysql_num_rows($result);
    }else if($cs=='current'){
       $sql = "select * from course_participant where completion LIKE '%$cs%' and name LIKE '%$q%'";
          $result = mysql_query($sql);
          $num_rows= mysql_num_rows($result);
    }
}





//if only course is selected
if($course!='') {
    $sql = "SELECT * FROM past_participant WHERE course='$course' UNION SELECT * FROM course_participant WHERE course='$course'";

         $result = mysql_query($sql);
         $num_rows= mysql_num_rows($result);
    }


//another problem query - all records of both tables
if($course=='all') {
    $sql = "SELECT * FROM past_participant UNION SELECT * FROM course_participant";

         $result = mysql_query($sql);
         $num_rows= mysql_num_rows($result);
}

//if date of course and course is selected and completion (yes/no/current)
if($cd!=''){
 if($course!=''){
   if($cs=='yes') {
    $sql="select * from past_participant where course_date='$cd'";
      $result = mysql_query($sql);
      $num_rows= mysql_num_rows($result);
    }else if($cs=='no') {
      $sql="select * from course_participant where course_date='$cd' and course LIKE '%$course%'";
      $result = mysql_query($sql);
      $num_rows= mysql_num_rows($result);
     }else if($cs=='current') {
      $sql="select * from course_participant where …
rukshilag 0 Junior Poster

u mean use phpmyadmin is it?

it seems that some of the queries are similar to eachother so some dont run. i changed the arrangement n the ones that ddnt work, work n working ones dont..

rukshilag 0 Junior Poster

Doing a System in Drupal - coding with php and mysql - want to know how i can integrate jasper reports to it so i can generate reports at the click of a button..


does anyone know?
please help..

rukshilag 0 Junior Poster

what i mean is - all cthe and athe courses - alllll the records in both tables shud be shown if all is pressed.. how to do that??
and also another preob is this following query

if($course!='blank'){
if($cs=='yes'){
    $sql = "select * FROM past_participant WHERE course='$course' and completion='$cs'";
         $result = mysql_query($sql);
         $num_rows= mysql_num_rows($result);
}

else if($cs=='current'){
  $sql = "select * FROM course_participant WHERE course='$course' and completion='$cs'";
         $result = mysql_query($sql);
         $num_rows= mysql_num_rows($result);
}
else if($cs=='no'){
  $sql = "select * FROM past_participant WHERE course='$course' and completion='$cs'";
         $result = mysql_query($sql);
         $num_rows= mysql_num_rows($result);
}
}

in this as u can see when i click on a course and press a radio button yes - even the records with no and current come! why is this???

rukshilag 0 Junior Poster

WHEN I USE UNION I GET THIS
warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\wamp\www\sdc\includes\common.inc(1695) : eval()'d code on line 212.

rukshilag 0 Junior Poster

Show your query. You can use UNION to combine the results of two tables.

here are my queries - they are giving me a lot of trouble

//all possible input combinations

//name and id combinations

if($q != '') {
	if($id != '') {
		$sql = "select * from course_participant where name LIKE '%$q%' and nic = '$id'";
                $result = mysql_query($sql);
                $num_rows= mysql_num_rows($result);
	}else{
		$sql = "select * from course_participant where name LIKE '%$q%'";
                $result = mysql_query($sql);
                $num_rows= mysql_num_rows($result);
	}
}else {
	if($id != '') {
		$sql = "select * from course_participant where nic = '$id'";
                $result = mysql_query($sql);
                $num_rows= mysql_num_rows($result);
	}else if($sql<0){
		$sql = false;
                $result = mysql_query($sql);
                $num_rows= mysql_num_rows($result);
                echo "No Result Found!";
	}
}

//name and completed successfully
if($cs=='yes'){
     if($q!=''){
       $sql = "select * from past_participant where completion LIKE '%$cs%' and name LIKE '%$q%'";
          $result = mysql_query($sql);
          $num_rows= mysql_num_rows($result);
    }else if($cs=='current'){
       $sql = "select * from course_participant where completion LIKE '%$cs%' and name LIKE '%$q%'";
          $result = mysql_query($sql);
          $num_rows= mysql_num_rows($result);
    }
}


//only completed successfully
if($cs =='yes') {
       $sql = "select * from past_participant WHERE completion='$cs'";
       $result = mysql_query($sql);
       $num_rows= mysql_num_rows($result);
} //if no is selected it should compare with both tables
else if($cs =='no') {
       $sql = "select * from past_participant WHERE completion='$cs'";
       $result = mysql_query($sql);
       $num_rows= mysql_num_rows($result);
}else if($cs=='current') {
       $sql = "select * from course_participant WHERE completion='$cs'";
       $result = mysql_query($sql);
       $num_rows= mysql_num_rows($result);
}

//course and completed successfully
if($course=='CTHE'){
 if($cs=='yes'){
    $sql = "select * from past_participant WHERE course='$course' and completion='$cs'";
         $result = mysql_query($sql);
         $num_rows= mysql_num_rows($result); …
rukshilag 0 Junior Poster

so there are 2 tables course participant and past participant - both have same fields.
i want to write a query that selects both from course participant and past participant if search option "find all" is called.
i out everypossible combination but it just doesnt get right - pls help

rukshilag 0 Junior Poster
//only completed successfully
if($cs =='yes') {
       $sql = "select * from past_participant where completion LIKE '%$cs%'";
       $result = mysql_query($sql);
       $num_rows= mysql_num_rows($result);
} else if($cs =='no') {
       $sql = "select * from course_participant FULL JOIN past_participant ON completion LIKE '%$cs%'";
       $result = mysql_query($sql);
      //$num_rows= mysql_num_rows($result);
}else if($cs =='current') {
       $sql = "select * from course_participant WHERE completion LIKE '%$cs%'";
       $result = mysql_query($sql);
       $num_rows= mysql_num_rows($result);
}

the above join doesnt seem to work in my code ... what is wrong??
it just needs to show all the "no" records in both tables.

rukshilag 0 Junior Poster

ok so i have to tables and i want to have a query that selects all from "table a" and "table be" where "a certain variable"="$x".. how do i select all from 2 tables at once?

rukshilag 0 Junior Poster

where do i place that line???