Chezshire Posted July 17, 2008 Share Posted July 17, 2008 Hello Everyone - your friendly newb here As usual I'm trying to do things that are a touch beyond my grasp and so i'm reaching out to the experts. With a some guidance I've put together the following piece of code that is doing something I've wanted to about two weeks: It's displaying the character name and the name of actor associated with the character. It's also supplying image, but (and there is always a but isn't there?) the image is displaying as a broken link. I'm not sure if it's because i'm not explaining/executing the link correctly, or if my attempt to modify the code is screwing it up or what. But can some one please take a look and provide a touch of guidance - or a lot (i'm not choosey Also the second thing is that it's only displaying the first and i'd like to display all the characters in the database. So to clarify, I'm asking: A. How can i get the image to display of the character/model named (I have an empty box right now) B. How can i display all the characters, ideally alphabetically. This is the code I'm working with: <?php //connect to the database $sql = "SELECT id, modelname, codename FROM cerebra WHERE approved=''"; $result = mysql_query($sql) or trigger_error(mysql_error(),E_USER_ERROR); //execute the query. If it fails, throw an error message $row = mysql_fetch_assoc($result);//put the result set in an array. echo '<p>Character: '.$row['codename']; echo ' = '; echo 'Model: '.$row['modelname']; echo '<br /><img src="/cerebra/images/<?php echo $id; ?>-.jpg" width="60" height="75" border="0"'.$row['image'].'" /</p>'; ?> And I would also like to give a shout of thanks out to Ben and to Singla who are both totally awesome people! Chez Link to comment https://forums.phpfreaks.com/topic/115161-two-image-display-questions/ Share on other sites More sharing options...
l0ve2hat3 Posted July 17, 2008 Share Posted July 17, 2008 echo <br /><img src="/cerebra/images/<?php echo $id; ?>-.jpg" width="60" height="75" border="0"'.$row['image'].'" /</p>'; you cannot echo inside of an echo use this for starters echo '<br /><img src="/cerebra/images/'.$id.'-.jpg" width="60" height="75" border="0"'.$row['image'].'" /</p>'; you also might want to double check the - before the .jpg to make sure thats not a typo Link to comment https://forums.phpfreaks.com/topic/115161-two-image-display-questions/#findComment-592193 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.