RE: [PHP] html formatting in mysql post

2011-05-07 Thread Ross Hansen

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: danbr...@php.net
 Date: Fri, 6 May 2011 23:04:44 -0400
 To: hansen.r...@live.com.au
 CC: php-general@lists.php.net
 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

  
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] html formatting in mysql post

2011-05-07 Thread Ashley Sheridan
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: danbr...@php.net
  Date: Fri, 6 May 2011 23:04:44 -0400
  To: hansen.r...@live.com.au
  CC: php-general@lists.php.net
  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




[PHP] accessing data from an array within an array.

2011-05-07 Thread Adam Preece
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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] accessing data from an array within an array.

2011-05-07 Thread admin
I would suggest you print out the array to get a better understanding of the
structure first.

Print_r('PRE');
Print_r($array);
Print_r('PRE');


You can foreach over the $array['row'] 

Foreach($array['row'] as $key=$values)
{
Echo $values.PHP_EOL;
}




Richard L. Buskirk

-Original Message-
From: Adam Preece [mailto:a...@blueyonder.co.uk] 
Sent: Saturday, May 07, 2011 11:37 AM
To: php-general@lists.php.net
Subject: [PHP] accessing data from an array within an array.

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
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] accessing data from an array within an array.

2011-05-07 Thread Adam Preece
hi,

worked it out, thankyou.


On 7 May 2011, at 16:57, ad...@buskirkgraphics.com wrote:

 I would suggest you print out the array to get a better understanding of the
 structure first.
 
 Print_r('PRE');
 Print_r($array);
 Print_r('PRE');
 
 
 You can foreach over the $array['row'] 
 
 Foreach($array['row'] as $key=$values)
 {
   Echo $values.PHP_EOL;
 }
   
 
 
 
 Richard L. Buskirk
 
 -Original Message-
 From: Adam Preece [mailto:a...@blueyonder.co.uk] 
 Sent: Saturday, May 07, 2011 11:37 AM
 To: php-general@lists.php.net
 Subject: [PHP] accessing data from an array within an array.
 
 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
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Bold links

2011-05-07 Thread Michael Simiyu

hey,

some php 101 here guys :)

i want to bold the first name and last name in the code below...

?php global $current_user;
  get_currentuserinfo();

  echo 'Welcome nbsp;' . $current_user-user_firstname . \n;
  echo '' . $current_user-user_lastname . \n;
?

Thanks
Michael

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Bold links

2011-05-07 Thread admin
?php global $current_user;
   get_currentuserinfo();

   echo 'Welcome nbsp;B' . $current_user-user_firstname . /B\n;
   echo 'B' . $current_user-user_lastname . /B\n;
?




Richard L. Buskirk

-Original Message-
From: Michael Simiyu [mailto:simiyu.mich...@gmail.com] 
Sent: Saturday, May 07, 2011 1:42 PM
To: php-general@lists.php.net
Subject: [PHP] Bold links

hey,

some php 101 here guys :)

i want to bold the first name and last name in the code below...

?php global $current_user;
   get_currentuserinfo();

   echo 'Welcome nbsp;' . $current_user-user_firstname . \n;
   echo '' . $current_user-user_lastname . \n;
?

Thanks
Michael

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Bold links

2011-05-07 Thread Adam Preece
Hi,

 ?php global $current_user;
  get_currentuserinfo();
 
  echo 'Welcome nbsp;' . b.$current_user-user_firstname . /b.\n;
  echo '' b. $current_user-user_lastname . /b.\n;
 ?


On 7 May 2011, at 18:42, Michael Simiyu wrote:

 hey,
 
 some php 101 here guys :)
 
 i want to bold the first name and last name in the code below...
 
 ?php global $current_user;
  get_currentuserinfo();
 
  echo 'Welcome nbsp;' . $current_user-user_firstname . \n;
  echo '' . $current_user-user_lastname . \n;
 ?
 
 Thanks
 Michael
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Bold links

2011-05-07 Thread Michael Simiyu

Thanks alot...

On May 7, 2011, at 8:39 PM, ad...@buskirkgraphics.com wrote:


?php global $current_user;
  get_currentuserinfo();

  echo 'Welcome nbsp;B' . $current_user-user_firstname . / 
B\n;

  echo 'B' . $current_user-user_lastname . /B\n;
?



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] html formatting in mysql post

2011-05-07 Thread Ross Hansen

After doing further reading on google i have managed to get this working using 
the nl2br php command.

if anyone else wants to know how i did this.

almost the same as what was mentioned in this thread however my rows were being 
displayed using while command.

echo nl2br($row['colname']); 

Thanks again for your assistance.


 From: a...@ashleysheridan.co.uk
 To: hansen.r...@live.com.au
 CC: php-general@lists.php.net
 Date: Sat, 7 May 2011 10:32:11 +0100
 Subject: RE: [PHP] html formatting in mysql post

 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?
 
// $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: danbr...@php.net
   Date: Fri, 6 May 2011 23:04:44 -0400
   To: hansen.r...@live.com.au
   CC: php-general@lists.php.net
   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


  
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Bold links

2011-05-07 Thread Tim Streater
On 07 May 2011 at 18:42, Michael Simiyu simiyu.mich...@gmail.com wrote: 

 hey,

straw.

 some php 101 here guys :)

 i want to bold the first name and last name in the code below...

It's not PHP 101, it's HTML 101.

tim


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php