Page 1 of 1

entering images with in text area

Posted: Mon Nov 21, 2005 10:34 am
by rami
i have a text filed in a database that text notes from the different person.
I have a php files that inserts data in to database and a php file that retieves data our of database
the text filed works fine with the plain text but problem is that the notes can have some images as well in the middle of those notes(text)

so i am not fiding way to either enter pictures between that text with in the text field or to display ot images...

how can i do it can any body provide logic or way of doing it.

by the way i have a feeling that it can be done just like in phpbb forum using codes like <img> or [img] but how can i activate the html or bb in my text fileds.

i have seen many such images middle of news in news sites
how dooes they do it..
any idea
please help..

d11wtq | Please refrain from posting your entire post in bold.... it's incredibly irritatiing and takes longer to read :roll:

Posted: Mon Nov 21, 2005 11:37 am
by Grim...
Can you show us an example of one of these news sites?

Posted: Mon Nov 21, 2005 11:38 am
by Grim...
Hang on...

Just include

Code: Select all

Lala user text 
<img src="http://url.of.image">
lalala more text
Is that what you mean?

Posted: Mon Nov 21, 2005 11:38 am
by phpdevuk
use something like htmlarea or fckedit to do it, they both work like html editors such as dreamweaver and frontpage.

Posted: Tue Nov 22, 2005 3:59 am
by rami
phpdevuk wrote:use something like htmlarea or fckedit to do it, they both work like html editors such as dreamweaver and frontpage.
can you be more illustrative
i know that
if we do
<img src= location with in that texr area
ie

Code: Select all

if (!empty($_POST['assignment']))
		{
		$d = ($_POST['assignment']);
		} 
		else 
			{
		$d = '';
			}
	

	
	if ($u && $t) 
		{ 
		$query = "insert into  assignment(tropic,teach_id,program,date,lastdate,assignment) VALUES ('$u','$t','$p',NOW(),'$su','$d')";		
		$result = @mysql_query ($query);
		
			if ($result)					{ 
			echo '<p><b>Your Assigment has been added to your Database.Please confirm in your personal page!</b></p>';
echo " <a href="giveassignment.php">Give Another Assignment</a>";
echo " <a href="index.php">Home</a>";
wouldnot that taken literally by system and will just type <img src=...
in the result

i have to text about that i think it will do so
doesnt it
do i need to activate any thing...

any other way
i am also thinking of uploading files in system and giving path...nut with in text area how ..?
thanks

Posted: Wed Nov 23, 2005 3:15 am
by phpdevuk
you could just put an <img src=" tag into the textarea and it would work just fine at displaying the image, htmlarea gives you a wysiwyg editor in the browser instead of a textarea field, one of the options in it is to insert images in to text have a look at it at http://www.dynarch.com/projects/htmlarea/ it would probably copy very well with what you want and it is easy to plug into a page.

Posted: Thu Nov 24, 2005 10:43 am
by rami
phpdevuk wrote:you could just put an <img src=" tag into the textarea and it would work just fine at displaying the image, htmlarea gives you a wysiwyg editor in the browser instead of a textarea field, one of the options in it is to insert images in to text have a look at it at http://www.dynarch.com/projects/htmlarea/ it would probably copy very well with what you want and it is easy to plug into a page.
if i directly do
<img src="...
wont it take the words literally and dispaly
img src=...
in the display page
i have just simple insert page ie

Code: Select all

if (!empty($_POST['assignment']))
		{
		$d = ($_POST['assignment']);
		} 
		else 
			{
		$d = '';
			}
	

	
	if ($u && $t) 
		{ 
		$query = "insert into  assignment(tropic,teach_id,program,date,lastdate,assignment) VALUES ('$u','$t','$p',NOW(),'$su','$d')";		
		$result = @mysql_query ($query);
		
			if ($result)	...........................

...


td width="41%"><b>Assignment</b></td>
            <td width="59%"><textarea name="assignment" cols="50" rows="15"><?php if (isset($_POST['assignment'])) echo $_POST['assignment']; ?></textarea></td>
          </tr>		
	 </table>
is the html code by default activated in the textarea
i have not tried but is it so...
but i thini it will type just <img src in result
i will
see thanks
any suggestion...

Posted: Mon Nov 28, 2005 8:24 pm
by rami
i really need help in this regard could any body give me a suggestion or solution
my application has been hampered with out it

so please help
thanks
rami

Posted: Tue Nov 29, 2005 1:40 am
by n00b Saibot
have you download & tried out HTMLArea from the link phpdevuk provided you :?:

Posted: Tue Dec 06, 2005 4:13 am
by rami
phpdevuk wrote:you could just put an <img src=" tag into the textarea and it would work just fine at displaying the image, htmlarea gives you a wysiwyg editor in the browser instead of a textarea field, one of the options in it is to insert images in to text have a look at it at http://www.dynarch.com/projects/htmlarea/ it would probably copy very well with what you want and it is easy to plug into a page.
i downloaded that application and the application works fine while inserting but when displaying the data in another page ,that has been inserted
if i use simple text area then html codes only is viewable
and if i use the same htmlarea application javascript code in the view text area or view textbox in the view page
it also displays that all tools and let user type and so all the things
i want to just plian display things what should i do
i am using php so called just let that code work

Code: Select all

<?
session_start();
//require_once ('includes/config.inc'); 
require_once ('../mysql_connect1.php'); 
$page_title = 'view';
include_once ('head.htm');

	if (isset($_GET['aid'])) 
	{
			$query = "SELECT * FROM assignment WHERE assign_id =". $_GET['aid']."";
			$result= mysql_query($query);
$pron=$row['program'];
if ($pron== "20021")
{
		$pron='BBA2002';
		} 
elseif ($pron=="20022")
{
		$pron='BCIS2002';
		} 
elseif ($pron=="20031")
{
$pron='BBA2003';
}
elseif ($pron=="20032")
{
$pron='BCIS2003';
}
elseif ($pron=="20041")
{
$pron='BBA2004';
}
elseif ($pron=="20042")
{
$pron='BCIS2004';
}
elseif ($pron =="20051")
{
$pron='BBA2005';
}
elseif ($pron =="20052")
{
$pron='BCIS2005';
}
elseif ($pron =="20053")
{
$pron='BPH2005';
}
echo '<table border="0" width="90%" cellspacing="3" cellpadding="2" align="center" bgcolor="#EFEFEF">
<tr>
<td align="left" width="30%" bgcolor="#00659C"></td>
</tr>';

		if (mysql_num_rows($result) > 0) 
		{ // if there are any rows of data, fetch the data			
				$row = mysql_fetch_array ($result);
echo "<a href="printassign.php?uid={$row['assign_id']}">Printable Version</a>";
echo "	<tr>
		<td align="left" ><b>Topic</b></td>
		<td align="left">{$row['tropic']}</td>
	</tr>\n";
echo "	<tr>
		<td align="left" ><b>TGiven Date</b></td>
		<td align="left">{$row['date']}</td>
	</tr>\n";
	echo "	<tr>
		<td align="left" ><b>Last date of submission</b></td>
		<td >{$row['lastdate']}</td>
</tr>\n";
echo "	<tr>
		<td align="left" ><b>Program</b></td>
		<td >$pron</td>
</tr>\n";

echo '</table>';
echo '<p><b>Assignment:</b> ';
echo '<p>.<textarea name="blah" cols="80" rows="15" input="disabled">', $row['assignment'], '</textarea>'.'<br />';
		} 
		else 
		{
			echo '<p>No data returned!</p>';
		} // mysql if end
	}
	else 
	{
		echo '<p>Such teacher not found.</p>';
}

/*else {
echo '<p>Missing uid!</p>';
}
*/
?>
<body bgcolor=skyblue>
<script type="text/javascript">
   _editor_url = "/htmlarea/";
   _editor_lang = "en";
</script>
<script type="text/javascript" src="/htmlarea/htmlarea.js"></script>
<script type="text/javascript" defer="1">
    HTMLArea.replaceAll();
</script>

</body>

Posted: Tue Dec 06, 2005 4:52 am
by Chris Corbyn
If you insert html into a textarea and then echo it back out to a page it will be rendered by the browser as HTML.

Have you bothered to view the HTML source code that gets sent to the browser? The only reason it would display the actual code in the browser window is if you see < & > etc inside the HTML source. In which case you're passing the textarea contents through a htmlentities() filter and thus breaking it....