473,246 Members | 1,594 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,246 software developers and data experts.

Add link to search results (<a href="">)

250 100+
In my php page there is a search function and when user search it will display table containing search results. I want to add
Expand|Select|Wrap|Line Numbers
  1. <a href ..></a>
  2.  
. Because when user click one record I want to pass values to ajax page.
to those results. But my code is not working. Please help me.This is my code.
Expand|Select|Wrap|Line Numbers
  1. while($row = mysql_fetch_array($result))
  2.     {
  3.     echo "<a href='javascript:void(0);' onclick=\"LookupVehicle('$VehicleNo','$VehicleType','$VehicleMake','$Price'); return false;\">";
  4.         $array = array('VehicleNo','VehicleType','VehicleMake','Price');
  5.         foreach ($array as $v)
  6.         $$v = $row[$v];?>
  7.  
  8.           <tr>
  9. <?php
  10.  
  11.                 foreach ($array as $v)
  12.                 echo "<td height=20 cursor: pointer;'> &nbsp;".$$v."</td>";
  13.         ?>
  14.         </a>
  15.          </tr>
  16.  
  17.     <?php }
  18.  
Oct 8 '09 #1
1 4928
Atli
5,058 Expert 4TB
Hey.

Not feeling particularly articulate today, so I just commented your code :-]
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. while($row = mysql_fetch_array($result)) 
  3. {
  4.     // Isn't this supposed to be *after* you crate the variables you are echoing?
  5.     // And why is the ending </a> somewhere way inside the <tr> tag?
  6.     echo "<a href='javascript:void(0);' onclick=\"LookupVehicle('$VehicleNo','$VehicleType','$VehicleMake','$Price'); return false;\">";
  7.  
  8.     // Why bother with this? You can just as easilly use
  9.     // "$row['VehicleNo']" as "$VehicleNo"
  10.     $array = array('VehicleNo','VehicleType','VehicleMake','Price');
  11.     foreach ($array as $v){
  12.         $$v = $row[$v];
  13.     }
  14.     // P.S. Note the addition of the brackets to your foreach loop.
  15.     // Always use brackets. Leaving them out is just sloppy.
  16.  
  17.     // No poing exiting the <?php block just to output 4 letters.
  18.     // Echo was created for a reason ;-)
  19.     echo "<tr>";
  20.  
  21.     foreach ($array as $v) {
  22.         echo "<td height=20 cursor: pointer;'> &nbsp;".$$v."</td>";
  23.     }
  24.     // Again, note the added brackets to the loop.
  25.  
  26.     // 9 letters this time. Still not worth exiting the PHP block ;-)
  27.     // What's with the random </a> here? Shouldn't it be up there with the
  28.     // rest of the <a> tag?
  29.     // Unless you are trying to make the entire row a link, in which case
  30.     // you should use the <tr> onclick event, not enclose the <tr> in a <a> tag.
  31.     echo "</a></tr>";
  32. }
  33. ?>
Oct 8 '09 #2

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

Similar topics

3
by: Nel | last post by:
Hi all, I have been searching for some clues as to how to show a substring from a database search. $pagetitle = "Page Title"; $pagetext = "This is <b>a typical</b> string that would be...
2
by: CharitiesOnline | last post by:
Hello, I have set this script up to add paging to a search results page. Which on the first page works fine. I calculates how many pages there should be depending on the number of results returned...
5
by: George | last post by:
Hi, Anyone has the background for explaining? I have made a search on my name and I have got a link to another search engine. The link's title was the search phrase for the other search engine...
4
by: Dica | last post by:
i apologize for what is no doubt a very rudimentary question, but i'm still trying to wrap my brain around .net coding habits. in classic asp, if i wanted to show search results, i'd just post the...
1
by: sqlster | last post by:
I have a search page which renders results upon post back based on certain input criteria. Clicking on a link on a search result such as order number navigates to the order detail screen. What...
0
by: =?Utf-8?B?Qm9ubmll?= | last post by:
I have a basic ASP / Index Server search page. I have a web site contained in a subdirectory in the root of a main web site. What Iā€™m trying to do is force the search page in the subdirectory,...
4
by: bendlam | last post by:
I have a page that contains search criteria and when you click on the search button it causes a post back that populates a dataview on the same page. One of the gridview columns contains a link...
3
by: Bigalan | last post by:
Hello, i am relatively new to PHP and i am struggling with printing multiple search results on to different pages. The code below works ok but when you click on next page button, it brings up a blank...
5
by: moorcroft | last post by:
Hi I have developed an application that people can use to search for planning applications. The way it works is that once search criteria has been selected and submit is hit, the server will save...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.