473,326 Members | 2,337 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,326 software developers and data experts.

Assign Hyperlinks to the Search result

Hi,
Ive made a search page. It displays the name of the users which is the result of search. Now i want that if we click on the name it should open another page in which the profile of the user will be displayed. The code that i ve done till now, only works for the last user in the list of users displayed and it also doesnt opens in another window. I think the name of the users should be passed as an array to the account page where profile is displayed. But i was not able to do it. Plz help. Ive given the relevant code below plz let me know what is the problem.

search.php
Expand|Select|Wrap|Line Numbers
  1. if($resultnum>0) { // Echos out matches if anything was found
  2. while($info=mysql_fetch_array($data)){
  3. //Print it out to page 
  4. ?><a href="searchaccount.php">
  5. <?php
  6. $_SESSION['username'] = $info['UserName'];
  7. echo "".$info['UserName'] . " <BR><BR>" ?></a> 
  8. <?php
  9. }// end of while
  10. }//end of if
  11. else{
  12. echo "There are no results to be displayed for your search";
  13. }
  14.  
searchaccount.php
Expand|Select|Wrap|Line Numbers
  1. $uname = $_SESSION['username'];
  2. $result1= " SELECT UserName, EmailAddress, FullName FROM usermaster WHERE UserName= '$uname'";
  3. $data1 = mysql_query($result1) or die(mysql_error()); 
  4.  
Mar 13 '08 #1
8 1572
Markus
6,050 Expert 4TB
You should assign the username as a parameter to the url and loop through all user names.
[php]
$_select = "SELECT * FROM `tbl_name`";

while($_row = mysql_fetch_array($_select))
{
echo $_row['username'] . " <a href=\"profile.php?id=$_row['username']\">profile</a><br />";
}
[/php]
Hope this helps.
Mar 13 '08 #2
Thanks.
I tried uaing the above code but its giving error.

Expand|Select|Wrap|Line Numbers
  1. while($info=mysql_fetch_array($data)){
  2. //Print it out to page 
  3. echo "".$info['UserName'] ."<a href=\"searchaccount.php?id=$info['UserName']\">profile</a><br/>"; 
  4. }
  5.  
When i used this code it gave me the following error:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\xampp\htdocs\skill_search\search.php on line 181

Then i removed the inverted commas at the start of echo.
Expand|Select|Wrap|Line Numbers
  1. while($info=mysql_fetch_array($data)){
  2. //Print it out to page 
  3. echo $info['UserName'] ."<a href=\"searchaccount.php?id=$info['UserName']\">profile</a><br/>"; 
  4. }
  5.  
When i used this code it gave me the following error:
Parse error: syntax error, unexpected '.' in C:\xampp\htdocs\skill_search\search.php on line 181

Plz let me know how to fix this problem.
Mar 13 '08 #3
Markus
6,050 Expert 4TB
Try
Expand|Select|Wrap|Line Numbers
  1. while($info=mysql_fetch_array($data)){
  2. //Print it out to page 
  3. echo "$info['UserName'] <a href=\"searchaccount.php?id=$info['UserName']\">profile</a><br/>"; 
  4. }
  5.  
When you use an echo with double quotes, variables will be parsed inside it automatically.

i.e.
[php]
echo "this will echo a $_variable";
echo 'this wont echo a $_variable';
[/php]
Mar 13 '08 #4
I tried this now but its still giving me the error.
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\xampp\htdocs\skill_search\search.php on line 181

What could be the reason for this error.
Plz help
Mar 13 '08 #5
Markus
6,050 Expert 4TB
I tried this now but its still giving me the error.
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\xampp\htdocs\skill_search\search.php on line 181

What could be the reason for this error.
Plz help
what line is 181?

regards
Mar 13 '08 #6
what line is 181?

regards
Thanks the problem got solved. The curly braces were missing which was giving error.
Thanks a lot.

Expand|Select|Wrap|Line Numbers
  1. echo "{$info['UserName']} <a href=\"searchaccount.php?id={$info['UserName']}\">profile</a><br/>"; 
  2.  
Can you just let me know how to make each profile open up in a different browser.
Mar 13 '08 #7
Markus
6,050 Expert 4TB
Expand|Select|Wrap|Line Numbers
  1. echo "{$info['UserName']} <a href=\"searchaccount.php?id={$info['UserName']}\" target=\"_blank\">profile</a><br/>"; 
  2.  

Try that
Mar 13 '08 #8
Thanks. It worked out.
Thanks a lot.
Mar 14 '08 #9

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

Similar topics

3
by: scoop_77 | last post by:
I'm looking for some software that would allow me to point to a folder in Windows Explorer, and have it output an html file with hyperlinks to all of the files within that folder and all of the...
3
by: Aasp | last post by:
Hello! I'm a complete Javascript newbie and my question is surely very naive, but believe me, I've spent this whole day searching thru the net and didn't find any solution to my little problem....
1
by: John | last post by:
Hi all, My app contains a datagrid with hyperlinks inside and these hyperlinks all point back to the same page. The problem is that I have a 'search' user control and the viewstate changes once...
9
by: Viken Karaguesian | last post by:
Hello all, I'm making a calendar section in a website. Each month is its own page and navigated by Previous / Next links. I have it working now with standard hyperlinks, but I want to learn how...
1
by: Janna | last post by:
Hello tech savvy gurus! I hope someone can help me! THE PROBLEM: "Cannot open specified file" when I click on a hyperlink in an Access database when it is located on our server. THE...
22
by: RobClack | last post by:
I'm quite new to xml and xsl, so this could be quite simple. I have an xml file with some data in it and an xsl file to process it into a web page. What doesn't work is hyperlinks. I've read...
1
by: rcoco | last post by:
Hi all, I have this big problem with hyperlinks I would appriciate any help please. My web site has two datagrids on the same page. And one has a list of names of the users which are in form of...
2
by: mguy27 | last post by:
I am working with VBA in ExcelUltimately I am trying to take a huge amount of data (9500-10000 rows) and do a search for text including the words "Violated Door". I then want to take the rows (which...
92
by: Erwin Moller | last post by:
Hi group, I encoutered page validation error, but I don't know a way around. The page has the following doctype: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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...
1
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
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.