How to put results of multiple querys properly in one table - html-table

<center><h2>Kaarten overzicht</h2></center>
<table border="1" id="table">
<tr>
<th>Patiente Naam</th>
<th>Arts</th>
<th>Huisarts</th>
<th>Diagnose</th>
</tr>
<!--- Alle informatie van patiente in een table zetten. --->
<cfloop query="VARIABLES.overzicht">
<cfoutput>
<tr>
<td>#Voornaam# #Achternaam#</td>
</cfoutput>
</cfloop>
<cfloop query="VARIABLES.overzichtArtsen">
<cfoutput>
<td>#Voornaam# #Achternaam#</td>
</cfoutput>
</cfloop>
<cfloop query="VARIABLES.overzichtHuisartsen">
<cfoutput>
<td>#Voornaam# #Achternaam#</td>
</cfoutput>
</cfloop>
<cfloop query="VARIABLES.overzichtDiagnose">
<cfoutput>
<td>#Type#</td>
</tr>
</cfoutput>
</cfloop>
</table>
It doesn't come out the way I wanted the results are on wrong places..
I use ColdFusion with the framework Fusebox. And the queries are SELECT * FROM [table_name];.
Please help..

#Duncan is correct about joining tables being the likely best solution, but here's an answer to your question on how to reference multiple queries in one loop.
This assumes that your queries all returned the same number of records.
<center><h2>Kaarten overzicht</h2></center>
<table border="1" id="table">
<tr>
<th>Patiente Naam</th>
<th>Arts</th>
<th>Huisarts</th>
<th>Diagnose</th>
</tr>
<!--- Alle informatie van patiente in een table zetten. --->
<cfoutput>
<cfloop query="VARIABLES.overzicht">
<tr>
<td>#Voornaam# #Achternaam#</td>
<td>
#VARIABLES.overzichtArtsen.Voornaam[CurrentRow]#
#VARIABLES.overzichtArtsen.Achternaam[CurrentRow]#
</td>
<td>
#VARIABLES.overzichtHuisartsen.Voornaam[CurrentRow]#
#VARIABLES.overzichtHuisartsen.Achternaam[CurrentRow]#
</td>
<td>
#VARIABLES.overzichtDiagnose.Type[CurrentRow]#
</td>
</tr>
</cfloop>
</cfoutput>
</table>
Queries are accessible as a struct with keys for each column, and each column is an array of values. CurrentRow is the index of the row you are currently looping over in the cfloop.

Duncan's comment about joining tables is valid, but even if you followed it, you might still have a problem because you have opening and closing tags inside different loops.
Your code start by creating a single table row with 4 cells. Then you have an opening tag inside a loop, but no closing tag. You now have malformed html which is why your display is not what you had hoped for.
It's hard to suggest alternative code because it it not entirely clear what your final output is supposed to look like.

Related

PHPUnit, Selenium - Click on link in row based on the value of another column in the same row

I think it's a stupid question, but I cant find an answer. I have table with many columns (name, date, link, etc.). I want to click on link based on the "name" value.
Here is short example:
<tr>
<td>
name value
</td>
<td>
date
</td>
<td>
<a href="">
link
</a>
</td>
</tr>
<tr>
the same format with different values
</tr>
Thanks for answers
This xpath will work for you, I think:
//td[contains(text(), 'name value')]/../td/a
It will find the <td> that contains 'name value', go back up to the containing <tr>, then back down to the <td> that has a<a> as a child in the same <tr>.
If I understand phpunit correctly, the command will look something like this:
$this->click("xpath=//td[contains(text(), 'name value')]/../td/a");

How to add cells in a column in html

is there a way to add cells in a row column in html table without adding another table inside the row column
I have attached the image. and here is my code
<tr>
<tbody>
<td>Name</td>
<td><div id="span1">Units</div>
<div id="span2" class="side-border">price</div>
<div id="span2" class="r">value</div>
</td>
</tbody>
</tr>
If you want to have some different structure of your rows, you should check colspan and rowspan. The numbers should add up.
Example
<table border="1px">
<tr>
<td colspan="5">Hello</td>
<td>World</td>
</tr>
<tr>
<td rowspan="2">col 1</td>
<td colspan="4">CENTER</td>
<td>right</td>
</tr>
<tr>
<td colspan="3">Text</td>
<td colspan="3">bottom right</td>
</tr>
</table>
If you were to add the numbers from colspan they add to 6 and rowspan goes to 3. There are some things you have to take care of though. It's a little hard for me to explain now what those are, just try to visualise how you want your table to look, and then follow this:
The table should have the max number of rows
The table should have the max number of columns
rowspan used across table has to add up (more or less)
colspan used across table has to add up (more or less).
Follow that, and after writing the HTML for a few "complex" tables, you'll get the gist of it.

Excess Characters Being Generated by ColdFusion Query/output

I've got a strange issue with some Coldfusion/SQL Query output. The actual data is generating properly, but at the bottom of the page it's outputting "Library/Library/Library/Library/Library/Library/Library/Library" for no reason I can discern.
It always outputs it in exactly that format, always 8 times, no matter how many terms I'm searching for, how many records are returned, or how much text is generated after grouping.
It doesn't happen on all pages, but it does seem to happen on every page on the site that pulls a query from this database...
I'm lost. Code below, live page is here: http://www.audiogo-library.com/client/client_pages/hachettepage.cfm
<cfsetting enablecfoutputonly="yes" showdebugoutput="no">
<!--- Custom Hachette page --->
<cfset todayDate = Now()>
<!--- Link to Style Sheets --->
<img style="margin:auto" src="http://www.audiogo-library.com/Library/client/client_images/hachettelogo.gif"></br>
<cfoutput> #MonthAsString(Month(Now()))# </cfoutput> Releases</br></br>
<cfquery name="GetProductBasicInfo" datasource="#Request.Application.PowerWeb.datasource#" dbtype="odbc">
SELECT product.ProductID, productmarket.imprint, product.IsbnUpc, product.Title, product.FullTitle, product.SubTitle, product.PubDate, product.SKU, productmarket.descriptionshort, productmarket.productform, productmarket.NoOfPieces, productmarket.productmarketid
FROM Product, ProductMarket
WHERE product.productid = productmarket.productid AND product.IsbnUpc LIKE '%61113%' AND product.PubDate BETWEEN '<cfoutput>#DatePart("m", todayDate)#</cfoutput>/01/<cfoutput>#DatePart("yyyy", todayDate)#</cfoutput>' AND '<cfoutput>#DatePart("m", todayDate)#</cfoutput>/31/<cfoutput>#DatePart("yyyy", todayDate)#</cfoutput>'
ORDER BY product.FullTitle ASC
</cfquery>
<cfoutput query="GetProductBasicInfo" Group="FullTitle">
<table width="90%" border="0" style="margin-top:15px;">
<tr>
<td><p><a href="http://www.audiogo-library.com/library/productdetails.cfm?sku=#SKU#">
<cfif #FullTitle# eq ''> <div class="title"> #Title# </div>
<cfelse> <div class="title">#FullTitle# </div> </a>
</cfif></p>
<p>
<cfif #descriptionshort# neq ''> #descriptionshort# </cfif>
</p>
</td>
<td width="30%"> <img src="http://www.audiogo-library.com/library/client/Products/ProdimageLg/#SKU#.jpg"></td>
</tr>
</table>
</cfoutput>
TestText
I actually solved it by accident while trying to push the "/Library"s down the page. It turns out the cfsettings tag built into the query/output was disabling non cfoutput content. THe guy who built the footer was relying on inheriting "enablecfoutputonly='false'", and this code changed that. Everything from the site's footer was being hidden except for the section of each address that was generated by cfoutput. SO yeah, if anyone else has this or a similar problem, check your cfsettings tag, and ensure you DISABLE
Go to cfadmin and disable query caching. Restart the CF service. Voila!...no more extra data.

How do I grab the variable NAME and not the VALUE of the variable in ColdFusion?

The basic idea is this: I have a form that generates form fields dynamically so let's say there are 5 evens people can sign up for (they all cost $10) then those 5 evens will be displayed. Like this:
<tr>
<th><label>#SeminarWisTitle#</label></th>
<td>
<label><input type="checkbox" name="#SeminarWisID#" value="10.00" onclick="CheckChoice(this);" onfocus="startCalc();" onblur="stopCalc();" class="checkbox" /> Individual Webinar ($119)</label>
</tr>
</cfoutput>
Now because of the Javascript the value on all these events will be 10.00 but the NAME of the form field will be unique, and that is what I actaully want to store in the database.
This is the code I've written:
<cfparam name="seminarBulkSignUp_List" default="">
<cfoutput query="qSeminarWisTwo">
<cfparam name="FORM.#SeminarWisID#" default="">
<cfif #FORM[#SeminarWisID#]# neq "">
<cfset seminarBulkSignUp_List = ListAppend(seminarBulkSignUp_List, #FORM[#SeminarWisID#]#)>
</cfif>
</cfoutput>
<cfset FORM.SeminarWisTitle = #seminarBulkSignUp_List#>
So with this code, I run a query for ALL the possible events, and then just check against the form that has been submitted to see which ones are "blank" as in not selected, and the ones that are selected i want to add to a list to store in the database.
Now this works as far as letting me know which events were selected and which not, but i want the list to compile the actual FORM FIELD names not the value they have. How would I do that?
<cfoutput>
<cfloop list="#StructKeyList(FORM)#" index="thisField">
My field name: #thisField#<br/>
My field value: #FORM[thisField]#<br/>
</cfloop>
</cfoutput>
Apply as necessary.

Double evaluation - How do I access my query column based on a variable that holds the column name?

I have a query and a list of field/column names. I want to do a sort of double loop - loop through each record in the query, and then loop through the list of field/column names and output each corresponding field. The loops should be something like this:
<table>
<cfoutput query="myQuery">
<tr>
<cfloop list="#cols#" index="col">
<td>?</td>
</cfloop>
</tr>
</cfoutput>
</table>
The problem is what to put where the question mark is... I've tried #myquery[col]#, but this didn't work. I need to get the variable indicated by the string name in the variable col... And obviously, #col# will just return the column name. I need to figure out some way to double-evaluate the string... something like ##col##, which of course won't work either. How can I accomplish this?
When referencing column names as a structure, you need to also tell the query which row you want to get. You should also make sure that you check that the column name exists if you didn't get the cols variable via myQuery.ColumnList.
Use the following code to dynamically reference each column in your loop:
<table>
<cfoutput query="myQuery">
<tr>
<cfloop list="#cols#" index="col">
<td>#myQuery[col][CurrentRow]#</td>
</cfloop>
</tr>
</cfoutput>
</table>
You can still use Sergii's approach with your own columnlist:
<cfloop list="#cols#" index="col">
<cfif StructKeyExists(myQuery, col)>
<td>#col# = #myQuery[col][myQuery.CurrentRow]#</td>
</cfif>
</cfloop>
Got it!! :)
#evaluate(evaluate("col"))#