ben1981 Posted March 29, 2007 Share Posted March 29, 2007 see my code below well the $picture variable contains just for example birthday1.jpg which exists and works if i use the birthday1.jpg string instead of the variable can i make this work so it displays a different picture for each result / row of the query? $cxn = mysqli_connect($host,$user,$password,$dbname); $sql = "SELECT * FROM products WHERE category='birthday'"; $result = mysqli_query($cxn,$sql); while ($row = mysqli_fetch_row($result)) { $picture='$row[2]'; echo "<div class='text'><img src='$picture'>" .$row[3]." ".$row[4]." ".$row[5]. "</div>"; } echo "</div>"; ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted March 29, 2007 Share Posted March 29, 2007 uhhh... yes? Quote Link to comment Share on other sites More sharing options...
ben1981 Posted March 29, 2007 Author Share Posted March 29, 2007 well could you please tell me how the code should be written as what i have above wont work it makes the whole page go blank! where if i write in picture1.jpg it all works fine Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted March 29, 2007 Share Posted March 29, 2007 change $picture='$row[2]'; to $picture = $row[2]; Quote Link to comment Share on other sites More sharing options...
ben1981 Posted March 29, 2007 Author Share Posted March 29, 2007 still not showing up! Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted March 29, 2007 Share Posted March 29, 2007 view source and see if the picture is there if not try using mysqli_fetch_assoc() instead of mysqli_fetch_row, and use the column name the picture is stored in in your database. Quote Link to comment Share on other sites More sharing options...
ben1981 Posted March 29, 2007 Author Share Posted March 29, 2007 ok got it working thanks for yourhelp- Quote Link to comment Share on other sites More sharing options...
ben1981 Posted March 29, 2007 Author Share Posted March 29, 2007 one more question - how do i pick images from a subfolder on the server? what format do i need to use, if the images are in /images subfolder? tried various things but cant get it working Quote Link to comment Share on other sites More sharing options...
AndyB Posted March 29, 2007 Share Posted March 29, 2007 just like a standard html link to an image in a different folder. If the images are in a direct subfolder to where the script resides .... echo "img src='images/". $picturename. "'>"; Quote Link to comment Share on other sites More sharing options...
ben1981 Posted March 29, 2007 Author Share Posted March 29, 2007 thanks can you show me the code format for adding a width and height tag for every pictiure? i want each picture to be the same size.. say 100 x 100 pixels? again ive tried messing with the code but the pics are appearing big! thanks for your help Quote Link to comment Share on other sites More sharing options...
Lytheum Posted March 29, 2007 Share Posted March 29, 2007 Just use: <img src='$picture' height='100' width='100'> Quote Link to comment Share on other sites More sharing options...
ben1981 Posted March 29, 2007 Author Share Posted March 29, 2007 ive got the following working... how can i add the width and height to it? tried messin but page keeps comin up blank - im not getting on too well with this coding business!! $cxn = mysqli_connect($host,$user,$password,$dbname); $sql = "SELECT * FROM products WHERE category='baby'"; $result = mysqli_query($cxn,$sql); while ($row = mysqli_fetch_row($result)) { echo "<p><img src='images/" .$row[3]. "'>" .$row[3]." ".$row[2]." ".$row[4]." ".$row[5]. "</p>"; } ?> Quote Link to comment Share on other sites More sharing options...
ben1981 Posted March 29, 2007 Author Share Posted March 29, 2007 ahhh got it working i think my ftp site is having problems Quote Link to comment Share on other sites More sharing options...
ben1981 Posted March 29, 2007 Author Share Posted March 29, 2007 Ahh i have another question sorry guys.... this one has been causing me problems in the past as well... when you insert an image and set align to right or left - and there isnt much text beside it - then the next picture is put next to it instead of below it is there a way of making sure the next picture will be underneath instead of alongside and slightly down from the last one? Quote Link to comment Share on other sites More sharing options...
AndyB Posted March 29, 2007 Share Posted March 29, 2007 Basic html ... <br clear="all"> Quote Link to comment Share on other sites More sharing options...
ben1981 Posted March 29, 2007 Author Share Posted March 29, 2007 superb , never used that command, self taught myself in xhtml css and now learning php mysql.. sorry for my basic questions but thanks all for answering really helpful Quote Link to comment Share on other sites More sharing options...
ben1981 Posted March 29, 2007 Author Share Posted March 29, 2007 I remember reading there was some code you could use to make sure that your logo jpg file loads before anything else? because at the moment the page loads in a funny order and the logo is usually last. does anyone know which command i mean? its nice to have the logo looking more permanent... Quote Link to comment Share on other sites More sharing options...
ben1981 Posted March 30, 2007 Author Share Posted March 30, 2007 oh also help much appreciated, is there a way to call another htm file from an exisiting one? i ask because I have a menu of links on the side of the page, and i have to write the details of these on every other page on the web site. so if i make one change to the menu, i have to edit about 10 pages. is there a way to call these details from another file so i only edit one file? for example like storing some variables in a seperate file and calling using INCLUDE? 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.