Jump to content

Recommended Posts

<?php 
$list_query = mysql_query("SELECT * FROM item_info");

echo "<table width=\"200\" border=\"1\"><tr><th scope=\"col\">ID</th><th scope=\"col\">Name</th> <th scope=\"col\">Author</th><th scope=\"col\">Manage</th>";   
while ($item_list = mysql_fetch_assoc($list_query)){
echo '<tr><th scope=\"col\">$item_list[item_id]</th> <th scope=\"col\">$item_list[item_name]</th><th scope=\"col\">$item_list[item_author]</th><th scope=\"col\"><a href=\"manage_item.php?item=$item_list[item_id]\">Manage</a></th>';
}?>

 

When it outputs i all i see is the $item_list[item_id] and not the actual id...

 

I also tried with {$variable}... but still didnt work

Link to comment
https://forums.phpfreaks.com/topic/63710-solved-php-error-variables/
Share on other sites

Use double quotes and put curly brackets around the variables. That is needed when you are using arrays.

 

Variables will only be parsed when enclosed in double quotes.

 

Edit: You should also use single or double quotes around the array keys. Else you are using constants which is not what you intended.

 

Edit 2: Without curly brackets is called simple syntax and with is called complex syntax (see http://php.net/string)

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.