PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old July 3rd, 2002, 05:36 AM
fakker fakker is offline
The calm b4 the storm
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Manchester, UK
Posts: 404 fakker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via Yahoo to fakker
Question PHP WYSIWYG getting frame source from DB

Hi,

I have just created the editor thanks to the great articles on this website... and it all works fine...
I have done the code to let me save the text to the DB no problem...

but I want to get the text from the DB and load it in to the iFrame window....

I have looked through this forum and managed to get some text in, but not the DB text.....

I have the following code:

-------------------------------------------------
var src = ' hello ';

function Init()
{
iView.document.designMode = 'On';
iframeWin = window.frames.iView;
iframeWin.document.open();
iframeWin.document.write(src);
iframeWin.document.close();

}

---------------------------------------------------

That manages to put "hello" in to the editor window, but when I tried:

var src = '<? echo "$text"; ?>';

it comes up with loads of errors....

I have one main page called "admin.htm" which has hyperlinks to "editpage.php" and a variable is passed over "?pageid=1" which then is used to select the record from the DB.
this is then supposed to be read in as $text value so it can be edited.

Plllleaaasse help!!

Thanks!
Matt F
Manchester, UK.

Reply With Quote
  #2  
Old July 3rd, 2002, 06:13 AM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
ahh, matt, this has been the most popular topic on this forum 2 date, eheh, what you have to do is much simpler then you think

firstly create a php page (call it: load.php)

in this page you need to print out the data you want to be able to edit in they wysiwyg editor.

PHP Code:
<?php
global $id;

        
mysql_connect("localhost","username","password");
        
mysql_select_db("db_name");

        
$query mysql_query("SELECT * FROM table_name WHERE field=$id");

        while(
$row mysql_fetch_array($query)
                {
                
//print data here
                
}
?>
ok, now your done that you now have a page that prints out the data you want to edit

now you need to load it, in the editor page you have add this to the <iframe> tag.

src="load.php?id=<?=$id ?>"

then when you load the editor, type this in the address bar

editor.php?id=#

i hope you get all that, eheh, kinda rushed it but basically if you use the src var in the <iframe> tag, it will load that data and you will be able to edit it

Reply With Quote
  #3  
Old July 3rd, 2002, 06:52 AM
fakker fakker is offline
The calm b4 the storm
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Manchester, UK
Posts: 404 fakker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via Yahoo to fakker
Talking

WOOO HOO HOO HOOOOOOO!!

It works!!



Thanks V MUCH!!!!

Matt

Reply With Quote
  #4  
Old July 3rd, 2002, 07:18 PM
mytch mytch is offline
Dev Articles Novice (500 - 999 posts)
 
Join Date: Apr 2002
Location: Sydney, Australia
Posts: 589 mytch User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Good work Ben,
But just about your earlier problem:

var src = ' hello ';

function Init()
{
iView.document.designMode = 'On';
iframeWin = window.frames.iView;
iframeWin.document.open();
iframeWin.document.write(src);
iframeWin.document.close();

}

The reason you would've got errors is because if you loaded text into the src attribute, it would've had quotes and new lines. you just have to replace ' with \' and a new line with \r\n so that the string sits on one line and it would all work fine. Bens method is easier tho :P

Reply With Quote
  #5  
Old July 3rd, 2002, 07:20 PM
fakker fakker is offline
The calm b4 the storm
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Manchester, UK
Posts: 404 fakker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via Yahoo to fakker
Thanks for all the help on this one!

Ben's idea worked perfectly, but you were right with the new line thingy...

it was when the value was being returned from the DB that it was adding new lines to the text string which send the javascript crayzee!

I'm just working on the image upload now!

;-)

Cheers!!
__________________
Matt 'Fakker' Facer

mattfacer.com

Reply With Quote
  #6  
Old July 12th, 2002, 05:28 AM
fakker fakker is offline
The calm b4 the storm
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Manchester, UK
Posts: 404 fakker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via Yahoo to fakker
I had a request for my code for the solution to my earlier problem:

getting the record from the DB in to the editor window... here is my code and how I did it:

--------------------------------
In your Editor Page ... ...
--------------------------------

Firstly (as mentioned above by Ben) you need to find the section which relates to the <iFrame>.. this is the actual editing part of the editor and the place where the text from the DB will be imported.
You need to specify a source for the iFrame. This source will be a seperate page which gets the data from the DB... then it is loaded in to the <iFrame> section...

so... add this (or similar) line to the <iFrame> tag...

<iframe id="iView" style="width: 600px; height:400px" src="load.php?id=<?= $id ?>"></iframe>

The important part it the src="load.php" part...

This is the page which we will create next. When the editor loads, it goes away and gets the page "load.php".... this is shown next:

--------------------------------
Create a new Page called load.php and insert the following code:
--------------------------------

<?php
global $id;

mysql_connect("localhost","username","password");
mysql_select_db("database_name");

$query = mysql_query("SELECT * FROM table_name WHERE id=$id");

while($row = mysql_fetch_array($query))
{
$text = $row['DB_field_with_text_you_want_to_return'];
echo "$text";

}
?>

this page opens the DB and finds the record which the <iFrame> has specified. As you can see in the <iFrame src="load.php?id=<?= $id ?> there is a variable called $ID.
This is called when you first load the editor page.

so....

when you load the editor page, you will need to tell it which record you want to display in the iFrame part... so the URL might be:

editor.php?id=1

this will populate the iFrame src part and will look like:

<iframe id="iView" style="width: 600px; height:400px" src="load.php?id=1"></iframe>

then the load.php file will get the variable $id and open the DB and find the record with ID = 1... then that page will return the text from the DB in to the iFrame window...

I hope this is clear??!!!
I have tried to explain it as smply as possible?!!

Let me know if you need anymore help....

Maybe there could be a 3rd part to the WYSIWYG articles on this site...as this appears to be a popular question?!!

Regards,

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > PHP WYSIWYG getting frame source from DB


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five &quot;checkpoints&quot; for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Iron Speed




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway