AlexisK Posted August 5, 2010 Share Posted August 5, 2010 Hello there . I have a little problemI want to make a movie database.In mysql i create a table create table movies (id int, name varchar(100), cover varchar(100), primary key(id));Next i use insert into movies ................ to insert data in table . In cover field i insert the path of cover . ( covers\cover1.jpg)The php code to see the contents of movies table<?php$con = mysql_connect("localhost","root","12345");if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("db_movies", $con);$result = mysql_query("SELECT * FROM movies"); while($row = mysql_fetch_array($result)) { echo $row['id'] . " " . $row['name'] . " " . $row['cover']; echo "<br />"; }mysql_close($con);?>The result is "1 movie name cover\cover1.jpgHow can i take id movie name and the picture ??????? Link to comment Share on other sites More sharing options...
thescientist Posted August 5, 2010 Share Posted August 5, 2010 How can i take id movie name and the picture ???????what do you mean? Link to comment Share on other sites More sharing options...
AlexisK Posted August 5, 2010 Author Share Posted August 5, 2010 Sorry for my Englishnow with my code i see1 Pulp Fiction covers\Pulp_Fiction.jpg2 Scence Of A Woman covers\Scence_Of_A_Woman.jpg.....I want to see 1 Pulp Fiction 2 Scence Of A Woman ...... etc Link to comment Share on other sites More sharing options...
thescientist Posted August 5, 2010 Share Posted August 5, 2010 you'll have to use PHP to output HTML during while loop. here's an example of how to create a table (towards the bottom of the page). http://www.w3schools.com/php/php_mysql_select.aspOf course you'll have to adapt it to your own needs, but it should give you a framework nonetheless. Link to comment Share on other sites More sharing options...
End User Posted August 5, 2010 Share Posted August 5, 2010 Unless I misunderstand the question, all you need to do is wrap the path data in an image tag as you loop through the rows:while($row = mysql_fetch_array($result)){ print "$row['name']<br /> <img src=\"$row['cover']\"><br />";} Link to comment Share on other sites More sharing options...
AlexisK Posted August 5, 2010 Author Share Posted August 5, 2010 You understand corectly but i take a wrong messageParse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in D:\XAMPP\xampp\htdocs\movies.php on line 17line 17 is the print "$row['name']<br /> <img src=\"$row['cover']\"><br />"; Link to comment Share on other sites More sharing options...
thescientist Posted August 5, 2010 Share Posted August 5, 2010 shouldn't it be something like: print $row['name'] . "<br/> <img src=\"" . $row['cover'] . "\"></br>"; Link to comment Share on other sites More sharing options...
AlexisK Posted August 5, 2010 Author Share Posted August 5, 2010 It work !!!!Thanks you very very very very mutch Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.