473,396 Members | 1,915 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Using URL to highlight a table row

I have a table in a database and my question is how can I create it ... that when I type .../array.php?id=1 into the url, it will highlight that row. If I put id=2 in, then it will highlight row 2


Expand|Select|Wrap|Line Numbers
  1. <?php
  2. function connect(){
  3.   // Make a MySQL Connection
  4.   $link = mysqli_connect("localhost", "root", "", "school") or die(mysqli_error());
  5.   return $link;
  6. }
  7.  
  8. if ($_GET)
  9. {
  10.   if(isset($_GET["id"])) $id = $_GET["id"]; 
  11. }
  12.  
  13.  
  14. // select query 
  15. $query = "SELECT * FROM graden" ;
  16.  
  17. if (isset($id)) { $query.= " WHERE id = $id "; }
  18.  
  19. $result = mysqli_query(connect(),$query);   
  20.  
  21. // table making
  22. $table = "<table border='1'>";
  23. $table .= "<tr>
  24.              <th> ID </th>
  25.              <th>Graden Celcius</th> 
  26.              <th>Aanduiding</th>
  27.              <th>Image</th> 
  28.         </tr>";
  29.  
  30. // keeps getting the next row until there are no more to get
  31. while($row = mysqli_fetch_assoc( $result )) {
  32.     // Print out the contents of each row into a table
  33.     foreach ($row as $key => $value) {
  34.         if ($key == "Image") {
  35.             $table .="<td><img src='$value' /></td>"; 
  36.         } elseif ($key == "temp") {
  37.             $table .="<td><a href='array.php?id=$value'>$value</a></td>"; 
  38.         } else {
  39.             $table .="<td>$value</td>";         
  40.         }
  41.  
  42.     }
  43.     $table .= "</tr>";
  44. }
  45.  
  46. $table .="</table>";
  47.  
  48. echo $table;
  49. ?>
Jun 20 '13 #1
1 1701
Claus Mygind
571 512MB
First of all it looks like from your code you are only returning one record and not the entire content of the data base table, because of the "where" clause in your sql query

If that is the case why would you need to highlight it?

But if you were returning multiple records and want to hightlight only the requested line.
1) eliminate the where
2) make a test for the id when scrolling out the lines for the table you want to display.
Expand|Select|Wrap|Line Numbers
  1. if (id == paramId)
  2. {
  3.   <td style="background-color: blue;">
  4. }else{
  5.   <td>
  6. }
  7.  
Jun 20 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: J Krugman | last post by:
I have set up an HTML table with clickable cells (the cells contain only text). They work fine, but I would like to give the user some visual feedback to indicate that a cell has been clicked. ...
0
by: Jacob Pallapati | last post by:
Hi, I have a trigger in which I build a String from the contents of a table. In a stored procedure I would use a cursor which would look like: set str_to_build = ''; create c1 cursor for...
1
by: Mike | last post by:
In C, we can typedef pointer to functions, and therefore use function tables. But what's the advantage of using function table? Thanks, Mike
5
by: Przemek Wrzesinski | last post by:
Hi, I'm trying to add additional column using 'alter table' command via OleDB to Excel workbook (one sheet called queExportBOND): Dim strConn As String strConn =...
4
by: Michael R | last post by:
Hi. I'm currently dealing with the following: I need a drop box that will have in it a certain range of accending consuquential numbers for ex: 1, 2, 3, 4, 5, 6, 7. The min and the max number...
1
by: PurpleWitch | last post by:
Hi there I'm using an Access 2000 DB on Office 2000. The following Pivot Table worked fine 2 days ago, but no I'm getting the "Invalid Procedure Call or Argument" error when using Pivot Table...
0
by: saroravi | last post by:
How can we write a cobol program without using session table. how Front end (PB) retrieve the data
2
by: cj | last post by:
We have a legacy accounting system (not developed in house) here that happens to be written in Visual FoxPro. One of the tables has an index that is actually a coded function COMPANY1 ...
0
debasisdas
by: debasisdas | last post by:
This thread contains some useful tips for using External tables. USING EXTERNAL TABLE ======================= 1.THE TABLE POINTS TO EXTERNAL FILE. IF DATA IS ALTERED IN THE EXTERNAL FILE,DATA...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
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...
0
agi2029
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.