The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Help with widget code
I have this code that is in a php widget to go and gather up to 5 random images.
But it's placing the images in the header instead of the php box. Any ideas on why that's happening? I did notice all this code is "msql" and my db is "mysqli" not sure if that matters? Code:
$con = mysql_connect("*****.**.*******.hostedresource.com","*******","******"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("******", $con); $result = mysql_query("SELECT * FROM vjb_ads ORDER BY RAND() LIMIT 0,5;"); while($row = mysql_fetch_array($result)) { echo "<a href='{$row['url']}'><img src='{$row['image_path']}' /></a><br/>"; } mysql_close($con); |
#2
|
|||
|
|||
You can't echo your html, you have to set $output. In your code I think you just have to change "echo" to "$output .= ", like:
Code:
$output .= "<a href='{$row['url']}'><img src='{$row['image_path']}' /></a><br/>"; |
Благодарность от: | ||
Lynne |
#3
|
|||
|
|||
Quote:
Nevermind!!! That worked!!! Missed the "=" when I copy and pasted... Thanks a bunch!!! --------------- Added [DATE]1345910120[/DATE] at [TIME]1345910120[/TIME] --------------- Quote:
Code:
<a href='{$row['url']}'" target="_blank"> What did I do wrong? |
#4
|
|||
|
|||
You used double quotes in your html. Since you're putting the code in a double quoted string, you either have to escape all double quotes that occur as part ofthe html (by putting a backslash in front on each one) or else use only single quotes (probably the easier option).
|
#5
|
|||
|
|||
Quote:
|
#6
|
|||
|
|||
Is there something in that code that might stop an animated gif in Google Chrome?
It works fine in IE and FF |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|