php-general Digest 8 May 2011 11:56:09 -0000 Issue 7303
Topics (messages 312716 through 312724):
Re: accessing data from an array within an array.
312716 by: admin.buskirkgraphics.com
312717 by: Adam Preece
Bold links
312718 by: Michael Simiyu
312719 by: admin.buskirkgraphics.com
312720 by: Adam Preece
312721 by: Michael Simiyu
312723 by: Tim Streater
Re: html formatting in mysql post
312722 by: Ross Hansen
How to DUMP $_POST parameters to a log file? Very useful and missing in the
php.net
312724 by: Eli Orr (Office)
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 ---
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:[email protected]]
Sent: Saturday, May 07, 2011 11:37 AM
To: [email protected]
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
--- End Message ---
--- Begin Message ---
hi,
worked it out, thankyou.
On 7 May 2011, at 16:57, <[email protected]> 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:[email protected]]
> Sent: Saturday, May 07, 2011 11:37 AM
> To: [email protected]
> 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
>
--- End Message ---
--- Begin Message ---
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 ' . $current_user->user_firstname . "\n";
echo '' . $current_user->user_lastname . "\n";
?>
Thanks
Michael
--- End Message ---
--- Begin Message ---
<?php global $current_user;
get_currentuserinfo();
echo 'Welcome <B>' . $current_user->user_firstname . "</B>\n";
echo '<B>' . $current_user->user_lastname . "</B>\n";
?>
Richard L. Buskirk
-----Original Message-----
From: Michael Simiyu [mailto:[email protected]]
Sent: Saturday, May 07, 2011 1:42 PM
To: [email protected]
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 ' . $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
--- End Message ---
--- Begin Message ---
Hi,
> <?php global $current_user;
> get_currentuserinfo();
>
> echo 'Welcome ' . "<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 ' . $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
>
--- End Message ---
--- Begin Message ---
Thanks alot...
On May 7, 2011, at 8:39 PM, <[email protected]> wrote:
<?php global $current_user;
get_currentuserinfo();
echo 'Welcome <B>' . $current_user->user_firstname . "</
B>\n";
echo '<B>' . $current_user->user_lastname . "</B>\n";
?>
--- End Message ---
--- Begin Message ---
On 07 May 2011 at 18:42, Michael Simiyu <[email protected]> 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
--- End Message ---
--- Begin Message ---
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: [email protected]
> To: [email protected]
> CC: [email protected]
> 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: [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 ---
Dear PHP Gurus,
I need dump a $_POST parameters as part of debug process with a client.
Any know service to make this ?
I know $_POST is an Array but I look for a service function that can
save the parsed array into a file.
let say :
$stt = save_POST_into_file ($_POST, $fp);
Any idea ?
--
Best Regards,
*Eli Orr*
CTO & Founder
*LogoDial Ltd.*
M:+972-54-7379604
O:+972-74-703-2034
F: +972-77-3379604
Plaut 10, Rehovot, Israel
Email: [email protected]_
Skype: _eliorr.com_
--- End Message ---