(first post ho yeah :) )
So,I have a very strange problem:
I have a <form> to edit some options for each users in a table.
So I use
while (blablabla req sql)
{
echo '<tr><td>['name']</td><td>['firstname']</td><td><button for modal appear></td></tr>';
echo 'my modal here';
}
(this is not the true code)
And... it work but it's look very very ugly (see image 1 when the form is out of the while and image 2 when I put the form into the while)
Any solution?
Code here >> http://paste.ideaslabs.com/show/Tn4cUpjjos
Code generated [only the end of one row] >> http://paste.ideaslabs.com/show/Df4gvrJoS
You have just messed up the HTML. Remember, PHP is just generating an HTML, that you did not do properly. Do something like:
while (blablabla req sql)
{
echo "<tr>";
echo '<td>['name']</td><td>['firstname']</td><td><button for modal appear>';
echo "</tr>";
echo 'my modal here';
}
More suggestions:
Inspect your generated HTML and try to figure out why wrong HTML was generated. Stop comparing UIs.
After one weekend of reflexion I'have finnaly find a way to solve this problem:
I put my modal in a exterior content (at the top of my php page) and in a new while, with the same request
2 same separate request like that
result3 = $bdd->query("SELECT * FROM TABLE_1");
result3 = $bdd->query("SELECT * FROM TABLE_1");
At the top of my .php page after <body>
<div header>
while ($ligne = $result3->fetch_assoc()){
echo '<form></form>';
}
</div>
And after, my table with:
while ($ligne = $result3->fetch_assoc()){
echo '<table></table>';
}
That's all !
Correct my english or ask me if you have a similar problem like that ;)
Related
I have created a custom wordpress post type everything works but my client asked me to insert a function that doenst show the button if the link field is empty that is also working but when I want to display the tekst or link the part where the php is inserted just doesnt shows up what am I doing wrong
I am able to get the data on other parts of this php file but not in this part of the page
<?php
$linktitle = $day_aray=get_field("under_shoe_button_title");
$linkexist = get_field("under_shoe_button_link");
echo($linktitle);
if (empty($linkexist)) {
echo '<html> <p></p></html>' ;
}
else {
echo '<html>
<a href="google.nl" class="button primary is-bevel box-shadow-3 box-shadow-4-hover expand" style="border-radius:5px;"
</html> <?php echo($linktitle); ?> <html><span></span>
<i class="icon-shopping-cart"></i></a>
</html>';
}
?>
If you would look carefully, you would notice, that you are echoing a string where, inside the string, you are trying to echo again. Even with little programming knowledge, you should understand, that it is not logical to do that.
The same goes for php opening <?php tag. You opened the tag at start of the page and later on, inside a string, you are trying to open it again. This does not work.
Instead, close the string (or escape it) and then add the echo option.
echo '<html>
<a href="google.nl" class="button primary is-bevel box-shadow-3 box-shadow-4-hover expand" style="border-radius:5px;"
</html>';
echo($linktitle);
echo '<html><span></span>
<i class="icon-shopping-cart"></i></a>
</html>';
And please, read the comments to you question and learn basic HTML
There are so many things wrong in your code
Firstly you are using echo inside echo you should use concatenation instead.
so you want to echo it like this
echo '<your html code>'.$linktitle.'<your other html code>';
Also your html code is wrong coz u are using many html tags.
I'm using bootstrap for my popup window. The popup winodw works fine.
Here is the code
<?php if(......my if condition for popup.......){ ?>
<a data-target="#remoteModal" data-toggle="modal" href="popup.php?book_code=<?php echo $row['BookCode']; ?>&month=<?php echo $month; ?>">My PopUp Link</a>
<?php } ?>
When I use print preview using File >> PrintPreview, the link is printed in the preview section. i.e the link is viewable ( popup.php?book_code=1&month=Apr )
How can I eliminate this?
First time i face this problem.
The print preview is like this
S.No Book Name Book Code
1 ABC 20
(popup.php?book_code=1&month=Apr )
2 DEF 40
(popup.php?book_code=1&month=Apr )
Found the solution here in this page
https://drupal.stackexchange.com/questions/59900/how-to-get-rid-of-added-urls-when-printing-a-bootstrap-themed-page
May be this will be useful..
Just what i did is.. opened the bootstrap.css
Removed these lines from the css
a[href]:after {
content: " (" attr(href) ")";
}
This will surely help someone..
Thanks,
Kimz
Here's the problem, I am trying to echo a statement or an array after dynamically generated HTML, and unfortunately the thing that i want to echo goes above the HTML, is there any way to echo it after that dynamic HTML or work around?
Code:
Link 1
Link 2
if(isset($_GET["id"]) && $_GET["id"] == "do_something") {
$html = "dynamic html generate";
echo $html;
//after this im using foreach
foreach($array as $item) { echo $item . "<br />"; }
}
As I click one of these two , dynamically generated HTML shows up. Now for example I have an array:
$array = array("error1", "error2");
All the generated PHP goes above the dynamic HTML :/.
How should i fix it so that i can echo all of this array below the dynamic HTML?
Thanks
Use buffering with ob_start
ob_start();
// dynamic html code generate
$dynamic_html = ob_get_clean();
echo $dynamic_html;
// your code
echo $dynamic_html;
Sounds like you missed some closing tags (most likely </table>) in the dynamic html. Thats why the later generated echo gets displayed at the top.
Example (Note the missing closing table):
<?php
echo "<table><tr><td>TableText</td></tr>";
echo "I should be bellow the table, but going to the top.";
?>
will produce:
I should be bellow the table, but going to the top.
TableText
In PHP i'm using the following code to put a banner at the top of my website.
$eventinfo = simplexml_load_file("eventinfo.xml");
<div id="eventinfo"><?php foreach($eventinfo->children() as $child){ $final = $child["name"]."...<a href='".$child["adr"]."'>more info...</a>"; } ?>
</div>
The XML doc is available at the following: http://eastsidespeedway.raceresults.co/eventinfo.xml
If you go to http://eastsidespeedway.raceresults.co/index.php you'll see that the more info... link is showing up twice. One with the correct link, and the other with a link to the same page (index.php).
Can anyone shed some light on what I'm doing wrong?
Also. If you see anything that I'm doing wrong, or you know something that's easier - let me know! This is my first time using XML/PHP so I'm kinda just wingin it. Haha.
this will work for you
<?php
$doc = new DOMDocument();
$doc->load('http://eastsidespeedway.raceresults.co/eventinfo.xml');
$title = $doc->getElementsByTagName('title');
$link = $doc->getElementsByTagName('link');
//print_r($eventinfo);
?>
<div id="eventinfo">
<?php echo $title->item(0)->getAttribute('name'); ?>
<a href='<?php echo $link->item(0)->getAttribute('adr'); ?>'>More Infoo..</a>
</div>
If you look at your source:
<div id="eventinfo">5/18/2013 - Al Smiley Memorial...<a href=''>more
info...</a>...<a href='http://www.eastsidespeedway.com/dirt.html'>more
info...</a></div>
You've got two hyperlinks- one href is blank meaning that it will redirect to the current page, check your HTML code first to see if you've accidentally duplicated the element, otherwise look at the construction of your string in the php code
I haven't found anytihng in Google or the PHP manual, believe it or not. I would've thought there would be a string operation for something like this, maybe there is and I'm just uber blind today...
I have a php page, and when the button gets clicked, I would like to change a string of text on that page with something else.
So I was wondering if I could set the id="" attrib of the <p> to id="something" and then in my php code do something like this:
<?php
$something = "this will replace existing text in the something paragraph...";
?>
Can somebody please point me in the right direction? As the above did not work.
Thank you :)
UPDATE
I was able to get it working using the following sample:
Place this code above the <html> tag:
<?php
$existing = "default message here";
$something = "message displayed if form filled out.";
$ne = $_REQUEST["name"];
if ($ne == null) {
$output = $existing;
} else {
$output = $something;
}
?>
And place the following where ever your message is to be displayed:
<?php echo $output ?>
As far as I can get from your very fuzzy question, usually you don't need string manipulation if you have source data - you just substitute one data with another, this way:
<?php
$existing = "existing text";
$something = "this will replace existing text in the something paragraph...";
if (empty($_GET['button'])) {
$output = $existing;
} else {
$output = $something;
}
?>
<html>
<and stuff>
<p><?php echo $output ?></p>
</html>
but why not to ask a question bringing a real example of what you need? instead of foggy explanations in terms you aren't good with?
If you want to change the content of the paragraph without reloading the page you will need to use JavaScript. Give the paragraph an id.<p id='something'>Some text here</p> and then use innerHTML to replace it's contents. document.getElementById('something').innerHTML='Some new text'.
If you are reloading the page then you can use PHP. One way would be to put a marker in the HTML and then use str_replace() to insert the new text. eg <p><!-- marker --></p> in the HTML and $html_string = str_replace('<!-- marker -->', 'New Text', $html_string) assuming $html_string contains the HTML to output.
If you are looking for string manipulation and conversion you can simply use the str_replace function in php.
Please check this: str_replace()
If you're using a form (which I'm assuming you do) just check if the variable is set (check the $_POST array) and use a conditional statement. If the condition is false then display the default text, otherwise display something else.