hi all ive got a file to display info from database and im trying some way to fetch username from another table for it i have put this at top of file.

<?php
$query          = mysqli_query($conn,"select * from user");
$fetch_user     = mysqli_fetch_array($query);
?>

and here is the section for displaying data

<?php
      $sql = "SELECT * FROM meets";
$result = mysqli_query($conn, $sql);

if (mysqli_num_rows($result) > 0) {
echo "<table><tr><th>ID</th><th>Event Type</th><th>Event Date</th><th>Event Region</th><th>Event Postcode</th><th>Event Title</th><th>Event Description</th><th>Event Seeking</th></tr>";
    // output data of each row
   while($row = mysqli_fetch_assoc($result)) {
   echo "<tr><td>".$row["id"]."</td><td>".$row["event_type"]."</td><td>".$row["event_date"]."</td><td>".$row["event_country"]."</td><td>".$row["event_postcode"]."</td><td>".$row["event_title"]."</td><td>".$row["event_description"]."</td><td>".$row["event_ltm"]. "</td></tr>";
    }
    echo "</table>";
} else {
    echo "0 results";
}

mysqli_close($conn);
?>

and after ammending it by replacing id with the following

echo "<tr><td>".$rowucfirst($fetch_user['user_name']);."</td><td>".$row["event_type"]."</td><td>".$row["event_date"]."</td><td>".$row["event_country"]."</td><td>".$row["event_postcode"]."</td><td>".$row["event_title"]."</td><td>".$row["event_description"]."</td><td>".$row["event_ltm"]. "</td></tr>";

i am getting the following error

PHP Parse error:  syntax error, unexpected '.'

what is the best way around this many thanks in advance jan x

Recommended Answers

All 4 Replies

If you remove the; in $rowucfirst($fetch_user['user_name']);."</td><td>" it should go away.

done that now im getting the following :

PHP Fatal error:  Uncaught Error: Function name must be a string in
Stack trace:
#0 {main}
  thrown in

many thanks hun x

I don't think $rowucfirst is a function, and if it were it shouldn't start with a $. Were you trying to just do echo "<tr><td>".ucfirst($fetch_user['user_name']) perhaps?

perfect thank you much appreciated x

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.