how to display results from database in same page in html - php

I am currently new to php.I am trying to display results from a database to the same html page.However am not using a form for searching,the search is universal.How can i display the results in same page?
For example heres a part of my html page
<body>
<div class="div1>
button to display results
</div>
<div class="div2">
</div>
and in my php everything is working fine.However i want when a user clicks the "button to display results" link,the results from the database should be displayed in div2.Help will be highly appreciated.

Try this: it will cause the page to refresh passing 1 to the query string to indicate whether to display or not
<div class="div1>
button to display results
</div>
<div class="div2">
<?php
$display = $_GET['display'];
if($display)
{
//do some dispaly here
}
?>
</div>

Related

Load php query in div onclick

I'm loading photos from database with mysql query. For default it load data from database with pagination.
<div class="col-md-10 bg col-md-push-2 ">
<div class="align_center gallery">
<?php
include "anj.php";
$sql = 'SELECT * FROM new_photos ;
/* function anjaan content code for loading photos .*/
anjaan($sql);
}
?>
</div>
<div class=" align_center ">
<div class=" col-md-12 pagination gallery">
<?php
echo $paginationctrl;
?>
</div>
</div>
Now I want when user click a button data should change with this
<?php
include "anj.php";
$sql = 'SELECT * FROM new_photos WHERE weight BETWEEN 10 AND 15';
anjaan($sql);
?>
Php is just server side, so i think u only will have two options.
1 - On click reload de page and send a post or get params to the application usign form and then load the page with the new query.
2 - If u want to do not reload te page, will be better to send an Ajax request to server side with JavaScript and then bring and replace the old content for the new one.

Getting rows from db and adding reserved- tag

what would be the right way to mark item as reserved? my current way works but i doubt it's "right" way to do it.
i've a simple query to get rows from database and then outputting them inside html tags. Here is example of my php variables:
$name = $row['name'];
$price = $row['price'];
$reserved = $row['reserved'];
and html example:
<div class="container">
<div class="item">
<div class="name">
$name
</div>
<div class="price">
$price
</div>
<div class="reserved">
$reserved
</div>
</div>
</div>
if a item is reserved, then i just add text to reserved- field in database.
I hide all "reserved" divs in css. Then i'm using jquery to loop through all "reserved" items. I check if that div has text, if it has, then i show it and after that i clear it.
$(".reserved").each(function(index) {
if($(this).is(":empty")) {
$(this).hide();
}
$(this).empty();
});
After that all items which had text in "reserved" field in database will have different layout. As they're supposed to have. It works but i don't think this is the right way.. can someone lead me to the right way? any help would be appreciated.

Mustache Page Break

I want building a form like that:
<div> test </div>
// show me all categories from table
<div class="section">
{{#categories}}
{{{.}}}
{{/categories}}
</div>
// show me all books from table>
<div class="section">
{{#books}}
{{{.}}}
{{/books}}
</div>
Each books or categories has div tag.
i want that each tag start on new page.
Can you tell me how can i insert new page in mustache.
Best Regards,
I found something:
From html is posible, something like <p style="page-break-after:always;"></p>.
After this line, new page is made.

mPDF - Content from specific div that is visible + add a save button

So I'm trying to set mPDF on my site, but the thing is, on the page that I want to create pdfs on, I get all of the content inside divs based on the posts count. So it looks something like this:
<div id="all-posts">
<div id="some-post">
content
</div>
<div id="some-other-post">
content
</div>
<div id="post-with-long-title">
content
</div>
</div>
And then I have a select, with options values which are equal to the div IDs inside all-posts. And when you pick an option from the select, that div is showed. Now what I need to do is show a Save PDF button, and when that is clicked, get the content from the div that is currently showing (based on whats selected in select tag) and save the .pdf. Is something like this even possible?
Update:
<?php include("mpdf/mpdf.php");
$mpdf=new mPDF();
ob_start(); ?>
<div id="all-posts">
<div id="some-post">
content
</div>
<div id="some-other-post">
content
</div>
<div id="post-with-long-title">
content
</div>
</div>
// Now collect the output buffer into a variable
<?php $html = ob_get_contents();
ob_end_clean();
$mpdf->WriteHTML($html);
$mpdf->Output();
exit; ?>

Is it possible to show the database values in jquery thickbox

In hiddenModalContent div is it possible to display the database value as once thickbox is opening it just showing nothing
<?php
foreach($this->list_details as $key=>$details)
{?>
<div class="sc_content_subheading"><? echo $this->escape($details['list_name'])?></div>
<div id="hiddenModalContent" style="display:none;">
<span class="content_subheading">List name </span><? echo $details['list_name'];?><br/>
</div>
<?php }?>
It seems all you are only outputting the list name. What else in the array would you like to show?

Categories