Jump to content

Recommended Posts

i no that the script works fine but when u use ' ' to echo something it echos it as it is but how do i make it to echo the table where it also shows the varables i need it to echo the table with the varables

 

<?php require('config.php');

if(isset($_GET[profile])){
$username = $_GET[profile];
$q = "SELECT wins, lose, clan, username FROM test WHERE username = '$username'";
$r = mysqli_query($dbc, $q);
$profiletest = mysqli_fetch_array($r, MYSQLI_ASSOC);

$q = "SELECT * FROM profile WHERE username = '$username'";
$r = mysqli_query($dbc, $q);
$profile = mysqli_fetch_array($r, MYSQLI_ASSOC);
echo '<table width="200" border="0" align="center">
  <tr>
    <td width="82"><div align="right">Username:</div></td>
    <td width="108"><?php echo $profile[username]; ?></td>
  </tr>
  <tr>
    <td><div align="right">Nickname:</div></td>
    <td><?php echo $profile[nickname]; ?></td>
  </tr>
  <tr>
    <td><div align="right">Clan:</div></td>
    <td><?php echo $profile[clan]; ?></td>
  </tr>
  <tr>
    <td><div align="right">Wins:</div></td>
    <td><?php echo $profile[wins]; ?></td>
  </tr>
  <tr>
    <td><div align="right">Lose:</div></td>
    <td><?php echo $profile[lose]; ?></td>
  </tr>
</table>';
}

?>

Link to comment
https://forums.phpfreaks.com/topic/171345-solved-need-help/
Share on other sites

echo "</pre>
<table width="'200'" border="'0'" align="'center'">
  
    Username:
    {$profile['username']}
  
  
    Nickname:
    {$profile['nickname']}
  
  
    Clan:
    {$profile['clan']}
  
  
    Wins:
    {$profile['wins']}
  
  
    Lose:
    {$profile['lose']}
  
</ta

 

Use double quotes for your string, so your variables interpolate.

Use single quotes for your attributes.

You can utilize curly braces around associative arrays to escape them.

You're aready in <?php tags, you can't use them again (near your variables).

You also don't need to echo again since all you're really doing is giving echo a long string.

 

Try this and see if it works, good luck.

 

*EDIT: Fixed some associative array syntax.

Link to comment
https://forums.phpfreaks.com/topic/171345-solved-need-help/#findComment-903619
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.