php-general Digest 7 May 2011 15:37:00 -0000 Issue 7302
Topics (messages 312709 through 312715):
html formatting in mysql post
312709 by: Ross Hansen
312711 by: Daniel Brown
312713 by: Ross Hansen
312714 by: Ashley Sheridan
Gentle (Friday) Reminder
312710 by: Daniel Brown
312712 by: Camilo Sperberg
accessing data from an array within an array.
312715 by: Adam Preece
Administrivia:
To subscribe to the digest, e-mail:
[email protected]
To unsubscribe from the digest, e-mail:
[email protected]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
Hey Guys,
I am using a form to post information to a MySQL table which is then echo(ing)
back out to a web page. it will sort of be like facebook where you can post
messages and stuff on peoples walls. The only issue is at the moment i can get
the formatting to stay. When i echo the table out from mysql it all gets
displayed on one line rather than seeing my new lines which i typed in the text
box.
I do know that this is a HTML error as it was never given the format tags when
the content was posted in the table.
I have seen something about NL2BR and also something about strip slashes but i
am not sure how to incorporate them into my post.
Could someone please advise?
--- End Message ---
--- Begin Message ---
On Fri, May 6, 2011 at 22:52, Ross Hansen <[email protected]> wrote:
>
> Hey Guys,
>
> I am using a form to post information to a MySQL table which is then
> echo(ing) back out to a web page. it will sort of be like facebook where you
> can post messages and stuff on peoples walls. The only issue is at the moment
> i can get the formatting to stay. When i echo the table out from mysql it all
> gets displayed on one line rather than seeing my new lines which i typed in
> the text box.
> I do know that this is a HTML error as it was never given the format tags
> when the content was posted in the table.
>
> I have seen something about NL2BR and also something about strip slashes but
> i am not sure how to incorporate them into my post.
>
> Could someone please advise?
Well, let's start with an easy question: have you *tried* them?
<?php
// $row = /* Database row grabbed elsewhere in your code. */'';
if (is_array($row)) {
foreach ($row as $r) {
echo nl2br($row).PHP_EOL;
}
} else {
echo nl2br($row).PHP_EOL;
}
?>
Error-handling and the remainder of checking is up to you.
--
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/
--- End Message ---
--- Begin Message ---
thanks for your responses,
so i understand that this code is using an array, however i havn't really used
arrays as i am a novice php coder.
Should this code be used on the php code for inserting the data into the MySQL
table or is it used when retrieving the data using the select function?
<?php
// $row = /* Database row grabbed elsewhere in your code. */'';
if (is_array($row)) {
foreach ($row as $r) {
echo nl2br($row).PHP_EOL;
}
} else {
echo nl2br($row).PHP_EOL;
}
?>
your help is appreciated.
----------------------------------------
> From: [email protected]
> Date: Fri, 6 May 2011 23:04:44 -0400
> To: [email protected]
> CC: [email protected]
> Subject: Re: [PHP] html formatting in mysql post
>
> On Fri, May 6, 2011 at 22:52, Ross Hansen wrote:
> >
> > Hey Guys,
> >
> > I am using a form to post information to a MySQL table which is then
> > echo(ing) back out to a web page. it will sort of be like facebook where
> > you can post messages and stuff on peoples walls. The only issue is at the
> > moment i can get the formatting to stay. When i echo the table out from
> > mysql it all gets displayed on one line rather than seeing my new lines
> > which i typed in the text box.
> > I do know that this is a HTML error as it was never given the format tags
> > when the content was posted in the table.
> >
> > I have seen something about NL2BR and also something about strip slashes
> > but i am not sure how to incorporate them into my post.
> >
> > Could someone please advise?
>
> Well, let's start with an easy question: have you *tried* them?
>
> >
> // $row = /* Database row grabbed elsewhere in your code. */'';
>
> if (is_array($row)) {
> foreach ($row as $r) {
> echo nl2br($row).PHP_EOL;
> }
> } else {
> echo nl2br($row).PHP_EOL;
> }
> ?>
>
> Error-handling and the remainder of checking is up to you.
>
> --
>
> Network Infrastructure Manager
> http://www.php.net/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--- End Message ---
--- Begin Message ---
On Sat, 2011-05-07 at 16:01 +0800, Ross Hansen wrote:
> thanks for your responses,
>
> so i understand that this code is using an array, however i havn't really
> used arrays as i am a novice php coder.
> Should this code be used on the php code for inserting the data into the
> MySQL table or is it used when retrieving the data using the select function?
>
> <?php
> // $row = /* Database row grabbed elsewhere in your code. */'';
>
> if (is_array($row)) {
> foreach ($row as $r) {
> echo nl2br($row).PHP_EOL;
> }
> } else {
> echo nl2br($row).PHP_EOL;
> }
> ?>
>
> your help is appreciated.
>
> ----------------------------------------
> > From: [email protected]
> > Date: Fri, 6 May 2011 23:04:44 -0400
> > To: [email protected]
> > CC: [email protected]
> > Subject: Re: [PHP] html formatting in mysql post
> >
> > On Fri, May 6, 2011 at 22:52, Ross Hansen wrote:
> > >
> > > Hey Guys,
> > >
> > > I am using a form to post information to a MySQL table which is then
> > > echo(ing) back out to a web page. it will sort of be like facebook where
> > > you can post messages and stuff on peoples walls. The only issue is at
> > > the moment i can get the formatting to stay. When i echo the table out
> > > from mysql it all gets displayed on one line rather than seeing my new
> > > lines which i typed in the text box.
> > > I do know that this is a HTML error as it was never given the format tags
> > > when the content was posted in the table.
> > >
> > > I have seen something about NL2BR and also something about strip slashes
> > > but i am not sure how to incorporate them into my post.
> > >
> > > Could someone please advise?
> >
> > Well, let's start with an easy question: have you *tried* them?
> >
> > >
> > // $row = /* Database row grabbed elsewhere in your code. */'';
> >
> > if (is_array($row)) {
> > foreach ($row as $r) {
> > echo nl2br($row).PHP_EOL;
> > }
> > } else {
> > echo nl2br($row).PHP_EOL;
> > }
> > ?>
> >
> > Error-handling and the remainder of checking is up to you.
> >
> > --
> >
> > Network Infrastructure Manager
> > http://www.php.net/
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
I think it would be well worth getting a book out on PHP or reading
through the various online tutorials and the PHP manual. It will explain
basic things like connecting to the database, using functions, echoing
content to the screen, etc.
--
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
<?php
$posting = array('bottom','interspersed','top');
// Feel free to add on....
$destinations = array('to hell','away','read the archives and see
why we don\'t like top-posting','to disneyland.... then die','anywhere
but here');
$point = array_rand($destinations);
foreach ($posting as $p) {
if ($p == 'top') {
// @todo - remind folks of rules: http://links.parasane.net/fb6k
echo 'Just remember.... top-posting on the list means you
can go '.$destinations[$point].'.'.PHP_EOL;
}
}
?>
--
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/
--- End Message ---
--- Begin Message ---
What do you mean by that? (irony lvl: 100%)
Sent from my iPhone
On 06-05-2011, at 22:58, Daniel Brown <[email protected]> wrote:
> <?php
>
> $posting = array('bottom','interspersed','top');
>
> // Feel free to add on....
> $destinations = array('to hell','away','read the archives and see
> why we don\'t like top-posting','to disneyland.... then die','anywhere
> but here');
>
> $point = array_rand($destinations);
>
> foreach ($posting as $p) {
>
> if ($p == 'top') {
>
> // @todo - remind folks of rules: http://links.parasane.net/fb6k
> echo 'Just remember.... top-posting on the list means you
> can go '.$destinations[$point].'.'.PHP_EOL;
>
> }
> }
> ?>
>
> --
> </Daniel P. Brown>
> Network Infrastructure Manager
> http://www.php.net/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--- End Message ---
--- Begin Message ---
hello all.
im trying to make a function that fetches all rows in the database and stores
each row (Array) within an array.
so the code is as follows:
public function fetch_all($table_name,$order = "DESC"){
$array['row'] = array();
strtoupper($order);
$query = "SELECT * FROM `{$table_name}` ORDER BY id
{$order}";
$result = $this->gen_query($query);
while($row = $this->fetch_assoc($result)){
$array['row'][] = $row;
}
if($this->sql_error_check($result)){
return $array;
}
}
this returns (ill just paste 1 row for the sake of the email length:
Array ( [row] => Array ( [0] => Array ( [id] => 9 [name] => TESTER [title] =>
TESTER [heading] => TESTER [text] =>
TESTER
[gallery_id] => 0 [meta_desc] =>
TESTER
[meta_keywords] => TESTER [meta_author] =>
TESTER
[page_id] => 0 [date_time] => 2011-05-07 06:49:39 [image] => [user_access_id]
=> 1 )
How do i access each array within the array and throw out the data for each one.
im pretty confused on this one.
any help would be appreciated.
Adam
--- End Message ---