Anyone good with PHP

KSclans

New Member
Messages
197
Reaction score
0
Points
0
db.php is a file that connect to my database
and I trying to array subtitle byline and content that is from clanwebs

PHP:
<?php

require_once 'db.php';

$result = mysql_query("SELECT subtitle, byline, content FROM post WHERE `name` ='clanwebs'");
$boxes = array();
while ($row = mysql_fetch_assoc($result))
{
  $new_box = array('subtitle' => $row['subtitle'], 'content' => $row['content'],  'byline' => $row['byline']);
  $boxes[] = $new_box;
}
$content['boxes'] = $boxes;

echo "[$boxes]";

?>

but then I echo the variable boxes and all it show is Array, not the stuff that i array the word Array

why it showing the word array like i echo 'array' instead pf echo '$boxes'
 

natsuki

New Member
Messages
112
Reaction score
0
Points
0
because the string value of an array is "Array". If you want the contents try var_dump($boxes) or print($boxes)
 

KSclans

New Member
Messages
197
Reaction score
0
Points
0
Nevermind my friend tell me the answer
but he say loopeach on it because it a looping array
 

dickey

New Member
Messages
128
Reaction score
0
Points
0
You need loops to do the manipulations but if you just want to check contents print_r($boxes) would do.
 

KSclans

New Member
Messages
197
Reaction score
0
Points
0
I need a box(es) that have one title and muti content like this

My Title
1. hello
2. hi
3. bye
My 2nd Title
1. ,,dfd,
2. llddfl

something like that... and i create a table for this kind of table name ol (CSS div class)
and have field name title content

but I have 3 content (maybe more depend on what users want)

should I have 3 row for the array ? like

name title content
----------------------------------
clanwebs HI hello
clanwebs HI hi
clanwebs Hi bye

but in array how do I tell the browser that row that have the same title is one box

for each box that have 1 title and 1 content
I select the boxes that belong to the user

SELECT subtitle, byline, content FROM post WHERE `name` ='clanwebs'");


but what i put for 1 title and muti content?
how do i select "the same" title ...
 

xmakina

New Member
Messages
264
Reaction score
0
Points
0
You either want to just make sure the <td>'s occur in the same place or use <br /> to add a line break.

Although I don't think this is what you want (both are incredibly simple solutions) but your english is so broken I'm confused as to what your after. Perhaps you can provide an example on the internet or draw what your after and upload it?
 

phpasks

New Member
Messages
145
Reaction score
0
Points
0
HTML:
<Table>
<Tr>
<Td>My Title</td>
</tr>
<Tr>
<Td>1. hello</td>
</tr>
<Tr>
<Td>2. hi</td>
</tr>
<Tr>
<Td>3. bye</td>
</tr>
<Tr>
<Td> My 2nd Title</td>
</tr>
<Tr>
<Td>1. ,,dfd,</td>
</tr>
<Tr>
<Td>2. llddfl

You can use this way or Your Array
PHP:
<?php
echo "<Table>";
while(list($key, $val) = each($array_name))
{
      echo "<tr><Td>".$val.</td></tr>
}
echo "</table>";
?>

I need a box(es) that have one title and muti content like this

My Title
1. hello
2. hi
3. bye
My 2nd Title
1. ,,dfd,
2. llddfl

something like that... and i create a table for this kind of table name ol (CSS div class)
and have field name title content

but I have 3 content (maybe more depend on what users want)

should I have 3 row for the array ? like

name title content
----------------------------------
clanwebs HI hello
clanwebs HI hi
clanwebs Hi bye

but in array how do I tell the browser that row that have the same title is one box

for each box that have 1 title and 1 content
I select the boxes that belong to the user

SELECT subtitle, byline, content FROM post WHERE `name` ='clanwebs'");


but what i put for 1 title and muti content?
how do i select "the same" title ...
 

KSclans

New Member
Messages
197
Reaction score
0
Points
0
I know my english is not that good, but... from the top first post
db.php is a file that connect to my database
and I trying to array subtitle byline and content that is from clanwebs

PHP:
<?php

require_once 'db.php';

$result = mysql_query("SELECT subtitle, byline, content FROM post WHERE `name` ='clanwebs'");
$boxes = array();
while ($row = mysql_fetch_assoc($result))
{
  $new_box = array('subtitle' => $row['subtitle'], 'content' => $row['content'],  'byline' => $row['byline']);
  $boxes[] = $new_box;
}
$content['boxes'] = $boxes;

?>

I am using template separate HTML with PHP
===================================
Now I want

I need a box(es) that have one title and muti content like this

My Title
1. hello
2. hi
3. bye
My 2nd Title
1. ,,dfd,
2. llddfl

something like that... and i create a table for this kind of table name ol (CSS div class)
and have field name title content

but I have 3 content (maybe more depend on what users want)

should I have 3 row for the array ? like

name title content
----------------------------------
clanwebs HI hello
clanwebs HI hi
clanwebs Hi bye

but in array how do I tell the browser that row that have the same title is one box

for each box that have 1 title and 1 content
I select the boxes that belong to the user

SELECT subtitle, byline, content FROM post WHERE `name` ='clanwebs'");


but what i put for 1 title and muti content?
how do i select "the same" title ...


Does it make sense now?:biggrin:

anyway so array the table in database like that it will show


HI
hello
HI
hi
Hi
bye


(it won't show clanwebs (username) because i use it to select which row to show so the browser will only show the row that belongs to the user.)

but what code can tell the browser to only display the same title only once and then display its content

Hi (title )
Hello (content)
hi (content)
bye (content)
 
Last edited:

Soki

Banned
Messages
857
Reaction score
1
Points
0
I believe he wants it to say "Hello, clanwebs". Like as below:

Username ll Title ll Content1 ll Content2 ll Content3
=======================================
clanwebs ll Hi ll Hello ll hi ll bye

Edit: Line up the chart your self. :p
It didn't comeout with the spaces...
 

KSclans

New Member
Messages
197
Reaction score
0
Points
0
Yes I can do that but what if i have content4 ? content5 ? Unlimited?
then I need to add a lot of content in order to make sure that the users (who insert new row) have enough content to insert their data to my database.
 

xmakina

New Member
Messages
264
Reaction score
0
Points
0
AHH. Your mistake is how your retrieve the data in the first place.

I'm not going to write the code for you, but here's what you need to do:

FOR EACH field IN $result
<th>Field Name</th>
END FOR

FOR EACH row IN $result
<tr>
FOR EACH value in $result
<td>Value</td>
END FOR
</tr>
END FOR


Okay? Go check out w3schools and read up the PHP manual with its SQL commands.
 

KSclans

New Member
Messages
197
Reaction score
0
Points
0
?_? Yea my questions is what code is the FOR EACH ? that what i asking...
how do i select "the same" title ...
so what you saying what I will get is

field name field name field name
user1 title 1 content1
user1 title 1 content2
user1 title 2 content1
user1 title 2 content2
user2 title 3 content1
user2 title 3 content2

but I need
User1
Title 1 : content1, content2 ...
Title 2 : content1, content2
.
.
.
User2 .....

in yours It will show 2 time title 1 and 2 and 3...but I only want title to show once and show all it content
 
Last edited:
Top