I have a problem regarding setting limit for specific page. For example i have 8 data. In page 1, only 5 data are allowed to display. the remaining data will display at the next page. How to make this possible to if the total data i get is from database. How to make this condition in sql??
Is not clear what you are asking
but you can limite the row showd in gridView with $dataProvider->pagination->pageSize
eg:
$dataProvider->pagination->pageSize=5;
thank you for the response. i already found an answer..:)
//$i refer to total of page.
$start_from = ($i-1)*5;
$RsPermitSkvLim = RsPermitSkv::model()->findAllBySql("SELECT * FROM rs_permit_skv WHERE id_permit_info = $id_permit_info ORDER BY id ASC LIMIT $start_from,5");
foreach($RsPermitSkvLim as $rsskvinfo) {
//coding here.
}
Related
I am doing Microsoft Dynmics D365 report layout. I have a table in my report that need to show the lines from the table in MS Dynamic D365. Which have only 2 lines.
D365 frontend system:
In the report layout, it is only showing the first line and the second line is not showing.
Report layout first line only showing:
I want the 2 lines to be showed in the report. I am not sure if my coding is not right or the row group that I am grouping in the report design. Please help me please. Apperciated.
here is my code in the dp class to get the table lines:
PurchPurchaseOrderTmp.MGAItemLabelName = PurchExtendedMaster.ExtName;
PurchPurchaseOrderTmp.MGAColValue1 = PurchExtended.ColValue1;
PurchPurchaseOrderTmp.MGAColValue2 = PurchExtended.ColValue2;
PurchPurchaseOrderTmp.MGAColValue3 = PurchExtended.ColValue3;
PurchPurchaseOrderTmp.MGAColValue4 = PurchExtended.ColValue4;
PurchPurchaseOrderTmp.MGALabelId = PurchExtended.LabelId;
//PurchPurchaseOrderTmp.MGALabelIdString += int2Str(PurchExtended.LabelVersion);
if (PurchPurchaseOrderTmp.MGAItemLabelName != "") {
PurchPurchaseOrderTmp.MGALabelIdString = strFmt("%1-%2",
PurchExtended.LabelId, int2Str(PurchExtended.LabelVersion));
}
else {
PurchPurchaseOrderTmp.MGALabelIdString = "";
}
Here is my report design row grouping:
Thanks
This is not really an answer at the moment as I can't see enough to be certain but...
Looking at the report design, it 'appears' that you don't have anything in the details row(s). The details group rows have been reduced in height so I'm guessing there is nothing in there.
That means that the text boxes below this must be in a group header or footer which is why they will only appear once.
The best way to get your head round this is to dump all the data from your dataset into a simple flat table, then see what you want repeating.
For exmaple, it looks like Label ID (MGAItemLabelName ?) should only be shown once, so there needs to be a group for that - which it looks like you have.
Then within that label name group, you have two rows of data that you want to show, so these must be at a lower level than their parent group. That might be the details row group, or another row group between the header and details depending on your needs.
The details row group typically contains fields that you want to show every instance of and that does not have any subordinate/child data.
There was a requirement, to have data horizontally expanded in the Rows. So I have created Child Row group in Column group of Matrix as shown in this link.
Reference Link
It is working fine. And it displays result as below.
Requirement was : Show Thumbnails of images uploaded for a building as above.
But now the problem is, when there will be number of images, this is going to be expanded horizontally.
I want to repeat this Row after 8 or 10 images.
Any Idea how can I achieve this in SSRS ?
Thank you,
Mittal.
Not quite sure about your requirement, do you want those images wrap in your report, each row has maximum 8 images? If so, we need to make each 8 images into one group. In this scenario, we can create a list. If you have a index field (like a specific id for each image) in your dataset, we can put in the group expression with this:
=ceiling(Fields!Index.Value/8)
If you don't have this kind of index column, we can make it manually. Embed the custom code below:
Dim CountNumber As Integer = 0
Public Shared Previous as Object
Public Function GroupNumber(ByVal category As Object) As Integer
If Category <> Previous then
CountNumber = CountNumber + 1
Return CountNumber
Else
Return CountNumber
End If
End Function
Then replace the group expression with this:
=ceiling(Code.GroupNumber(Fields!Image.Value)/8)
I have tested in my local environment and it works. But I can't share the screenshot due to low reputation.
I am trying to allow only certain data to be inserted into an html form field...
i currently have
pattern="[A-za-z]{2}[0-9]{6}"
which works great for a reference number starting with RQ and then 6 numbers.
how can i add another pattern to allow 3 letters with 8 numbers after that?
for example INM12345678
so that users can only use RQ123456 or INM12345678
try this:
/(RQ\d{6}|INM\d{8})/
here is the demo see here
If you want to limit valid data as said in comment:
^RQ[0-9]{6}|INM[0-9]{8}$
I have 3 thumbnails which i want to rotate each time a user refresh the page. Therefore want to show different thumbnail each time. I have image name stored in the database. I am using this SQL query to fetch "select thumbnail from tablename order by rand() limit 1". It is fetching one thumbnail perfectly.
The problem is that sometime same images comes up. For example first time i refresh the page thumbnail 1.jpg shows but second time again 1.jpg comes up.
So what i am looking for is to have different thumbnail each time i refresh the page.
Can anyone provide me some suggestions to achieve this ?
this is not possible with random selection, as the same image can come again.
For the effect you want you need to use a cookie to store the last displayed image name and NOT display that image for the next request.
As you have confirmed in your comment you do not want to display the last displayed thumbnail. IN that case you can do this like this using sessions:
// get last shown from session if any
$last_shown = '';
if(isset($_SESSION['last_shown_thumb']))
$last_shown = $_SESSION['last_shown_thumb'];
// select a thumbnail randomly which is not the one last shown
$query = "SELECT thumbnail FROM tablename WHERE thumbnail <> '" . $last_shown . "' order by rand() limit 1";
$res = mysql_query($query);
$row = mysql_fetch_row($res);
$curr_thumb = $row[0];
// set the current to last shown in session
$_SESSION['last_shown_thumb'] = $curr_thumb;
Assuming you are using PHP, you store the previous thumbnail in $current_thumbnail.
Then, you can do it like this
SELECT thumbnail FROM tablename WHERE thumbnail <> '$current_thumbnail' ORDER BY rand() LIMIT 1
Your query just needs to know what thumbnail you are currently displaying so you can filter it out.
Using php and mysql 5.x. I currently load a banner image in a certain section of my site like so:
SELECT * FROM banners WHERE section = 1 AND pageid = 2
But if no results found I run a second query:
SELECT * FROM banners WHERE section = 1 AND pageid = 0
Basically what Im doing is trying to find banner images assigned to that section for that page. If no results found then I look for any default banner images in the second query. Is there a better way where I can do this in one query?
EDIT
To clarify a little bit more. I want to check if there is any banners assigned to the page, if not then see if there is any banners assigned to 0 (Default). I dont want a mix of both either it shows all banners assigned to that page or show all banners assigned to pageid 0 and there could be a possibility of multiple rows returned not just one.
ADDITIONAL EDIT
To better explain what this is for. In an admin tool I allow someone to assign a banner image to section on the website. In the admin tool they can select the section and the page they want the banner image to show. They can also set the default banner image(s) for that section. So if there were no banner images assigned to a section by default it will load the banner image(s) assigned to 0 for that section throughout the website. So instead of assigning a default banner image to 50 different pages they can just do it one time and it will load the default banner image or images for that section. Just trying to find a way to do this in a more optimal way, instead of 2 queries could it be done in one?
The OR operator will make the conditional (pageid = 2 OR pageid = 0) return true immediately if just the first value is true and since there is a LIMIT 1 I think it should always fetch one with pageid = 2 first since the order of pageid is DESC and 2 is bigger than 0.
SELECT * FROM banners WHERE section = 1 AND (pageid = 2 OR pageid = 0) ORDER BY pageid DESC LIMIT 1
EDIT: I'm not positive if the ORDER BY is necessary, I'd love to see some comments on that
Maybe it's not the most elegant way, but you can try this:
SELECT *
FROM banners
WHERE section = 1
AND pageid = IF(
(select count(*) from banners where section = 1 and pageid = 2) = 0,
0, 2
);