Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

2 words variable problem 1

Status
Not open for further replies.

Cristii00

Programmer
Nov 18, 2002
8
0
0
RO
I have a table in the database and one of the fields needs to have two or more words. Let's say it's a field called "name" and i have in it names like "John William Johnson", "Alley Cat" and others.
I take out all the fields in the table in a php file, and these names become links to another page "test2.php".
What i need is to take the whole variable, both two words.
Instead of having "test2.php?num=Alley" i need to have something like "test2.php?num=Alley Cat" (or eventually test2.php?num=Alley%20Cat).
In the page i open i want to have the variable as two separate words, as it was originally. For example if i need to print it, it should be "Alley Cat" , and not "Alley%20Cat"

Ok, i guess you understand my problem. So far i can only take the first word as a variable.
 
you problem is not quite clear... can you post some code? [cheers]
Cheers!
Laura
 
Try this
Code:
echo '<a href=&quot;anotherpage.php?avar=' . urlencode($avar) . '&quot;>Click this link</a>';
//Daniel
 
here is my code:
..........
$sql= &quot;SELECT * FROM names&quot;;
$sql_result = mysql_query($sql,$connection) or die (&quot;Could not select data&quot;);

while($myrow = mysql_fetch_array($sql_result)) {
print( &quot; <tr>
<td>&quot;.$myrow[&quot;id&quot;].&quot;</td>
<td>&quot;.&quot;<A HREF=log.php?num=$myrow[name]>$myrow[name]</A>&quot;.&quot;</td>
</tr><br>&quot;);
}

 
Code:
$sql= &quot;SELECT * FROM names&quot;;
$sql_result = mysql_query($sql,$connection) or die (&quot;Could not select data&quot;);

 while($myrow = mysql_fetch_array($sql_result)) {
        print( &quot;  <tr>
    <td>&quot;.$myrow[&quot;id&quot;].&quot;</td>
    <td>&quot;.&quot;<A HREF=\&quot;log.php?num=&quot; . urlencode($myrow[name]) . &quot;\&quot;>$myrow[name]</A>&quot;.&quot;</td>
    </tr><br>&quot;);
}
//Daniel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top