Jump to content

Recommended Posts

Hello, I'm working onthe below peice of code basically when i call a table from the database I dont want to have to write all the code each time hence the function, The only part I'm having trouble with is specifying the column heading without hard codeing it see below.

 

mysql_fetch_assoc

 

function return_table_item($item, $table)
{
$table_item="SELECT $item FROM $table";
$table_item_results =mysql_query($table_item);
 
while ($item_return=mysql_fetch_assoc($table_item_results)){
echo '<a href=' . $item_return['$item'] . '.php target="menu_results"><li>' . sanitize_text_from_tables($item_return['$item']]) . '</li></a>';
}
 
how can I request the $item column using the function variable $item.
 
Any help appreciated.
echo '<a href=' . $item_return[$item] . '.php target="menu_results"><li>' . sanitize_text_from_tables($item_return[$item]]) . '</li></a>';

 

PHP Parse error:  syntax error, unexpected ']' in /home/quotegen/public_html/QuoteGenV4/library/class_lib.php on line 19

 

Any ideas?

No problem, glad to help.  :happy-04:

 

Side note:

Perhaps you are already aware of this, but the mysql_ functions have been depreciated. More information about the alternatives can be found here:

http://www.php.net/manual/en/mysqlinfo.api.choosing.php

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.