jebadoa Posted July 25, 2008 Share Posted July 25, 2008 Hi gurus, I am just getting started in PHP and trying to figure this out. I have a clip from a page that repeats in several places. It would be good as a function, but it has html in it. How do I deal with that? Here is the code: <div class="panelScrollBox"> <?php $data = mysql_query("SELECT * FROM videos WHERE category='br'") or die(mysql_error()); while($info = mysql_fetch_array( $data )) { ?> <div class="panelDivider"> <a href="of.html"><img src="/images/<?php print $info['thumb']; ?> " alt="ALTDATA" border= "0"class="panelVid" /></a> <span class="videoTitle"><?php print $info['title']; ?></span> <br /> <?php print $info['price']; ?> (Quicktime) <strong><?php print $info['length']; ?></strong>. <br /> <a href="<?php print $info['buymovbtn']; ?>" target="ej_ejc" class="ec_ejc_thkbx" onClick="javascript:return EJEJC_lc(this);"> <img src="images/buyMOV.png" border="0" alt="Add to Cart"/></a><br /><br /> </div> <?php } ?> </div> Quote Link to comment Share on other sites More sharing options...
MFHJoe Posted July 25, 2008 Share Posted July 25, 2008 Same way you've done the while statement mate. <?php function panelscrollbox() { ?> at the top, and simply <?php } ?> at the bottom. Then just call the function with panelscrollbox(); Quote Link to comment Share on other sites More sharing options...
jebadoa Posted July 25, 2008 Author Share Posted July 25, 2008 Thanks! That works, and now I am trying to pass a value in so that it will select videos from a certain category: function displayVideos($cat) and my query is $data = mysql_query("SELECT * FROM videos WHERE category='$cat'") I call the function with: <?php include('sbfunctions.php'); displayVideos("pitching"); ?> but it displays videos from another category ??? (not sure how you displayed code in blocks.... Quote Link to comment Share on other sites More sharing options...
Entanio Posted July 25, 2008 Share Posted July 25, 2008 Simply, Put: displayVideos(*cat name*) and in your function: function displayVideos($cat){ $data = mysql_query("SELECT * FROM videos WHERE category='$cat'") or die(mysql_error()); 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.