Jump to content

html inside function


jebadoa

Recommended Posts

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>

Link to comment
Share on other sites

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....

Link to comment
Share on other sites

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());

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.