Jump to content

[SOLVED] Make hyperlink in dynamic listing


oceans

Recommended Posts

Dear People,

 

I do sql and populate a table with say 5 column,

I want one to be a hyperlink to next page, thus I did the following but it is not working.

Where could I have gone wrong?

 

 

echo "<table>";

$i=0;

while($row = mysql_fetch_assoc($result))

{

echo "<tr>";

echo "<td class=FieldName><a herf=/MyPHP/nextpage.php>".$row['Number']."</a></td>";

echo "<td class=FieldName>".$row['STID']."</td>";

echo "<td class=FieldName>".$row['Name']."</td>";

echo "<td class=FieldName>".$row['Add']."</td>";

echo "<td class=FieldName>".$row['Tel']."</td>";

echo "</tr>";

}

echo "</table>";

 

Link to comment
https://forums.phpfreaks.com/topic/49941-solved-make-hyperlink-in-dynamic-listing/
Share on other sites

Invalid html?

 

echo "<table>";
      $i=0;
      while($row = mysql_fetch_assoc($result))
      {
          echo "<tr>";
          echo "<td class='FieldName'><a herf='/MyPHP/nextpage.php'>".$row['Number']."</a></td>";
          echo "<td class='FieldName'>".$row['STID']."</td>";
          echo "<td class='FieldName'>".$row['Name']."</td>";
          echo "<td class='FieldName'>".$row['Add']."</td>";
          echo "<td class='FieldName'>".$row['Tel']."</td>";
          echo "</tr>";
      }
      echo "</table>";

 

Please, use the [ code ] [/ code ] tags (no space) when posting code.

your html isnt right

 

 

" a herf " SHOULD BE " a href"

echo "<td class='FieldName'><a hERf='/MyPHP/nextpage.php'>".$row['Number']."</a></td>";

Should BE!!!

echo "<td class='FieldName'><a hREf='/MyPHP/nextpage.php'>".$row['Number']."</a></td>";

your html isnt right

 

 

" a herf " SHOULD BE " a href"

echo "<td class='FieldName'><a hERf='/MyPHP/nextpage.php'>".$row['Number']."</a></td>";

Should BE!!!

echo "<td class='FieldName'><a hREf='/MyPHP/nextpage.php'>".$row['Number']."</a></td>";

 

 

What a nice shoot...

personally i would pass the id number in the GET method through the link you just made

lets say your pages contain messages.

then if you want certain pages to appear you will have to apply the LIMIT into your sql

lets say the link = is like followed

echo "<td class='FieldName'><a href='/MyPHP/nextpage.php?start=".$row['Number'].">".$row['Number']."</a></td>";

will output a link something like

nextpage.php?start=15

 

then in your php script call for the $_GET['start'] id.

and execute the page query like this.

 

 

---> simple example ----> mysql_query("SELECT * FROM TABLE LIMIT 1,15");

$number_of_messages = 5;
---> real deal ---------->mysql_query("SELECT * FROM TABLE LIMIT '$_GET['start']','$number_of_messages' ");

 

THE LIMIT FUNCTION in the query will make sure your query only selects the needed messages,

"LIMIT 323,10" will cause the query to skip selecting the 323 first messages en only select the 10 after 323.

 

so "LIMIT 323,10" will select 323,324,325,32.....

and

so "LIMIT 19,2" will select 19 AND 20

 

Hope this helps

 

Greeting

Silverado

What a nice shoot...

thank you:)

 

my programming skills where so terrible on the beginning, that i turned into a "PRO syntax error searching machine":)

i can distinguishe a dot from a comma from over 2 meter away from my screen:)

 

please post the related code here in the forum

put in between CODE tags!!!!!

 

"<a href='/MyPHP/Service/ST/nextpage.php?start=45>45"

what i shoud be seeing is

"45"

you probely did not close the A TAGS

so it should be like this!!!!

echo "<a href='/MyPHP/nextpage.php?start=".$row['Number'].">".$row['Number']."</a>";

 

further i only get to see one entry.

is your LIMIT written as it should be????

please show your code and put it between the CODE TAGS

 

[/code/]

 

while($row = mysql_fetch_assoc($result))

{

echo "<td class='FieldName'><a href='/MyPHP/Service/ST/NewPage.php?start=".$row['Number'].">".$row['Number']."</a></td>";

echo "<td class=FieldName>".$row['STID']."</td>";

echo "<td class=FieldName>".$row['Name']."</td>";

echo "<td class=FieldName>".$row['Address']."</td>";

echo "</tr>";

}

echo "</table>";

 

[/code/]

[/code/]

 

while($row = mysql_fetch_assoc($result))

{

echo "<td class='FieldName'><a href='/MyPHP/Service/ST/NewPage.php?start=".$row['Number'].">".$row['Number']."</a></td>";

echo "<td class=FieldName>".$row['STID']."</td>";

echo "<td class=FieldName>".$row['Name']."</td>";

echo "<td class=FieldName>".$row['Address']."</td>";

echo "</tr>";

}

echo "</table>";

 

[/code/]

these still arent the right tags:):):)

open with [ CODE ] without spaces.

and close em with [ / CODE ] also without spaces

cause if you dont.

echo "<td class='FieldName'><a href='/MyPHP/nextpage.php?start=".$row['Number'].">".$row['Number']."</a></td>";

will turn into

echo "<td class='FieldName'><a href='/MyPHP/nextpage.php?start=".$row['Number'].">".$row['Number']."[/url]</td>";

notice the A CLOSING TAG CHANGED INTO AND URL CLOSING TAG?????

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.