Jump to content

Archived

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

khoking

Box with Random Guestbook Text for Guestbook for osC(MS2) v1.0

Recommended Posts

I use Guestbook as my customer's testimonial as I like the simple design of it.

 

I want to create an infobox on my OSC store front page to display random guestbook entry in it. I have successfully pulled the info from the database, but I can't seems to get the guestbook text to display.

 

Below is my guestbook.php file in my INCLUDES/BOXES/ folder. I am a complete PHP idiot, so really hope someone can give some light / correction on my file below.

 

<?php
/*
Guestbook Box
*/
?>
<?php
 $random_guestbook =  tep_random_select("select g.entry_id, gd.entry_text as guestbook_text, g.entry_rating, g.date_added, g.visitors_name, g.visitors_location from " . TABLE_GUESTBOOK . " g, " . TABLE_GUESTBOOK_DESCRIPTION . " gd where g.entry_id = gd.entry_id and gd.languages_id = '" . (int)$languages_id . "' and g.entry_status = '1' ORDER BY rand() LIMIT 1")
?>
	  <tr>
	    <td>
<?php
   $info_box_contents = array();
   $info_box_contents[] = array('align' => 'left',
							 'text'  => BOX_HEADING_GUESTBOOK
						    );
   new infoBoxHeading($info_box_contents, false, false, tep_href_link(FILENAME_GUESTBOOK, '', 'NONSSL'));
   $guestbooktext = substr($guestbook_description[entry_text], 0, 100);
   $info_box_contents = array();
   $info_box_contents[] = array('align' => 'left',
							 'text' => '<a href="' . tep_href_link(FILENAME_GUESTBOOK, tep_get_all_get_params(array('language', 'currency')) .'&entry_id=' . $random_guestbook['entry_id']) . '"><b><center>' . $guestbooktext . '</center></b><br><b>Read More</b></a><br><br><table align="right" border="0" cellspacing="0" cellpadding="0"><tr align="right"><td align="right" class="infoBoxContents">' .  '<b>'.$random_guestbook['visitors_name'].'     </b></td></tr></table>'
							 );
   new infoBox($info_box_contents);
?>
	    </td>
	  </tr>


Best regards,

Koh Kho King

Share this post


Link to post
Share on other sites

Did you add an include for this file in your includes/column_left.php?

 

You're using the array value $guestbook_description[entry_text] which is never defined. Also, the syntax is wrong, and you're trying to retrieve the wrong value. Try $random_guestbook['guestbook_text'] instead.

 

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites

Dear Jim,

 

Thank you very much!

 

$random_guestbook['guestbook_text'] did pulled the correct data from the database! Thanks!!!


Best regards,

Koh Kho King

Share this post


Link to post
Share on other sites

Dear Jim,

 

In my customer's feedback. When there is an ' symbol in the text, eg. I'm, it will show as I\'m in the guestbook page. Do you know how to get rid of the \ ?

 

eg

 

Why don\'t have Canon 430EX II Speedlite? I\'m considering to order 1... Reply: Yes, we have. You can use the search feature at the upper left column and key in 430EX, then you will find the product.


Best regards,

Koh Kho King

Share this post


Link to post
Share on other sites

Use this: stripslashes( $random_guestbook['guestbook_text'] )

 

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites

×