KurveMedia Posted April 7, 2008 Share Posted April 7, 2008 This is my first post, so im hoping somebody here can help. My problem is i have a directory that im buliding and there are free listing for businesses and paid listings for businesses. one of the features of the paid listing is that the listing will include a link to google maps. Problem is i only want that information to show up for paid listings and not both free and paid. when the business owner signs up for thier paid listing, there is a hidden field in the form that populates a field in the database with the type of listing "free" or "paid". How would i be able to only have the link viewable on paid listings. just alittle FYI im fairly new to PHP. Any help would be great. Thanks in advance Mike Quote Link to comment Share on other sites More sharing options...
poleposters Posted April 7, 2008 Share Posted April 7, 2008 Hi Mike My approach is to add a column in your database called paid_listing and assign it a value either '0' or '1'. '0' for unpaid listings and '1' for paid listings. Then all you need to do is run a query that tests the value of this field. ie if paid listing==1 print "link to google maps" I could be more specific if you posted some of your code. Hope it helps. Matt Quote Link to comment Share on other sites More sharing options...
KurveMedia Posted April 8, 2008 Author Share Posted April 8, 2008 poleposters Thanks for the quick response, below is my code for the listings page. thanks in advance <?php require_once('Connections/latinolinx.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $maxRows_rsSubCat = 10; $pageNum_rsSubCat = 0; if (isset($_GET['pageNum_rsSubCat'])) { $pageNum_rsSubCat = $_GET['pageNum_rsSubCat']; } $startRow_rsSubCat = $pageNum_rsSubCat * $maxRows_rsSubCat; $colname_rsSubCat = "-1"; if (isset($_GET['MainCat'])) { $colname_rsSubCat = $_GET['MainCat']; } mysql_select_db($database_latinolinx, $latinolinx); $query_rsSubCat = sprintf("SELECT MainCat, SubCat FROM subcategory WHERE MainCat = %s", GetSQLValueString($colname_rsSubCat, "text")); $query_limit_rsSubCat = sprintf("%s LIMIT %d, %d", $query_rsSubCat, $startRow_rsSubCat, $maxRows_rsSubCat); $rsSubCat = mysql_query($query_limit_rsSubCat, $latinolinx) or die(mysql_error()); $row_rsSubCat = mysql_fetch_assoc($rsSubCat); if (isset($_GET['totalRows_rsSubCat'])) { $totalRows_rsSubCat = $_GET['totalRows_rsSubCat']; } else { $all_rsSubCat = mysql_query($query_rsSubCat); $totalRows_rsSubCat = mysql_num_rows($all_rsSubCat); } $totalPages_rsSubCat = ceil($totalRows_rsSubCat/$maxRows_rsSubCat)-1; $maxRows_rsListing = 10; $pageNum_rsListing = 0; if (isset($_GET['pageNum_rsListing'])) { $pageNum_rsListing = $_GET['pageNum_rsListing']; } $startRow_rsListing = $pageNum_rsListing * $maxRows_rsListing; mysql_select_db($database_latinolinx, $latinolinx); $query_rsListing = "SELECT * FROM listings"; $query_limit_rsListing = sprintf("%s LIMIT %d, %d", $query_rsListing, $startRow_rsListing, $maxRows_rsListing); $rsListing = mysql_query($query_limit_rsListing, $latinolinx) or die(mysql_error()); $row_rsListing = mysql_fetch_assoc($rsListing); if (isset($_GET['totalRows_rsListing'])) { $totalRows_rsListing = $_GET['totalRows_rsListing']; } else { $all_rsListing = mysql_query($query_rsListing); $totalRows_rsListing = mysql_num_rows($all_rsListing); } $totalPages_rsListing = ceil($totalRows_rsListing/$maxRows_rsListing)-1; Quote Link to comment Share on other sites More sharing options...
poleposters Posted April 8, 2008 Share Posted April 8, 2008 Hey Mike, Not sure if you've posted the right bit of code.I'm only quite new to PHP.I can see that you've selected the listing data and then put it into an array.But I don't think you show the code that actually prints the listing. What you need to do is make sure that the query also pulls out the data from the paid_listing column, so that when you print the listings you can print the extra info for the paid listing. e.g print "yourarrayname[business_name];" print "yourarrayname[phone_number];" print "yourarrayname[address];" if(yourarrayname[paid listing]==1) print"yourarrayname[linktogooglemap];" This way the premium listing link to googlemaps only appears if the paid_listing field for that business is ==1. Quote Link to comment Share on other sites More sharing options...
KurveMedia Posted April 8, 2008 Author Share Posted April 8, 2008 hey poleposter i think this is what your looking for, im fairly new to php also., i appreciate the help. <h3><?php echo $_GET['SubCat']; ?></h3> <hr /> <table border="1"> <tr> <td> </td> <td> </td> <td> </td> </tr> <?php do { ?> <tr> <td><?php echo $row_rsListing['BusinessLogo']; ?></td> <td><?php echo $row_rsListing['BusinessName']; ?></td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td>Address:</td> <td> </td> </tr> <tr> <td> </td> <td><?php echo $row_rsListing['BusinessStreet']; ?></td> <td> </td> </tr> <tr> <td> </td> <td><?php echo $row_rsListing['BusinessCity']; ?></td> <td><?php echo $row_rsListing['BizState']; ?></td> </tr> <tr> <td> </td> <td> </td> <td><?php echo $row_rsListing['BusinessZip']; ?></td> </tr> <tr> <td> </td> <td>Contact Information:</td> <td> </td> </tr> <tr> <td> </td> <td><?php echo $row_rsListing['BusinessPhone']; ?></td> <td> </td> </tr> <tr> <td> </td> <td><?php echo $row_rsListing['WebAddress']; ?></td> <td> </td> </tr> <tr> <td> </td> <td>Map:</td> <td> </td> </tr> <?php } while ($row_rsListing = mysql_fetch_assoc($rsListing)); ?> </table> </div> Thanks Mike Quote Link to comment Share on other sites More sharing options...
poleposters Posted April 9, 2008 Share Posted April 9, 2008 I've changed the code below. It should work, as long as you have a column called 'paid_listing in the same table where all the other array information is retrieved ie BusinesLogo,BusinessName etc. Have the paid_listing record set to '0' by default and update it to '1' when the paid listing is purchased. That way the condition if ($$row_rsListing['paid_listing']>0 is satisfied, and the print link to googlemaps is executed. <h3><?php echo $_GET['SubCat']; ?></h3> <hr /> <table border="1"> <tr> <td> </td> <td> </td> <td> </td> </tr> <?php do { ?> <tr> <td><?php echo $row_rsListing['BusinessLogo']; ?></td> <td><?php echo $row_rsListing['BusinessName']; ?></td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td>Address:</td> <td> </td> </tr> <tr> <td> </td> <td><?php echo $row_rsListing['BusinessStreet']; ?></td> <td> </td> </tr> <tr> <td> </td> <td><?php echo $row_rsListing['BusinessCity']; ?></td> <td><?php echo $row_rsListing['BizState']; ?></td> </tr> <tr> <td> </td> <td> </td> <td><?php echo $row_rsListing['BusinessZip']; ?></td> </tr> <tr> <td> </td> <td>Contact Information:</td> <td> </td> </tr> <tr> <td> </td> <td><?php echo $row_rsListing['BusinessPhone']; ?></td> <td> </td> </tr> <tr> <td> </td> <td><?php echo $row_rsListing['WebAddress']; ?></td> <td> </td> </tr> <tr> <td> </td> [color=limegreen]<td> <?php if ($$row_rsListing['paid_listing']>0) { print " LINK TO GOOGLEMAPS"; } </td>[/color] <td> </td> </tr> <?php } while ($row_rsListing = mysql_fetch_assoc($rsListing)); ?> </table> </div> Quote Link to comment Share on other sites More sharing options...
KurveMedia Posted April 21, 2008 Author Share Posted April 21, 2008 Poleposter I used the code you said to use and im gettign the following error when i acccess that page "Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/content/l/a/t/latinolinx/html/testing/listing.php on line 250" the follow code is what is on line 250 echo "<a href=\"http://maps.google.com/maps?f=q&hl=es&q=$row_rsListing['businessNumber'],$row_rsListing['BusinessStreet'],$row_rsListing['BusinessCity'],$row_rsListing['BizState'],$row_rsListing['BusinessZip']\">View Map</a>";} Quote Link to comment Share on other sites More sharing options...
poleposters Posted April 25, 2008 Share Posted April 25, 2008 If its a t_sting parse error it usually means its a problem with quote marks or semicolons etc. Try removing the single quotes from the arrays ie $row_rsListing[businessNumber] instead of $row_rsListing['businessNumber'], Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.