Entries tagged html

Show Pictures in a Form on a Table with Report in APEX

Posted on 10. Dezember 2013 Comments

The table is called WPDBD_TEIL. The primary key is TID. In WPDBD_TEIL there is a column called BILD(german: picture/image) from type BLOB.

First click on your form and keep the name of the picture in mind. In this case, it’s P9_BILD.
report_bild

Then go to your report, click on edit for the whole report and use the following code

apex_editreport

select "TID", 
"TNAME",
"PREIS",
decode(nvl(dbms_lob.getlength("BILD"),0),0,null, '<img height="100px" width="100px" src="'||apex_util.get_blob_file_src('P9_BILD',TID)||'" />') "BILD"
from "#OWNER#"."WPDBD_TEIL"

If you’d open the report now, you only get the HTML Code. So you have to change the way APEX displays the entry. So go to the report, click on BILD and change Display as Text to Report Standard Column

 

edit_bildstandardreportcolumn

 

The form I used was the following.

formreport

Also, in the last page of creating the form, you have to chose your own primary key, not the ROWID.

 

primarykeyapexform

 

Simple MRBS Output from Database

Posted on 17. September 2013 Comments

I wrote a little PHP-script that extracts the most important and current data from MRBS’s MySQL database and just prints them in a simple HTML file. Its not pretty but good for bandwith and clarity. We use it to display information on an energy efficient e-ink screen in front of conference/computer rooms.

$date is set like this:

$date = date("Y-m-d");

The SELECT-statements go like this, where N is the ID of the room(in the database, not what you might call it)

SELECT name,description,from_unixtime(start_time),from_unixtime(end_time) FROM mrbs_entry WHERE from_unixtime(start_time) LIKE '%" . $date . "%' AND room_id = N;

I’m not gonna explain here how to establish a database connection in PHP, but you can have a  look at the whole sourcecode at github 😉

I then cut off the date with substr() because it’s always 10 characters in front of time->(YYYY-MM-DD) and printed it via echo. This is the simple version, there is a version with tables on github.

while($row=mysql_fetch_row($qry01)) {
echo "- <strong>Room</strong> 01 | <strong>Desc:</strong>" . $row[0]." - ".$row[1]." |  <strong>Time:</strong> ". substr($row[2],10) . " - " . substr($row[3],10) . " <br />";
}

update: I wrote another version that prints JSON objects which can be parsed on the other side. For easier parsing(e.g. if everything is in one String) I numbered them:

$jsonarray = array('begin' . $i => substr($row[2],11, 5), 'end' . $i => substr($row[3],11,5), 'name' . $i => $row['name'], 'description' . $i =>  $row['description']);

You’ll find the whole thing on github.