Arrays

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

pinehead18
Forum Contributor
Posts: 329
Joined: Thu Jul 31, 2003 9:20 pm

Post by pinehead18 »

well i've probably changed it 90 times. LOL
But lets see what i got atm.

I have what you have atm. It actually prints explode( and it dones't actually perform the function. I was trying to figure out why but kept getting parse errors. Seems my extreme newbyness is catching up to me :(

$sql = "SELECT * FROM users where user='$name'";
$result = mysql_query($sql) or die(mysql_error());

while($arr = mysql_fetch_array($result))
{
$pics[] = $arr["add_picts"];
}
foreach($pics as $picid)
{
echo 'Print HTML for '.join('<br />', explode(',', $picid)).'<br />";

}

Thanks so much for your help

Code: Select all

<?php

?>

Code: Select all

<?php

?>
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

.'<br />";
^^ should be
.'<br />';
pinehead18
Forum Contributor
Posts: 329
Joined: Thu Jul 31, 2003 9:20 pm

Post by pinehead18 »

yay thanks!!! I'm sure i'll have tons more questions :). I wish people would post how to connect to sql and stuff on here so i can give back the help i recieved lol
pinehead18
Forum Contributor
Posts: 329
Joined: Thu Jul 31, 2003 9:20 pm

Post by pinehead18 »

Ok didn't take me long to come back.

I need to make it so echo 'Print HTML for '.join('<br />', explode(',', $picid)).'<br />";

turns into $table .= 'Print HTML for '.join('<br />', explode(',', $picid)).'<br />';


However, parse error city after you help me on this LOL do you know of an article that talks about all the ' ". "'; i need to use?
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Hmm..i don't see a parse error there :o

The rules on quotes etc are pretty simple but can seem complicated as there's many ways to mix/match them .. and i don't know of any docs (apart from the manual) that goes into details about all the possibilities.

In general you ....
use single quotes for echoing strings (with no vars), like echo 'foo bar';
use double quotes if there's vars in there, like echo "foo $bar";

Usually the biggest trap is doing echo 'foo $bar'; which won't do as you expect, variables arn't 'interpolated' inside single quotes, which just means you see $bar instead of $bar's value :o
</bad explanation>
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

what do you mean, you want the first line to turn into the second line????
i think your talking about concatanation ya know

Code: Select all

$name=pinehead18;
echo "your name is".$name.".";
//you can do the same thing in a $var

$var = "your name is".$name.".";
catch my drift?

may the force be with you!!!!
pinehead18
Forum Contributor
Posts: 329
Joined: Thu Jul 31, 2003 9:20 pm

Post by pinehead18 »

No, my template system is kinda weird. I put all the contents of the html page in $output

So i need to make $table = "the for each loop with my html" and put it in my $output statement.
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

huh, i'm really confused..........i should have slept last night.....DAMN addictive PHP
pinehead18
Forum Contributor
Posts: 329
Joined: Thu Jul 31, 2003 9:20 pm

Post by pinehead18 »

haha you got that right. Addictive. It wouldn't be so bad if i could learn it quicker :(
pinehead18
Forum Contributor
Posts: 329
Joined: Thu Jul 31, 2003 9:20 pm

Post by pinehead18 »

basically i need to take
echo 'Print HTML for '.join('<br />', explode(',', $picid)).'<br />';

and turn it into $table . = "Print HTML for '.join('<br />', explode(',', $picid)).'<br />';

without a city of parse errors
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post by DuFF »

Code: Select all

<?php
$table .= "Print HTML for " . join('<br />', explode(',', $picid)) . "<br />";
?>
Does that work?
pinehead18
Forum Contributor
Posts: 329
Joined: Thu Jul 31, 2003 9:20 pm

Post by pinehead18 »

yes, thank you i'm in good shape now.

thank you all for your help

I think i figured alot out today about arrays

Been a long day :(
Post Reply