I have prob with my code its working fine bur, i want to add url to Row Name, When i add them it show error.

Exapmle and code:

<strong><font size="3">
<?php
    mysql_connect("localhost", "rooot", "123") or die("Error connecting to database: ".mysql_error());
    mysql_select_db("Search") or die(mysql_error());
    $query = $_GET['query']; 
    $min_length = 3;
    $max_length = 15;
  if(strlen($query) >= $min_length)
  { 
        $query = htmlspecialchars($query); 
        $query = mysql_real_escape_string($query);  
  echo "<table border='0' width='' align='left' cellpadding='1' cellspacing='1'>";
  echo "<tr><h3>You have searched for $query... Please find the details of $query...</h3></tr>";
  echo "<tr align='center' bgcolor='#03acfa' > <td height='35px' width='125px'><b>Name</b></td> <td><b>Type</b></td> <td><b>Address</b></td></tr>";     
        $result = mysql_query("SELECT * FROM company WHERE (`Name` LIKE '%".$query."%') OR (`Type` LIKE '%".$query."%')") or die(mysql_error()); 
        if(mysql_num_rows($result) > 0)
  {
            while($results = mysql_fetch_array($result))
   { 
                echo "<tr align='center' bgcolor='#93dafb'><td height='25px'>".$results['Name']."</td> <td>".$results['Type']."</td> <td>".$results['Address']."</td></tr>";
            }

        }
        else{ 
            echo "<tr align='center' bgcolor='#fdee03'><td colspan='2' height='25px'>Sorry..No data found for $query if you are owner for Business company / Organization you can add your content for submiting your content click here</td><tr>"; 
   echo "</table>";  
        }   
    }
    else{ 
        echo "<tr align='center' bgcolor='#fdee03' font size='10'><td colspan='2' height='25px'>Your search keyword contains letters only ".$min_length;
    }

?>

This is the URL:

<?
    <td align="center"><a href="Get-Details.php?id=<? echo $rows['id']; ?>">View Details</a></td>
    ?>

Recommended Answers

All 15 Replies

I want to add this URL

    <td align="center"><a href="Get-Details.php?id=<? echo $rows['id']; ?>">View Details</a></td>
    ?> 

to:

    .$results['Name'].

any sugession ?

Can you not just add the link to your output, I see no need to add it to your variable. Try this:

while($results = mysql_fetch_array($result))
{

  ?>

    <tr align='center' bgcolor='#93dafb'>
      <td height='25px'>
        <?= $results['Name']; ?> <a href="Get-Details.php?id=<?= $results['id']; ?>View Details</a>
      </td> 
      <td>
        <?= $results['Type']; ?>
      </td>
      <td>
        <?= $results['Address']; ?>
      </td>
    </tr>


  <?php

}

Parse error: syntax error, unexpected $end in /home/

That means you missed a closing } or ). Double check you didn't delete an extra one when you were changing the code. If not post all of your code here and I will take a look for you.

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Search test page?</title>
<meta name="description" content="">
<meta name="keywords" content="ask,">
<meta name="author" content="Shahid Khan">
<meta name="robots" content="INDEX, FOLLOW">
<meta name="revisit-after" content="1 Day">
<meta name="generator" content="">
<style>
html, body
{
   height: 100%;
}
div#space
{
   width: 1px;
   height: 50%;
   margin-bottom: -367px;
   float:left
}
div#container
{
   width: 970px;
   height: 734px;
   margin: 0 auto;
   position: relative;
   clear: left;
}
body
{
   background-color: #FFFFFF;
   color: #000000;
   font-family: Arial;
   font-size: 8px;
   line-height: 1.1875;
   margin: 0;
   padding: 0;
}
</style>
<style>
@-webkit-keyframes animate-border
{
   0% { border-color: #000000;  }
   100% { border-color: #FF0000;  }
}
@-moz-keyframes animate-border
{
   0% { border-color: #000000;  }
   100% { border-color: #FF0000;  }
}
@-o-keyframes animate-border
{
   0% { border-color: #000000;  }
   100% { border-color: #FF0000;  }
}
@-ms-keyframes animate-border
{
   0% { border-color: #000000;  }
   100% { border-color: #FF0000;  }
}
@keyframes animate-border
{
   0% { border-color: #000000;  }
   100% { border-color: #FF0000;  }
}
a
{
   color: #0000FF;
   text-decoration: underline;
}
a:visited
{
   color: #800080;
}
a:active
{
   color: #FF0000;
}
a:hover
{
   color: #0000FF;
   text-decoration: underline;
}
</style>
<style>
#Image3
{
   border: 0px #000000 solid;
}
#Image6
{
   border: 0px #000000 solid;
}
#Image4
{
   border: 0px #000000 solid;
}
#Image1
{
   border: 0px #000000 solid;
}
#wb_Form1
{
   background-color: transparent;
   border: 0px #000000 solid;
}
#Editbox1
{
   border: 1px #565554 solid;
   background-color: #FFFFFF;
   color :#000000;
   font-family: Arial;
   font-weight: bold;
   font-style: italic;
   font-size: 27px;
   padding: 0px 0px 0px 2px;
   text-align: center;
   vertical-align: middle;
   -webkit-animation: animate-border 500ms ease-in-out 0ms infinite normal;
   -moz-animation: animate-border 500ms ease-in-out 0ms infinite normal;
   -ms-animation: animate-border 500ms ease-in-out 0ms infinite normal;
   animation: animate-border 500ms ease-in-out 0ms infinite normal;
}
#Button1
{
   border: 0px #A9A9A9 solid;
   -moz-border-radius: 2px;
   -webkit-border-radius: 2px;
   border-radius: 2px;
   background-color: transparent;
   background-image: url(images/page2_Button1_bkgrnd.png);
   background-repeat: repeat-x;
   background-position: left top;
   color: #FFFFFF;
   font-family: Arial;
   font-weight: bold;
   font-size: 27px;
}
#Layer2
{
   background-color: #FF8C00;
}
#Layer1
{
   background-color: #FF8C00;
}
#wb_Text2 
{
   background-color: transparent;
   border: 0px #000000 solid;
   padding: 0;
   text-align: left;
}
#wb_Text2 div
{
   text-align: left;
}
</style>
</head>
<body>
<div id="Layer2" style="position:absolute;text-align:left;left:0px;top:0px;width:100%;height:24px;z-index:3;" title="">
</div>
<div id="Layer1" style="position:absolute;text-align:center;left:0px;top:707px;width:100%;height:24px;z-index:4;" title="">
<div id="Layer1_Container" style="width:973px;position:relative;margin-left:auto;margin-right:auto;text-align:left;">
<div id="wb_Text2" style="position:absolute;left:2px;top:4px;width:968px;height:16px;z-index:2;text-align:left;">
<span style="color:#000000;font-family:Arial;font-size:13px;"><strong>Submit your content&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; Support&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; Complaint&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; Suggestion&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; Privacy&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; FAQ&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; Admin&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; Advertising</strong></span></div>
</div>
</div>
<div id="space"><br></div>
<div id="container">
<div id="wb_Image3" style="position:absolute;left:11px;top:160px;width:51px;height:45px;z-index:5;">
<img src="images/company.png" id="Image3" alt="" style="width:51px;height:45px;"></div>
<div id="wb_Image6" style="position:absolute;left:398px;top:155px;width:35px;height:44px;z-index:6;">
<img src="images/images%20%285%29.jpg" id="Image6" alt="" style="width:35px;height:44px;"></div>
<div id="wb_Image4" style="position:absolute;left:184px;top:157px;width:51px;height:45px;z-index:7;">
<img src="images/images%20%284%29.jpg" id="Image4" alt="" style="width:51px;height:45px;"></div>
<div id="wb_Image1" style="position:absolute;left:0px;top:24px;width:374px;height:113px;z-index:8;">
<img src="images/new%20sr.jpg" id="Image1" alt="" style="width:374px;height:113px;"></div>
<div id="wb_Form1" style="position:absolute;left:373px;top:40px;width:594px;height:110px;z-index:9;">
<form name="q" method="get" action="Result.php" id="Form1">
<input type="text" id="Editbox1" style="position:absolute;left:28px;top:8px;width:548px;height:44px;line-height:44px;z-index:0;" name="query" value="" title="Powerd By: Swat Corporation" placeholder="Type business, company, place, organization name ?">
<input type="submit" id="Button1" name="" value="Search" style="position:absolute;left:201px;top:70px;width:185px;height:34px;z-index:1;">
</form>
</div>
<div id="Html1" style="position:absolute;left:3px;top:208px;width:692px;height:160px;z-index:10">
<strong><font size="3">
<?php
    mysql_connect("localhost", "rrr", "Zam0ngX6kgapassnZST43ghqrAWhyd") or die("Error connecting to database: ".mysql_error());
    mysql_select_db("test") or die(mysql_error());
    $query = $_GET['query']; 
    $min_length = 3;
    $max_length = 15;
  if(strlen($query) >= $min_length)
  { 
        $query = htmlspecialchars($query); 
        $query = mysql_real_escape_string($query);  
  echo "<table border='0' width='' align='left' cellpadding='1' cellspacing='1'>";
  echo "<tr><h3>You have searched for $query... Please find the details of $query...</h3></tr>";
  echo "<tr align='center' bgcolor='#03acfa' > <td height='35px' width='125px'><b>Name</b></td> <td><b>Type</b></td> <td><b>Address</b></td></tr>";     
        $result = mysql_query("SELECT * FROM company WHERE (`Name` LIKE '%".$query."%') OR (`Type` LIKE '%".$query."%')") or die(mysql_error()); 
        if(mysql_num_rows($result) > 0)
  {
while($results = mysql_fetch_array($result))
{
  ?>
    <tr align='center' bgcolor='#93dafb'>
      <td height='25px'>
        <?= $results['Name']; ?> <a href="Get-Details.php?id=<?= $results['id']; ?>View Details</a>
      </td> 
      <td>
        <?= $results['Type']; ?>
      </td>
      <td>
        <?= $results['Address']; ?>
      </td>
    </tr>
  <?php
}

This is allmy code i try to edit but no result.

You're missing the last 10 lines of your original code.

        }
        else {
            echo "<tr align='center' bgcolor='#fdee03'><td colspan='2' height='25px'>Sorry..No data found for $query if you are owner for Business company / Organization you can add your content for submiting your content click here</td><tr>";

             echo "</table>";

      }
    }
    else {
        echo "<tr align='center' bgcolor='#fdee03' font size='10'><td colspan='2' height='25px'>Your search keyword contains letters only ".$min_length;

    }


?>

what missing

Check out this code it showing the following error:
Parse error: syntax error, unexpected '<', expecting ']' in C:\xampp\htdocs\Test4\result-colored.php on line 19

Code:

<?php
    mysql_connect("localhost", "root", "admin") or die("Error connecting to database: ".mysql_error());
    mysql_select_db("Search") or die(mysql_error());
    $query = $_GET['q']; 
    $min_length = 3;
    $max_length = 15;
  if(strlen($query) >= $min_length)
  { 
        $query = htmlspecialchars($query); 
        $query = mysql_real_escape_string($query);  
  echo "<table border='0' width='' align='left' cellpadding='1' cellspacing='1'>";
  echo "<tr><h3>You have searched Invoice verification for $query... Please find the details of $query...</h3></tr>";
  echo "<tr align='center' bgcolor='#03acfa' > <td height='35px' width='500px'><b>Name</b></td> <td><b>Type</b></td></tr>";     
        $result = mysql_query("SELECT * FROM company WHERE (`Name` LIKE '%".$query."%') OR (`Type` LIKE '%".$query."%')") or die(mysql_error()); 
        if(mysql_num_rows($result) > 0)
  {
            while($results = mysql_fetch_array($result))
   { 
                echo "<tr align='center' bgcolor='#93dafb'><td height='25px'>".$results[<a href="Profile.php?id=<? echo $rows['id']; ?>"><? echo $rows['Name']; ?></a>."</td> <td>".$results['Type']."</td></tr>";
            }

        }
        else{ 
            echo "<tr align='center' bgcolor='#fdee03'><td colspan='2' height='25px'>Sorry... No such data found for $query Please check your keyword OR type.</td><tr>"; 
   echo "</table>";  
        }   
    }
    else{ 
        echo "<tr align='center' bgcolor='#fdee03' font size='10'><td colspan='2' height='25px'>Your search keyword contains letters only ".$min_length;
    }
?>

Looks like you copied some un-needed code into your echo statement

[code]echo "<tr align='center' bgcolor='#93dafb'><td height='25px'><a href='Profile.php?id=" . $results['id'] . "'>" . $results['Name'] . "</a>.</td> <td>".$results['Type']."</td></tr>";
[/code]

*Sorry, stuck on a machine with IE7 at the moment which won't let me make the above into a code block

in line 19

echo "<tr align='center' bgcolor='#93dafb'><td height='25px'>".$results[<a href="Profile.php?id=<? echo $rows['id']; ?>"><? echo $rows['Name']; ?></a>."</td> <td>".$results['Type']."</td></tr>";

its show error.

but this works fine:

echo "<tr align='center' bgcolor='#93dafb'><td height='25px'>".$results['Name']."</td> <td>".$results['Type']."</td></tr>";

i want Name to be a link.

Did you try what I just posted?

echo "<tr align='center' bgcolor='#93dafb'><td height='25px'><a href='Profile.php?id=" . $results['id'] . "'>" . $results['Name'] . "</a>.</td> <td>".$results['Type']."</td></tr>";

Thanks Mr.GliderPilot its work, but in each result it retrive (.) in each rows

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.