Hi i have a simple database query that fetch the data from the database i want to mak

Discussion in 'PHP' started by macaela, Jul 11, 2011.

  1. #1
    Hi i have a simple database query that fetch the data from the database i want to make one of the row like first name into a jwplayer link so when click on first name linked plays the video

    this my php code
    
    <?php
    $q=$_GET["q"];
    
    $con = mysql_connect('localhost', 'root', '');
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
    
    mysql_select_db("droptest", $con);
    
    $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>
    </tr>";
    
    
    while($row = mysql_fetch_array($result))
      {
      echo "<tr>";
      echo "<td> " . $row['FirstName'] . "</td>";
      echo "<td>" . $row['LastName'] . "</td>";
      echo "<td>" . $row['Age'] . "</td>";
      echo "<td>" . $row['Hometown'] . "</td>";
      echo "<td>" . $row['Job'] . "</td>";
      echo "</tr>";
      }
    echo "</table>";
    
    mysql_close($con);
    ?>
    PHP:
    this the jwplayer link
    <a href="#" onClick="jwplayer().load('videos/film.mp4')"><a/>
    Code (markup):
    i tried like this
      echo "<td> "<a href="#" onClick="jwplayer().load(' . $row['FirstName'] .')"><a/>"</td>";
    Code (markup):
    but get error
     
    macaela, Jul 11, 2011 IP
  2. AdsMakeSense

    AdsMakeSense Active Member

    Messages:
    389
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    70
    #2
    It would help us if you paste the error that you get.
     
    AdsMakeSense, Jul 11, 2011 IP
  3. macaela

    macaela Active Member

    Messages:
    181
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #3
    Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\xampp\htdocs\4film\4film\droptest\getuser1.php on line 30
    this line
      echo "<td>" <a href='#' onClick='jwplayer().load(' . $row['FirstName'] .')'><a/> "</td>";
    Code (markup):
    this without the link works fine but i want the link
      echo "<td> " . $row['FirstName'] . "</td>";
    Code (markup):
     
    macaela, Jul 11, 2011 IP
  4. AdsMakeSense

    AdsMakeSense Active Member

    Messages:
    389
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    70
    #4
    You, have it all quoted wrong... Try This:

    echo "<td><a href=\"#\" onClick=\"jwplayer().load('" . $row['FirstName'] . "')\"><a/></td>";
    Code (markup):
     
    AdsMakeSense, Jul 11, 2011 IP
  5. macaela

    macaela Active Member

    Messages:
    181
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #5
    it removes the error but unfortunaly doesnt retrieve the row first name just comes blank
    like that it removes the error but it doesnt retrieve the row just shows the row blank
    echo "<td><a href='#' onClick='jwplayer().load('" . $row['FirstName'] ."')'><a/></td>";
    Code (markup):
     
    macaela, Jul 11, 2011 IP
  6. AdsMakeSense

    AdsMakeSense Active Member

    Messages:
    389
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    70
    #6
    Did you use my Code Above? Of course it comes out blank, you put nothing in the a URL: Try this:

    echo "<td><a href=\"#\" onClick=\"jwplayer().load('" . $row['FirstName'] . "')\">" . $row['FirstName'] . "<a/></td>";
    Code (markup):
     
    AdsMakeSense, Jul 11, 2011 IP
  7. macaela

    macaela Active Member

    Messages:
    181
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #7
    the jwplayer is usually called tru the onclick
    like this
    <a href="#" onClick="jwplayer().load({'file': '[B]video1_SD.mp4[/B]', 'hd.file': '[B]video2.mp4[/B]'})">
    Code (markup):
    so i tried video1_SD replaced with . $row['FirstName'] .
    instead to put the file name directly it will come from the database thats why i tried the pick up the first row just to test it

    so how can i replace video1 and video2 with . $row['FirstName'] . and . $row['FirstName'] .

    <a href="#" onClick="jwplayer().load({'file': 'video1_SD.mp4', 'hd.file': '[B]video2.mp4'})">
    Code (markup):
     
    macaela, Jul 11, 2011 IP