If I use this code to get records from mysql - <ul>
-
<?php
-
$cquery = mysql_query ("Select * From product Where category_id=$category_id");
-
while ( $cr = mysql_fetch_array ($cquery)) {
-
while ( $pr = mysql_fetch_array ($cquery) ) {
-
?>
-
<li>
-
-
<a href="index.php?product=<?php echo $category_id; ?>&product_id=<?php echo $pr['product_id']; ?>"><?php echo $pr['name']; ?></a>
-
-
-
</li>
-
<?php } } ?>
-
</ul>
Then how can I apply different style to the clicked product, like if below code results:
product 1
product 2
product 3
And then if some one click on product 1, it should be like this: product 1
product 2
product 3
I have tried with several things but have not succeeded yet. What is the best way to do this?
Thanks.
7 1805 Rabbit 12,516
Recognized Expert Moderator MVP
I would put each product in it's own container, probably a div, and use the on click event to run a javascript function that changes the class. Don't forget to change the class of the previously selected item back.
Thanks, but isn't there a way for it be done with if comparison,
like if (selected) then <a class="active"> ???
Rabbit 12,516
Recognized Expert Moderator MVP
It sounds like you're trying to do it using only PHP but that's impossible because the PHP engine has no idea what elements the user clicks on. That has to be handled on the client side using javascript.
great, and can I have such example with JS?
Rabbit 12,516
Recognized Expert Moderator MVP
Give it a shot and then post what you have. We can work through the errors you run into.
Thanks but can you provide me some link where such usage of JS is described because I am a beginner to PHP. :(
Rabbit 12,516
Recognized Expert Moderator MVP
Javascript is unrelated to PHP. You'll want to start out with a tutorial on Javascript. You can try the one on the w3schools website.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: ChrisR |
last post by:
Hi guys
My app is a simple Main form with a few Subforms that are not linked,
and a few pop forms.
Problem is:
I have a pop form with a Listbox with a list of records related to the
subform in the Main form. I'd like to double click on the selected
file in the listbox and load that record into the the Subform, easy
|
by: dbuchanan |
last post by:
Hello,
I want to open a child form based on the record selected in a
dataGridView of the parent form.
I want the child form to open with a populated child table based on the
selected parent record.
How do I get the ID of the selected record in the parent form's
dataGridView so I can use it in filling the child form's dataGridView?
|
by: mci |
last post by:
Hi!
How can I print the selected record? I'm using visual basic 6. After I search the record, it display in the form but when I click the print button all the records will print. What I want is to print the selected record only.
Thanks!
|
by: KiwiGenie |
last post by:
I have a form which lists selected records, there could be anything from 1 record to all records selected. I want to output a report for each record as HTML. I want each file to take its name from a certain field (RecipeName), so can't simply put a page break in the report.
Would it be possible to create a loop which opens the report hidden, then exports it to HTML, then closes the report, and does this for each selected record? Or would all...
|
by: ndeeley |
last post by:
Hello,
I've not had a lot of luck getting this to work, despite looking around lots of websites, so here goes...
I have a main form frmProjectScheduler. It's a tabbed form and the front page is a switchboard.
The front page shows a chart of uncompleted jobs, generated from a query qryUncompletedJobs. When a button next to this chart is clicked, a new form frmListUncompleted appears, showing the results of this query in a listbox,...
| |
by: Bob |
last post by:
Hello,
Using VB 2005.net.
I have a bound datagridview and a delete button control (or when the user pressed the 'Delete' key) I can successfully delete the selected record from
the table and it is removed from the dgv. But then I want to select the previous row in the dgv and select it so on 'Select Index Changed' event I
can populate text boxes referring to the selected row. The user may have selected the 5th row in the dgv then...
|
by: Dave |
last post by:
Access 2003
I have an unbound search form, which shows filtered search records in
it’s sub-form.
On the unbound search form I wish to place a button, which will close
off the search form, and take me to my main document form, showing the
selected record indicated in the initial search forms, sub-form.
Using option one below, placed on any-one of the search forms, sub-
|
by: =?Utf-8?B?SnVsaWEgQg==?= |
last post by:
Hi all, this is a second post, so apologies, but I never had an answer to my
first post (several weeks ago) and I really need some help.
I'm using a .Net 2.0 Gridview which is populated using an ObjectDataSource
which calls on a method in a class. This all works fine.
The Gridview has a select button automatically generated. When the user
presses this I want to be able to take the data from the selected record and
use it. However...
|
by: eneyardi |
last post by:
How to filter selected record in a report?
i have a form name Data Tracking Details where i can view my records one by one using record selector. Now, i want my current record in a form to be filtered in a report. i want to do this in a command button, when i press it, i can print the filtered record.
|
by: David Patz |
last post by:
Is it possible for a user to select a record from a datasheet in a subform, double click it, and write that specific record to another table? I have attempted to perform this task using DoCmd.DoMenuItem commands and RunCommand acCmds but with no luck? Im currently building this system in VBA with MS Access 2003. Thus far I have only been able to copy the selected record to a the windows clipboard to be used in other text-based platforms, but I...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |