PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Mon Sep 16, 2019 8:59 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: concatanating
PostPosted: Tue Jan 28, 2014 4:34 am 
Offline
Forum Commoner
User avatar

Joined: Fri Jan 03, 2014 6:30 am
Posts: 95
Location: Vancouver Canada
Can someone explain to me how concatenation is used in this function?

1- why does value= $row[id] needs to be concatenated on both sides?

the result of this function returns a list rows with a check-box at the beginning of the line followed by firstname, lastname and email address all equally spaced on the same line. there is a tidbit in there I don't quite get because if I was to write an inline echo line to have the same output, I would write it differently and I am trying to figure out why there is a difference?

or does it have to do with the fact that it is concatenated inside the array todelete[] and then used by the delete query? but that poses a problem since I think we would need to use an explode function... as you can see, I'm not clear on theory and design question.

Syntax: [ Download ] [ Hide ]
// Display the customer rows with checkboxes for deleting
$query = "SELECT * FROM email_list";
$result = mysqli_query($dbc, $query);
while ($row = mysqli_fetch_array($result)) {
echo '<input type="checkbox" value="' . $row['id'] . '" name="todelete[]" />';
echo $row['first_name'];
echo ' ' . $row['last_name'];
echo ' ' . $row['email'];
echo '<br />';
}
 


Top
 Profile  
 
 Post subject: Re: concatanating
PostPosted: Tue Jan 28, 2014 6:33 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6425
Location: Montreal, Canada
You're using a single quote to delimit your strings. The complete string has three components, so you need two concatenation operators. The first operator joins 2 to 1, the second joins 3 to (1 + 2).
Syntax: [ Download ] [ Hide ]
'<input type="checkbox" value="' // 1
$row['id'] // 2
'" name="todelete[]" />' // 3

You could restructure it as above with an echo at the start of each line and achieve the same result.

_________________


Top
 Profile  
 
 Post subject: Re: concatanating
PostPosted: Tue Jan 28, 2014 1:11 pm 
Offline
Forum Commoner
User avatar

Joined: Fri Jan 03, 2014 6:30 am
Posts: 95
Location: Vancouver Canada
ok yes this makes sense. I think I been looking at it as being part of an input field which is throwing me off since a form is usually between HTML tags and then add a php tag in between for the value. Thanks for your help, much appreciated


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group