Jump to content

How to array this


KYKK

Recommended Posts

EDIT: QUESTION 1All i have is that and in database i have a name clanwebs and some other info in field subtitle, byline, content and i trying to array it

$result = mysql_query("SELECT title, content FROM custom_fields WHERE user='user1'");$boxes = array();while ($row = mysql_fetch_assoc($result)){  $new_box = array('title' => $row['title'], 'content' => $row['content']);  $boxes[] = $new_box;}$content['boxes'] = $boxes;

for each box that have 1 title and 1 content and what i put for 1 title and muti content?I thinking something like echo all Hi title and it content same as how you echo the boxes for each user???

Link to comment
Share on other sites

You mean like

$var = array(	"key1" => array("item1", "item2", "item3"),	"key2" => array("item1", "item2", "item3"));

Link to comment
Share on other sites

O i thought only justsomeguy going to answer my post, because only him will keep follow my questions to pages... so last thread we did a 1 title and 1 content array and get data from databaseso in database we haveid title content===============================1 hi HI content for Hi1 hello hello ...1 bye bye ....1 cya cya ,,, 2 whatever whatever content there are2 some title bla bla bla3 ..... ...4 title ...and in array $result = mysql_query("SELECT title, content FROM custom_fields WHERE user_id=1");$boxes = array();while ($row = mysql_fetch_assoc($result)){ $new_box = array('title' => $row['title'], 'content' => $row['content']); $boxes[] = $new_box;}$content['boxes'] = $boxes;select the title and content from the user we have or we can do user_id=$Get_user or something then we don't need to change code for different user...and it will array the user title and rowand now i have 1 title with muti-content and I want to have like a bullet list (and a list have more then one thing...)and so I thought having the database doid title content==================1 Hi Hi1 Hi Hello1 Hi Hey1 Bye bye1 Bye bye bye1 Bye cya1 bye later1 somemore ....1 whatever ....2 for different users22...Like that and I though if we could do same thing which select the user first and select content that have the same title and echo the title 1 time and echo it all the contentI have no idea how to put THE SAME Title in code.....so get what i mean?

Link to comment
Share on other sites

EDIT: QUESTION 1 (a New array questions)All i have is that and in database i have a name clanwebs and some other info in field subtitle, byline, content and i trying to array it

<?phprequire_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']);  $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 ArrayI did this before but where i go wrong?

Link to comment
Share on other sites

That's because $boxes is an array. You need to echo the contents of the array, through the use of a foreach() loop or such. For debugging purposes you can use print_r().

Link to comment
Share on other sites

do you mean boxes IS the word array ? but I have the template system which you separate PHP and HTML, and I put {*boxes} in HTML template I use $content['name'] = $row['name']; and I put {*name} in HTML and it will show $row['name']that why I use $content['boxes'] so I can put {*boxes}but I don't understand why it showing the word array instead of the stuff I want from databaseand I successfully use foreach loop and i able to see the result...but I need {*boxes} to have the data so how can I do that?

Link to comment
Share on other sites

Now I need a box(es) that have one title and muti content like thisMy Title1. hello2. hi3. byeMy 2nd Title1. ,,dfd,2. llddflsomething like that... and i create a table for this kind of table name ol (CSS div class)and have field name title contentbut I have 3 content (maybe more depend on what users want)should I have 3 row for the array ? likename title content----------------------------------clanwebs HI helloclanwebs HI hiclanwebs Hi byebut in array how do I tell the browser that row that have the same title is one boxfor each box that have 1 title and 1 contentI 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 ...

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...