Posts

java - How to save file as pdf -

Image
i have website that's not ready production yet. when user purchase product generating receipt. need want give option user save pdf. on click of icon receipt has downloaded. have no idea this. here sample receipt: on click of "save pdf" need download receipt. can me in this. your problems can broken down following pieces. when user clicks "save pdf" generate pdf: itext comes handy in doing (its free & open source). here example of generating tabular data in pdf. there tons of example itext download pdf. once pdf generated, same can send user via response object file. here example of downloading text file. same can used downloading file. hope helps.

php - Unable to insert data -

i newbee codeigniter , php. trying insert data using form , display on same view page using mvc pattern given codeigniter. view is: <html> <head> <title>my form</title> </head> <body> <? echo form_open('books/input'); ?> <? echo $id; ?>: <? echo form_input('id'); ?> </br> <? echo $title; ?>: <? echo form_input('title'); ?> </br> <? echo $body; ?>: <? echo form_input('body'); ?> </br> <? echo form_submit('mysubmit','submit!'); ?> <? echo form_close(); ?> </body> </html> and controller is: <? class books extends controller{ function books(){ parent::controller(); } function main(){ $this->load->model('books_model'); $data = $this->books_model->general(); //$this->load->view('books_main',$data); } ...

Drools: using rule "exists" for a Map(Scala) -

i have class "records" has map[string,double](scala) attribute "payorders" , want find out whether map contains value larger 50. rule wrote this: rule "user1" dialect "mvel" no-loop when $user:records($pay:payorders.values) exists(number(doublevalue > 50) $pay) system.out.println("user1") end the problem there no error rule doesn't work! no outputs. then, tried print $pay . output $pay:maplike(300.0) . first thought drools can't analyze type, revised $user:records($pay:payorders.values) $user:records($pay:payorders.values.tolist) . still prints nothing. seems once added exists line, rule don't work. can me? thanks!

php filter_var fails with zero on FILTER_VALIDATE_INT -

i'm confused following throws exception: if (!filter_var(0, filter_validate_int)) throw new exception("non numeric field passed " . $field . " when expecting number: " . $variable . " passed instead"); anything positive works fine? i've tried intval(0) , still nothing. 0 not integer? filter_var returns filtered data , or false if filter fails. filter_var(0, filter_validate_int) returns int(0) , , falsy value, !filter_var(0, filter_validate_int) true.

java - How to programmatically change the background image of an Android Activity -

i have been able change colour of activity background (see this post ). requirement same background image. mean can click button, select option , change current activity background image new one. here have done: private sharedpreferences prefs; private static final string selected_item = "selecteditem"; private editor sharedprefeditor; btnchangecolor = (imagebutton) findviewbyid(r.id.btnchangecolor); btnchangecolor.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { final charsequence[] items={getstring(r.string.default),getstring(r.string.pix1), getstring(r.string.pix2))}; alertdialog.builder builder = new alertdialog.builder( contentview.this); builder.settitle((getresources().getstring(r.string.color_switch))); builder.setpositivebutton((r.string.ok), new dialoginterface.onclicklistener() { @override public void onclick(dialoginterface dialog, int which) { } }); ...

php - How to get upload image for particular user -

database tables: [a].registationform [b].login total file (1)registrationform.php (2)login.php (3)profile.php in file details: (1)html fields: upload profile picture , other details. (2)username, password only registrated user allow use of session problems: (3)profile.php display details own picture. how can get picture form "registrationform" table . dbtable olny image name there , file in upload folder. my query $order = "select * `registrationform` user_id='$id'"; $result = mysql_query($order); while($data = mysql_fetch_row($result)) { echo("<tr><td>fistname:$data[1]</td></tr> <tr><td>lastname:$data[2]</td></tr> <tr><td>image:$data[5]</td></tr>"); } can give me suggestion thank you. you may use following statement:---- $order = "select * `registrationform` user_id='$id'"; $result = mysql_query($o...

python - Django belong to field or parents field -

i'm using django 1.6 , trying make field parent field , parent field can have several children field? i make db containing drop down list contains (computer, scanner, printer ) if user choose computer , can added things related such monitor .. is possible make django? yes, possible. need use foreignkey task. example: # models.py django.db import models class gadget(models.model): """ model you'll add gadgets computer, printer, etc. """ name = models.charfield(max_length=100) class property(models.model): """ model adding monitor, etc. gadgets models. """ gadget = models.foreignkey(gadget) property = models.charfield(max_length=100) something_else = models.charfield(max_length=100)