Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Php and mysql link

Posted on 2013-11-12
10
Medium Priority
?
266 Views
Last Modified: 2014-06-04
I'm pulling a link out of my mysql database and trying to add an id to it.  Here is the code to pull the data out of the database:

<?php 
$sql = mysql_query("SELECT * FROM ybgstores WHERE cat_id=$cat_id ORDER BY storename");

echo" <table width='100%' border='0'>
  <tr>
    <th width='25%'><h5>Store</h5></th>
	<th width='50%'><h5><div align='center'>Description</div></h5></th>
    <th width='25%'><h5><div align='center'>Donation</div></h5></th>

 </tr>";

while ($row = mysql_fetch_array($sql)){
		echo "<tr>";
		echo "<td width='25%'>".$row['logo_link']."</td>";
		echo "<td width='50%'><div align='left'>".$row['description']."</div></td>";
		echo "<td width='10%'><div align='center'>".$row['donat_percent']."</div></td>";
		echo "</tr>";
		echo "<tr>";
		echo "<td colspan='3'><hr size='1' /></td>";
		echo "</tr>";
}
		echo "</table>";
	
?>

Open in new window


Which gives my this:

<a href="http://www.tkqlhce.com/click-7227717-10716258[b]?sid= echo $sid;[/b]" target="_blank">
<img src="http://www.ftjcfx.com/image-7227717-10716258" width="75" height="75" alt="AllPosters.com   " border="0"/></a>

Open in new window


Now i want to add the sid?  - ?sid= echo $sid; but it only renders it as text it dosen't process the php code and the sid variable.

What am I missing and yes I'm new at this.  Thank in advance
0
Comment
Question by:Monte2256
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
10 Comments
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 39642719
It's not clear where the second part is coming from in the first part.  What does $row['description'] show by itself?
0
 

Author Comment

by:Monte2256
ID: 39643039
That is coming from mysql database
0
 

Author Comment

by:Monte2256
ID: 39643048
Description is in the database here is the website that I'm working on. http://pw5n.com/ybg/products.php?sid=Feeding%20America

If you look att he link behind the image you will see what I'm talking about.

Thank you
Bill
0
The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 39643126
The problem is that there are a number of ways to add things to the text.  I am having trouble figuring out Exactly what is coming from the database.  Once I know that, I can tell how to add the 'sid' part.  Does it need to go in the middle of the text or at the end?
0
 
LVL 44

Expert Comment

by:Chris Stanyon
ID: 39643315
The link behind the image on your site is this:

http://www.tkqlhce.com/click-7227717-10716258?sid=Feeding America

There is no PHP code echoing out - it appears to be working as you expect it to, unless I'm missing something!
0
 

Author Comment

by:Monte2256
ID: 40112212
Hi David

This works but is there a better way

It has to go in the middle of the link, my client enters and breaks the link into parts to putting the sid=  in as seen in the picture below.  The on the page the link is reassembled and the sid code is echoed from the session.

first part of link:
<a href="http://www.tkqlhce.com/click-7227717-11304284?sid=

Second part of link:
" target="_blank">
<img src="http://www.tqlkg.com/image-7227717-11304284" width="89" height="90" alt="1SaleADay.com - Great Deals, Just 24 Hours" border="0"/></a>

split link


The session data "feeding-america" has to go in the middle of the link right after the sid=

my code to reassemble the link looks like this and adds the session id data in the middle:
<?php
$sql = mysql_query("SELECT * FROM ybgstores WHERE cat_id=$cat_id ORDER BY storename");

echo" <table width='100%' border='0'>
  <tr>
    <th width='25%'><h5>Store</h5></th>
      <th width='50%'><h5><div align='center'>Description</div></h5></th>
    <th width='25%'><h5><div align='center'>Donation</div></h5></th>

 </tr>";

while ($row = mysql_fetch_array($sql)){
            echo "<tr>";
            echo "<td width='25%'>".$row['logo_link']."&sid=$_SESSION[sid] target='_blank'".$row['logo_link2']."</td>";
            echo "<td width='50%'><div align='left'>".$row['description']."</div></td>";
            echo "<td width='10%'><div align='center'>".$row['donat_percent']."</div></td>";
            echo "</tr>";
            echo "<tr>";
            echo "<td colspan='3'><hr size='1' /></td>";
            echo "</tr>";
}
            echo "</table>";
            
            
            
?>
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 40112253
You're putting target='_blank' in there twice.  Should probably be...

echo "<td width='25%'>".$row['logo_link']."&sid=".$_SESSION[sid].$row['logo_link2']."</td>";

Open in new window

0
 

Author Comment

by:Monte2256
ID: 40112261
Yes thank you that's a mistake, but is there a better way of doing this?
0
 
LVL 84

Accepted Solution

by:
Dave Baldwin earned 2000 total points
ID: 40112270
I don't know but that should fix the problem with the code you posted.
0
 

Author Closing Comment

by:Monte2256
ID: 40112274
Thank you
0

Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
In this article, we’ll look at how to deploy ProxySQL.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Six Sigma Control Plans

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question