idgeit Posted March 18, 2007 Share Posted March 18, 2007 Hey all, Really simple question, I get data from a mysql database and its $product_id How can i put this into the link /addtocart.php?id=Product_id Thanks! ~ Idgeit Link to comment https://forums.phpfreaks.com/topic/43228-solved-mysql-into-link/ Share on other sites More sharing options...
pocobueno1388 Posted March 18, 2007 Share Posted March 18, 2007 <a href="/addtocart.php?id=$product_id">Link</a> Link to comment https://forums.phpfreaks.com/topic/43228-solved-mysql-into-link/#findComment-209877 Share on other sites More sharing options...
idgeit Posted March 18, 2007 Author Share Posted March 18, 2007 the page with the link on it has no probem, but the url is making is /addtocart.php?id=$product_id instead of the product id, ??? Link to comment https://forums.phpfreaks.com/topic/43228-solved-mysql-into-link/#findComment-209885 Share on other sites More sharing options...
trq Posted March 18, 2007 Share Posted March 18, 2007 Post the relevent code. Link to comment https://forums.phpfreaks.com/topic/43228-solved-mysql-into-link/#findComment-209891 Share on other sites More sharing options...
pocobueno1388 Posted March 18, 2007 Share Posted March 18, 2007 Make sure you have double quotes around the echo or print. echo "<a href='/addtocart.php?id=$product_id'>Link</a>"; Link to comment https://forums.phpfreaks.com/topic/43228-solved-mysql-into-link/#findComment-209893 Share on other sites More sharing options...
idgeit Posted March 18, 2007 Author Share Posted March 18, 2007 <?php $handle = mysql_connect('xxx', 'xx', 'xxxx'); if($handle == false){ die("Could not connect to MySQL. Exiting.\r\n"); } $db = mysql_select_db('xxxx'); if($db == false){ die("Could not select MySQL DB. Exiting.\r\n"); } $query = "SELECT products.product_id, products.product_dis, products.product_price, products.product_title, products.product_pic FROM products WHERE products.product_id = ".$_GET['id']; $result = mysql_query($query, $handle); while($row = mysql_fetch_assoc($result)){ $product_id = $row["product_id"]; $product_dis = $row["product_dis"]; $product_title = $row["product_title"]; $product_price = $row["product_price"]; $product_pic = $row["product_pic"]; } mysql_close($handle); ?> <?php include('phpinclude/top.php'); ?><br> <table width="74%" height="486" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="22%" rowspan="2" valign="top"><?php include('phpinclude/menu.php'); ?> </td> <td width="78%" height="333"><br> <br> <br> <br> <br> <br> <br> <table width="85%" height="48" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="55%" valign="top"> <table width="100%" height="119" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="36%" height="18" bgcolor="#CCCCCC"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Product No.</strong></font></td> <td width="64%" bgcolor="#CCCCCC"> <font size="2" face="Verdana, Arial, Helvetica, sans-serif"><?php echo ("$product_id"); ?></font></td> </tr> <tr bgcolor="#EAEAEA"> <td height="18"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Title:</strong></font></td> <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><?php echo ("$product_title"); ?> </font></td> </tr> <tr> <td height="18" bgcolor="#CCCCCC"><p><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Description:</strong></font></p> <p> </p></td> <td valign="top" bgcolor="#CCCCCC"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><?php echo ("$product_dis"); ?></font></td> </tr> <tr bgcolor="#EAEAEA"> <td height="18"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Price:</strong></font></td> <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif">€<?php echo ("$product_price"); ?></font></td> </tr> <tr> <td bgcolor="#CCCCCC"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> </font></td> <td bgcolor="#CCCCCC"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> </font></td> </tr> </table></td> <td width="45%" valign="top"><img src= <?php echo $product_pic; ?> height="150" width="150"></td> </tr> </table> <br> <a href="/addtocart.php?id=$product_id">Link</a> </tr> <tr> <td height="153"></td> </tr> </table> <br> <?php include ('phpinclude/trailer.php'); ?> Link to comment https://forums.phpfreaks.com/topic/43228-solved-mysql-into-link/#findComment-209894 Share on other sites More sharing options...
shaunrigby Posted March 18, 2007 Share Posted March 18, 2007 <br> <a href="/addtocart.php?id=<?php print $product_id; ?>">Link</a> </tr> Link to comment https://forums.phpfreaks.com/topic/43228-solved-mysql-into-link/#findComment-209896 Share on other sites More sharing options...
trq Posted March 18, 2007 Share Posted March 18, 2007 <a href="addtocart.php?id=<?php echo $product_id; ?>">Link</a> Link to comment https://forums.phpfreaks.com/topic/43228-solved-mysql-into-link/#findComment-209897 Share on other sites More sharing options...
idgeit Posted March 18, 2007 Author Share Posted March 18, 2007 thats it! Thanks for all the help ~ Idgeit Link to comment https://forums.phpfreaks.com/topic/43228-solved-mysql-into-link/#findComment-209898 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.