wesley Posted November 19, 2015 Share Posted November 19, 2015 Hello, I have written a php script but I see nothing in the browser. I want to show words and images form a mysql database. But there is something wrong with the image img tag. Can someone help me? thanks in advance the code is: echo "<ul>"; while ($record = mysqli_fetch_assoc($result)) { $id = $record['id']; $brand = $record['brand']; $description = $record['description']; $images = $record['images']; $title = $record['title']; echo "<li> $id $brand $description </li>"; echo "<img src="car/.$images." height="100" title="$title" alt="car" />";//this is going wrong } echo "</ul>"; Link to comment Share on other sites More sharing options...
dsonesuk Posted November 19, 2015 Share Posted November 19, 2015 You are not separating what is html/text from what is php, You are mixing php double quotes, with html attribute double quotes, it is going in and out of php with every second double quote, you will have to use single quotes for the php code, or escape with '\' placed before html/text double quotes. You should not place img outside a <li> ...</li> element anyway. Link to comment Share on other sites More sharing options...
john_jack Posted December 16, 2015 Share Posted December 16, 2015 you should change : this "echo "<img src="car/.$images." height="100" title="$title" alt="car" />";//this is going wrong" to echo "<img src='car/".$images." ' height='100' title=' ".$title." ' alt='car' />"; Good luck Link to comment Share on other sites More sharing options...
dsonesuk Posted December 16, 2015 Share Posted December 16, 2015 If anything it should be echo '<img src="car/'.$images.'" height="100" title="'.$title.'" alt="car" />'; Link to comment Share on other sites More sharing options...
sandeepm Posted December 29, 2015 Share Posted December 29, 2015 If you have full of confusions let do one thing echo "<ul>";while ($record = mysqli_fetch_assoc($result)) {$id = $record['id'];$brand = $record['brand'];$description = $record['description'];$images = $record['images'];$title = $record['title'];echo "<li> $id $brand $description </li>"; ?><img src="car/<?php echo $images ?>" height="100" title="<?php echo $title ?>" alt="car" /> // write like this and check once <?php}echo "</ul>"; Link to comment Share on other sites More sharing options...
dsonesuk Posted December 29, 2015 Share Posted December 29, 2015 Which does exactly the same as previuos posts but in less cleaner manner. Link to comment Share on other sites More sharing options...
john_jack Posted December 29, 2015 Share Posted December 29, 2015 if the image is still not showing up but other info like the adress and such is showing , maybe the problem is in the image path in your database . -check if the car directory exists -make sure that the images you are trying to display are in car directory -check the images paths in your database . PS open the developer tools on your browser and check the path in the <img> tag Link to comment Share on other sites More sharing options...
dsonesuk Posted December 29, 2015 Share Posted December 29, 2015 OH yeah! forget to mention as pointed out before in post #2 YOU CANNOT HAVE A IMAGE ELEMENT OUTSIDE A LI ELEMENT WHEN USING A UL ELEMENT. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now