Jump to content

Need code to not only see one href site, but how to show more than one.


hendrikbez
Go to solution Solved by Barand,

Recommended Posts

I have the following code to show the token address in bscscan.

I need it to be able to show ethscan website, pologon website eg.

How can I let it get the correct one, when I add a token adress

<td>
<a href="https://bscscan.com/token/<?php echo $checkSqlRow["ADDRESS"]; ?>">
<?php echo $checkSqlRow["ADDRESS"]; ?>
</a></td>

 

Link to comment
Share on other sites

:psychic:

The best way we can help is if you know what you want to do but don't know what the code needs to be. We're good with code. We're not good with things like "able to show ethscan website".

You have to figure out what it is you need to do - like, are you talking about a <a> or an <iframe> or what - and then we can show you what code you need to do it.

Link to comment
Share on other sites

31 minutes ago, requinix said:

:psychic:

The best way we can help is if you know what you want to do but don't know what the code needs to be. We're good with code. We're not good with things like "able to show ethscan website".

You have to figure out what it is you need to do - like, are you talking about a <a> or an <iframe> or what - and then we can show you what code you need to do it.

Ok, thank you, will try to explain again. 

 

At the moment this code is working.

<td>
	<a href="https://bscscan.com/token/<?php echo $checkSqlRow["ADDRESS"]; ?> "style="color:lime" target="_blank">
	<?php echo $checkSqlRow["ADDRESS"]; ?>	</a>
</td>

I I want to let it see different https addresses like tronscan ethscan eg.   

If I try the following code (I know it is wrong), then it needs to be added in ["ADDRESS"] eg bscscan or ethscan or anyone other tokenscan  instead of [OXDweed5433......]that is in ["ADDRESS] .

This is were I am stuck. on how to get it to work.

<td><?php
       $checkSqlRow["ADDRESS"] = strtolower($checkSqlRow["ADDRESS"]);
          if ($checkSqlRow["ADDRESST"] == "bscscan") {
              echo '<a href="https://bscscan.com/token/<?php echo $checkSqlRow["ADDRESS"]; ?></a>';
          } elseif ($checkSqlRow["WALLET"] == "altcoin trader") {
              echo '<a href="https://ethscan.com/token/<?php echo $checkSqlRow["ADDRESS"]; ?></a>';
          }
          ?>	
</td>

 

Screenshot_12.png

Screenshot_11.png

Link to comment
Share on other sites

So basically it's a question of syntax.

<?php tags are for entering PHP mode.

this is html mode
<?php
this is php mode
echo "this is still php mode even though you're outputting html";
?>
back to html mode

So the <?php in

echo '<a href="https://bscscan.com/token/<?php echo $checkSqlRow["ADDRESS"]; ?></a>';

won't work because you're already in PHP mode. Compare that to

<a href="https://bscscan.com/token/<?php echo $checkSqlRow["ADDRESS"]; ?> "style="color:lime" target="_blank">

which starts in HTML mode, uses <?php to switch to PHP mode and output the address, then switches back to HTML mode.

If you want to echo some HTML with a PHP variable in it, you can do that with

echo '<a href="https://bscscan.com/token/', $checkSqlRow["ADDRESS"], '</a>';

 

Link to comment
Share on other sites

1 hour ago, hendrikbez said:

My first code is working 100%.

Which is why I didn't say anything about it being wrong or not working.

1 hour ago, hendrikbez said:

I am trying to find out on how to add different token scans in the same code.

And I'm trying to tell you what you have to change with your not-working code in order to make it work.

Link to comment
Share on other sites

Thank you, I am new at learning PHP, I did pay a person to do this for me, and I am working from what he did, I already did make a lot of changes, but still have problems understanding this code.

12 hours ago, requinix said:
this is html mode
<?php
this is php mode
echo "this is still php mode even though you're outputting html";
?>
back to html mode

I see what you are saying here to me, If I start with <?php  and end with ?> then I do not need to use in in between the code again. If it is so, then I have to go thru all the code and fix it.

Ok, I have make a new column ["BLOCKCHAIN"] with all of the blockchains  that can be used.

I do not get it to work, see code below,  something is wrong in the code

I need to show the address in ["ADDRESS"] like (x0bfbgf66........), and when I click on it it must open the link.

What is happening now, when running, it  the <td> is removed and not showing in my table, it move for the row I changed one <td> back

<td>
	<?php
		$checkSqlRow["ADDRESS"] = strtolower($checkSqlRow["ADDRESS"]); 
			if ($checkSqlRow["BLOCKCHAIN"] == "bscscan")
				{
					echo '<a href="https://bscscan.com/token/', $checkSqlRow["ADDRESS"], '</a>';
				} 
			elseif ($checkSqlRow["BLOCKCHAIN"] == "tronscan")
				{
					echo '<a href="https://tronscan/token/', $checkSqlRow["ADDRESS"], '</a>';
				} 
			elseif ($checkSqlRow["BLOCKCHAIN"] == "dgb")
				{
					echo '<a href="https://dgb.com/token/', $checkSqlRow["ADDRESS"], '</a>'; 
				} 
			elseif ($checkSqlRow["BLOCKCHAIN"] == "hecoinfo")
				{
					echo '<a href="https://heco.com/token/', $checkSqlRow["ADDRESS"], '</a>';
				} 
			elseif ($checkSqlRow["BLOCKCHAIN"] == "polygonscan") 
				{
					echo '<a href="https://polyn.com/token/', $checkSqlRow["ADDRESS"], '</a>';
				} 
			elseif ($checkSqlRow["BLOCKCHAIN"] == "rvn") 
				{
					echo '<a href="https://rvn.com/token/', $checkSqlRow["ADDRESS"], '</a>';
				} 
			elseif ($checkSqlRow["BLOCKCHAIN"] == "etherscan") 
				{
					echo '<a href="https://ethn.com/token/', $checkSqlRow["ADDRESS"], '</a>'; 
				} 
			elseif ($checkSqlRow["BLOCKCHAIN1"] == "thundercore") 
				{
					echo '<a href="https://tttn.com/token/', $checkSqlRow["ADDRESS"], '</a>';
				} 
			elseif ($checkSqlRow["BLOCKCHAIN"] == "solscan") 
				{
					echo '<a href="https:/solscan.com/token/', $checkSqlRow["ADDRESS"], '</a>';
				}
	?>	
</td>

 

Screenshot_13.png

Edited by hendrikbez
Link to comment
Share on other sites

  • Solution

Use an array - it cuts out a lot of repetetive code

$domains   = [  "bscscan"     => "bscscan.com",
                "tronscan"    => "tronscan",                                                       //  .com ???
                "dgb"         => "dgb.com",
                "hecoinfo"    => "heco.com",
                "polygonscan" => "polyn.com",
                "rvn"         => "rvn.com",
                "etherscan"   => "ethn.com",
                "thundercore" => "tttn.com",
                "solscan"     => "solscan.com"
             ];

$address = strtolower($checkSqlRow["ADDRESS"]);
echo "<td><a href='https://{$domains[$checkSqlRow["BLOCKCHAIN"]]}/token/$address'>$address</a></td>";

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.