0

Hi all i need to update some iframe values in my videos table, embed column. Can I achieve this with this kind code below ? I tried already but i got syntax errors. Please help me. here is the code

type of column embed is text.

UPDATE videos
SET embed RAND('<iframe src="http://example.com" height="504" width="921" 
                        frameborder="0" scrolling="no">
               </iframe>',
              '<iframe src="http://example.com" height="504" width="921" 
                       frameborder="0" scrolling="no">
               </iframe>',
               '<iframe src="http://example.com height="504" width="921" 
                        frameborder="0" scrolling="no">
               </iframe>')
WHERE id in(5727,5723,5665)

Here is the error code; #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RAND ('

3
Contributors
2
Replies
11
Views
2 Years
Discussion Span
Last Post by diafol
0

The options for the random content that you provided are all the same. If this is right, then there is not randomness and you should use pritaeas' sql. If all your iframes have the same basic structure, perhaps it's easier to just store the src in one column and build the iframe with php on the fly. This is easier than having to update loads of records if you decide that you want the width to change to 674 instead (for example).

It's possible that you'd want to create a function to display the iframe so that you can have customisable dimensions (and other attributes/properties):

function createIframe($src, $h=NULL,$w=NULL)
{
    $parts = array();
    $parts[] = "<iframe src='$src'";
    if($h) $parts[] = "height='$h'";
    if($w) $parts[] = "width='$w'";
    $parts[] = "frameborder='0' scrolling='no'></iframe>";
    return implode(" ", $parts);
}

echo createIframe($row['src'],$height,$width);   

If you're hardcoding dimensions (as in DB values or above), then you could lose responsiveness.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.