Rokit
-
Posts
4 -
Joined
-
Last visited
Never
Posts posted by Rokit
-
-
First, here's some code:
$result = mysql_query("SELECT standard FROM thestandards WHERE id={$theSearch}", $connection); if (!$result) { die("Database connection failed: " . mysql_error()); } while ($row = mysql_fetch_array($result)) { $query = $row[0]; } // echo $testing = nl2br($query); $subStrings = explode('\n', $query); echo $subStrings[0] . "<br />"; // outputs entire query echo $subStrings[1] . "<br />"; // undefined offset echo $subStrings[2] . "<br />"; // undefined offset echo $subStrings[3] . "<br />"; // undefined offset
So, the data I'm retrieving from the database is several small paragraphs. I want to take these paragraphs, separate them, and put them into an array. I tried using the explode function with the newline char, but for some reason it doesn't work. I can get it to work if I want to go explicitly add "\n"s in the database everywhere, but that just doesn't seem practical. nl2br doesn't work for what I need, but I find it interesting that this function is somehow able to "see" all the newlines in the query, whereas the explode function cannot. Explode is really what I need, but I've tried '\n', '\r', '\r\n' and nothing works. Thanks for the help.
-
I agree with Requinix; however, the question could be read as how to populate the text area with content from the database ("The text is provided by a database and I want to format it for the user")
Oh ok, so it has to be submitted. Yeah, I thought of that right after I posted, litebearer. It would probably be better just getting the info straight from the database, then I can just format it and put it into the text area. Thanks anyway guys.
-
I'm trying to retrieve the text from a text area and put this in a PHP variable without submitting the form. The text is provided by a database and I want to format it for the user. How can I do this with PHP?
So basically:
<form id="createForm" name="createForm" method="post" action=""> <textarea name="subjectTextArea" id="subjectTextArea" cols="45" rows="5"> This is the text I want to put in a PHP variable before the form is submitted. </textarea> </form> <?php $txtArea = ? ?>
Thanks for the help.
separate query using newlines (retrieving not inserting)
in PHP Coding Help
Posted
By God it worked. Seems no matter what programming language I've always been able to use ' and " interchangeably. Thanks for the help.