hi i have the above function but what i am trying to do is replace the above the name of the file with the one that will be queried from the database but i keep getting sintax error. want to to put where it says filr name example (file1.mp4) with the ( <?php echo $filename?>) but i keep getting sintax error echo "<td><a href='#' onClick=\"jwplayer().load({'file': 'file1.mp4', 'hd.file': 'file2.mp4'})\"> </td>"; PHP: so it would look like this echo "<td><a href='#' onClick=\"jwplayer().load({'file': '<?php echo $filename1?>', 'hd.file': '<?php echo $filename2?>'})\"> </td>"; PHP: but gives me error
You are already inside a php tag, and inside an echo statement too, so you cannot open another php tag anymore. You should: echo "<td><a href='#' onClick=\"jwplayer().load({'file': '$filename1', 'hd.file': '$filename2'})\"> </td>"; PHP: Or, echo "<td><a href='#' onClick=\"jwplayer().load({'file': '".$filename1."', 'hd.file': '".$filename2."'})\"> </td>"; PHP: Read more about php basic concatenation and using variables inside a string.
ok the way you mention got rid of the error but i am a lil confused because the link doesnt work but i think that would be another problem just wanted to doubel check this line as it is will fetch all the first name in the database and display as many time as it is on the database as if i had the line like this?? echo "<td>" . $row['FirstName'] . "</td>"; PHP: or like this i will need something extra like a GET_[FirstName] on top of my while fetch loop echo "<td><a href=\"#\" onClick=\"jwplayer().load({'file': '".$FirstName."', 'hd.file': '".$FirstName."'})\"> " . $row['FirstName'] ."</td>"; this how the whole code looks now that should do a normal database query or i am missing something in order for those new line that you gave me to work <html> <head> </head> <body> <?php $q=$_GET["q"]; $con = mysql_connect('localhost', 'root', ''); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("droptest", $con); $FirstName=$_GET['FirstName']; $sql="SELECT * FROM user WHERE id = '".$q."'"; $result = mysql_query($sql); echo "<table border='1'> <tr> <th>Firstname</th> <th>Lastname</th> <th>Age</th> <th>Hometown</th> <th>Job</th> <th>secondvideo</th> </tr>"; //jwplayer().load('file':hofbell30732_SD.mp4','hd.file':'hofbell30732_SD.mp4') //<a href="#" onClick="jwplayer().load({'file': 'hofbell30732_SD.mp4', 'hd.file': 'videos/film.mp4'})"> </a> //onClick="jwplayer().load({\'file\': \'hofbell30732_SD.mp4\', \'hd.file\': \'videos/film.mp4\'})"> // echo $row['FirstName'] . " " . $row['LastName']; while($row = mysql_fetch_array($result)) { echo "<tr>"; //echo "<td><a href=\"#\" onClick=\"jwplayer().load('" . $row['FirstName'] . "')\">" . $row['FirstName'] . "<a/></td>"; echo "<td>" . $row['LastName'] . ''. $row['Job'] . "</td>"; echo "<td>" . $row['Age'] . "</td>"; echo "<td>" . $row['Hometown'] . ''. $row['Job'] . "</td>"; echo "<td>" . $row['Job'] . "</td>"; echo "<td><a href=\"#\" onClick=\"jwplayer().load({'file': '".$FirstName."', 'hd.file': '".$FirstName."'})\"> " . $row['FirstName'] ."</td>"; echo "<td>" . $row['arr'] . "</td>"; echo "<td>" . $arr . "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> </body> </html> PHP: