close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

simple php related

Thread began 9/14/2015 11:37 am by Kumel | Last modified 9/14/2015 4:15 pm by Ray Borduin | 1798 views | 8 replies |

Kumel

simple php related

i wanna know how can we display right content on one of the results page.

I will explain the background 1st so that you dont get confused :)

Well i m maintaining a database & has structure just like how you guys structure for e-commerce.

At insert page, when adding product there is an option to chose category. here choosing multiple cat option in given.
Now data store as multiple like this: 1,2,3,4.........

Now on results page i know how to display value of 1 category name thru something like this:

<?php $_GET['ID'] = $row_Products[‘CategoryID’]?>

<?php
$colname_CategoryName = "-1";
if (isset($_GET['ID'])) {
$colname_CategoryName = $_GET['ID'];
}
mysql_select_db($database_con1, $con1);
$query_CategoryName = sprintf("SELECT * FROM LockoutPoints WHERE ID = %s", GetSQLValueString($colname_CategoryName, "int"));
$CategoryName = mysql_query($query_CategoryName, $con1) or die(mysql_error());
$row_CategoryName = mysql_fetch_assoc($ProductCatName);
$totalRows_CategoryName = mysql_num_rows($ProductCatName);
?>



then to show category name i insert php as this:

<?php echo $row_CategoryName['Name'];?>




So lets say i had choosen multiple categories for a product. This display just the first value present in category. ie 1's (category name) ex: 1,2,3,4
I wanna display all category names from 1,2,3,4 values. (category names)


How can this be done?
Anyone?

Sign in to reply to this post

Ray BorduinWebAssist

You can try:

php:
mysql_select_db($database_con1, $con1);

$query_CategoryName = "SELECT * FROM LockoutPoints WHERE ID IN (".$row_Products[‘CategoryID’].")";
$CategoryName = mysql_query($query_CategoryName, $con1) or die(mysql_error());
$row_CategoryName = mysql_fetch_assoc($ProductCatName);
$totalRows_CategoryName = mysql_num_rows($ProductCatName);
?>



Then you can use a repeat region to show all of the category names from the returned recordset.

Sign in to reply to this post
Did this help? Tips are appreciated...

Kumel

You made it look easy :) but how can comma (,) be added after each?

Sign in to reply to this post

Kumel

Originally Said By: Ray Borduin
  You can try:
php:
mysql_select_db($database_con1, $con1);

$query_CategoryName = "SELECT * FROM LockoutPoints WHERE ID IN (".$row_Products[‘CategoryID’].")";
$CategoryName = mysql_query($query_CategoryName, $con1) or die(mysql_error());
$row_CategoryName = mysql_fetch_assoc($ProductCatName);
$totalRows_CategoryName = mysql_num_rows($ProductCatName);
?>


Then you can use a repeat region to show all of the category names from the returned recordset.  



This is good.

Can be used for all in similar way?

$query_CategoryName = "SELECT * FROM LockoutPoints WHERE ID IN (".$row_Products[‘CategoryID’].")";
Sign in to reply to this post

Ray BorduinWebAssist

I'm not sure I understand the question. I think that the CategoryID column already has a comma separated list of IDs, that is what I got from your post.

If you want to just show the category names comma separated you can use:
$query_CategoryName = "SELECT GROUP_CONCAT(Name) AS AllCats FROM LockoutPoints WHERE ID IN (".$row_Products[‘CategoryID’].")";

And then you can just show the column AllCats and don't need a repeat region.

Sign in to reply to this post
Did this help? Tips are appreciated...

Kumel

what is GROUP_CONAT? and AllCats
i got this error : FUNCTION lotomanager.GROUP_CONAT does not exist

Sign in to reply to this post

Ray BorduinWebAssist

Sorry typo... should have been GROUP_CONCAT

That SQL function will take multiple rows in a recordset and combine them comma separated into a single value.

Sign in to reply to this post
Did this help? Tips are appreciated...

Kumel

error:
Unknown column 'Name' in 'field list'

What is Name referring to? i m confused a little from this code:

$query_CategoryName = "SELECT GROUP_CONCAT(Name) AS AllCats FROM LockoutPoints WHERE ID IN (".$row_Products[‘CategoryID’].")";
Sign in to reply to this post

Ray BorduinWebAssist

The category name field in the AllCats table that you want comma separated to display on the page.

Sign in to reply to this post
Did this help? Tips are appreciated...

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...