php string two echo statements together [closed] - php

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
this string is breaking my code and I am not sure why. If anyone can help me correct it I would appreciate it.
if ($p == $url) { echo '<li><a class="active" href="index.php?p=' . $url . '">'
. $label . '</a></li>'; } else { echo '<li>' . $label . '</li>'; }

htmlspecialchars(urlencode($url)) and htmlspecialchars($label). The rest seems fine.

Related

How can use tab space in variable [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
"\t" is not working on my code
Tried to put a lot on .' '.
$name = '<h4 class="h4">NAME: '."\t".$firstname .' '. $midname .' '. $lastname. '</h4>';
Expected out put is
NAME: Mark stack
Put the Name: inside the <span>Name:</span> and set margin-right to the span to get your desired space.
echo $name = '<h4 class="h4"><span style = "margin-right: 20px;">NAME:</span> '.$firstname .' '. $midname .' '. $lastname. '</h4>';
Demo
html syntax cant read tab.... it dosent know it , as a charachter.
use this. <pre></pre>

Using foreach loop to create links from an array [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
Please help me create links using a php foreach loop that iterates over an array which contains the names of navbar links for a webpage.
Currently my loop creates links but when you click on them an error 404 page and displays in the url (for example when clicking on "blog"):
...homebrew-actual/blog.php>Blog <a></li><li><a href="
I would like the url to go to:
... homebrew-actual/blog.php
without the html tags.
Here is my current PHP loop:
<nav>
<ul>
<?php
$navOptions = array('index', 'showcase','about','blog','contact','forums');
foreach($navOptions AS $navOption) {
if ($navOption == $currentPage) {
print '<li>' . '' . ucfirst($navOption) . '</li>';
} else {
echo '<li>' . '<a href="/homebrew-actual/' . $navOption . '.php>' . ucfirst($navOption) . '</a></li>';
}
}
?>
<li class="special">Shop</li>
</ul>
</nav>
Please help me identify a solution to create a links for a navbar using an array with the link names and use a for loop to link to those pages.
Thank you for checking out this question.
You forgot a ":
print '<li>' . '' . ucfirst($navOption) . '</li>';
^--start href ^---end of href, missing "
Since you never close the href string, you end up with broken HTML.

php mysql / link not producing results [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
the link within the string is producing the results page just fine. However, no content is being displayed. Here is the string:
echo '<td>' . substr($row['DESCR'], 0, 40) . '</td>';
What could I do in order to get the content to display on the results page? thank You
I've added the new code, and unfortunately now, its not echoing out the string itself
echo '' . substr($row[\'DESCR\'], 0, 40) . '';
is producing a blank page.
You have space issue in the link,
Change
echo '<td>' . substr($row['DESCR'], 0, 40) . '</td>';
To
echo '<td>' . substr($row['DESCR'], 0, 40) . '</td>';

Load HTML <select> options while loading the page in php/javascript [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
How to load option dynamically,when we have to load options like eg: 1-500. as the values in select list.
Loding can be either done in php or javascript.
plz can someone provide eg/simple snippet or helpfull links? Thanks!
I tried: Javascript
for(var i=1;i<=500;i++)
{
//create new option
var option = new Option(i, "Value" + i);
//Add the new option it to the select
sel.options[i] = option;
}
Iterate over the values with a foreach, for or while loop, and just ouput whatever you need:
<?php
$html = '<select>';
for ($i=0; $i<500; $i++) {
$html .= '<option value="' . $i . '">Option ' . $i . '</option>';
}
$html .= '</select>';
echo $html;
?>

MYSQL Php parsing error [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am unable to figure out the parsing error on this piece of code.
Any help would be greatly appreciated.
echo "<li>";
echo "<a href=\"http://online.somewebsite.com/" . $info['path'] . >" . $info['value'] . "</a>";
echo "</li>";
echo '<li>' . $info['value'] . '</li>';
You forget " before > in second line
echo "<li>";
echo "" . $info['value'] . "";
echo "</li>";

Categories