I am pretty new to Javascript and could do with a hand with a little problem I've got.
I have a PHP script which loads varying amount of images from a database - all 150px wide - and displaying them in a horizontal row. I need to be able to adjust the width of this row to enable scrolling if the items are more than the standard width, or to remove the scrollbar if it is not.
In my PHP I query the database and if the result set returned is greater than 0 I attempt the following in javascript
$width = mysql_num_rows($get) * 150;
'<script type="text/javascript">
document.getElementById('container').setAttribute('style', 'width: '.$width.'');
</script>'
container is the holding div ID which is populated by the result set. However I seem unable to dynamically update the width depending on the results of the query.
My HTML is pretty simple
<div id="container">
#Call PHP Function
</div>
Thanks