Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
I have no clue on what to put as the title, its to do with mkinga $var ... name?
Old 09-22-2007, 04:00 PM I have no clue on what to put as the title, its to do with mkinga $var ... name?
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
Hi, ok, this is a bit confusing.

im TRYING to make a function which basically will generate the array you get from a mysql_fetch_array

ok heres the function.
PHP Code:
function db_row_modules($field$arrayanme)
{
$res mysql_query("SELECT $field FROM modules");
$row mysql_fetch_array($res);
$.
$arrayval $row;
return 
$row;

and im trying to use it like so.
PHP Code:
db_row_modules(module_namemodules);
foreach(
$modules as $module)
{
echo 
'<li>'.$modules['module_name'].'</li>';

obvious it dont work

and i get the error of unexpected $.

So how do i cange the name of a VAR?

help
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
 
Register now for full access!
Old 09-22-2007, 08:14 PM Re: I have no clue on what to put as the title, its to do with mkinga $var ... name?
rogem002's Avatar
PHP Chap

Posts: 843
Name: Mike
Location: United Kingdom
Trades: 0
I hate to be rude, but if you have no clue...why are you building a CMS?

Put a counter in, like

PHP Code:
<?php
$count 
"0";
// whats coming out..most likely in a while
{
foreach(
$arrays as $key => $value){
$return[$count][$key] = $value;
$count $count 1;
}
}
?>
I think what you need to put is (looking at your code):
PHP Code:
db_row_modules(module_namemodules);
foreach(
$modules as $module)
{
echo 
'<li>'.$module['module_name'].'</li>';

__________________
My Blog/Site:
Please login or register to view this content. Registration is FREE
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Old 09-22-2007, 08:53 PM Re: I have no clue on what to put as the title, its to do with mkinga $var ... name?
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
Quote:
Originally Posted by rogem002 View Post
I hate to be rude, but if you have no clue...why are you building a CMS?

Put a counter in, like

PHP Code:
<?php
$count 
"0";
// whats coming out..most likely in a while
{
foreach(
$arrays as $key => $value){
$return[$count][$key] = $value;
$count $count 1;
}
}
?>
I think what you need to put is (looking at your code):
PHP Code:
db_row_modules(module_namemodules);
foreach(
$modules as $module)
{
echo 
'<li>'.$module['module_name'].'</li>';

ookay i hate to be rude but i dotn think you get what i am asking.
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 09-23-2007, 08:51 AM Re: I have no clue on what to put as the title, its to do with mkinga $var ... name?
Super Talker

Posts: 134
Trades: 0
is it not like this :

PHP Code:
db_row_modules($module_name$modules);
foreach(
$modules as $module)
{
echo 
'<li>'.$module['module_name'].'</li>';

__________________

Please login or register to view this content. Registration is FREE

Check out the Facebook Clone build with Jcow SNS at
Please login or register to view this content. Registration is FREE
, it is free and it always will be
Falcone is offline
Reply With Quote
View Public Profile
 
Old 09-23-2007, 09:29 AM Re: I have no clue on what to put as the title, its to do with mkinga $var ... name?
Novice Talker

Posts: 7
Name: Dee Tee
Trades: 0
$.$arrayval = $row;

The first $ is the issue....
Dawg is offline
Reply With Quote
View Public Profile
 
Old 09-23-2007, 10:11 AM Re: I have no clue on what to put as the title, its to do with mkinga $var ... name?
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
i know that was the issue, it was just kind of how i wanted it to work,
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 09-23-2007, 12:40 PM Re: I have no clue on what to put as the title, its to do with mkinga $var ... name?
rogem002's Avatar
PHP Chap

Posts: 843
Name: Mike
Location: United Kingdom
Trades: 0
Quote:
Originally Posted by Dawg View Post
$.$arrayval = $row;

The first $ is the issue....
Quote:
Originally Posted by dansgalaxy View Post
i know that was the issue, it was just kind of how i wanted it to work,
Ah, that is what you meant.
__________________
My Blog/Site:
Please login or register to view this content. Registration is FREE
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Old 09-23-2007, 12:49 PM Re: I have no clue on what to put as the title, its to do with mkinga $var ... name?
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
Ok if that logic of $.$arrayval = $row; actually worked it would do what i want but how do i do it so it does work??
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 09-23-2007, 01:44 PM Re: I have no clue on what to put as the title, its to do with mkinga $var ... name?
Ultra Talker

Posts: 483
Trades: 0
... and yet you never really tell us what it is that you want it to do. You basically say "this is how I think it should work..." and leave it at that.

You say "if that logic of $.$arrayval = $row; actually worked it would do what i want". How about you explain to us in English what you are attempting to make that row do?

Are you trying to append the $row value to the end of the array named $arrayval? Are you trying to append the $row value to the end of the array that has the same variable name as the string stored in $arrayval?

Explain to us more effectively what you want and then we can help.
__________________

Please login or register to view this content. Registration is FREE
TwistMyArm is offline
Reply With Quote
View Public Profile
 
Old 09-23-2007, 02:08 PM Re: I have no clue on what to put as the title, its to do with mkinga $var ... name?
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
well i want what is enterd into the second param of it to be the name of the row array

theres probably a really simple solutions but im a bit cluless...
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 09-23-2007, 09:01 PM Re: I have no clue on what to put as the title, its to do with mkinga $var ... name?
Ultra Talker

Posts: 483
Trades: 0
Then you are probably looking for:
PHP Code:
function db_row_modules($field$arrayname)
{
    global $
$arrayname;

    
$res mysql_query("SELECT $field FROM modules");
    
$row mysql_fetch_array($res);
    $
$arrayname$row;
    return 
$row;

Note that I fixed the spelling of the second parameter and also made that new parameter global so that it is still accessible once you're finished.

What I don't understand is why you're assigning the value to this dynamic variable and then returning it as well... I don't really see the point there.
__________________

Please login or register to view this content. Registration is FREE
TwistMyArm is offline
Reply With Quote
View Public Profile
 
Old 09-24-2007, 09:12 AM Re: I have no clue on what to put as the title, its to do with mkinga $var ... name?
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
well basically i want $row to be $arraynaem like that and then return it so i can use $random['field']
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 09-24-2007, 09:28 AM Re: I have no clue on what to put as the title, its to do with mkinga $var ... name?
Ultra Talker

Posts: 483
Trades: 0
Dan. I'm sure you think you're making perfect sense but I don't understand what you're trying to say.

Instead of trying to say it in one line, take 5 minutes and write a few paragraphs if need be. Use things like "the value of the variable named $x" and "the variable that has the name y". Tell us what you are wanting to pass in, what you are wanting to pass out and what other things you are trying to affect at the same time.

Sorry mate, but I just don't understand.
__________________

Please login or register to view this content. Registration is FREE
TwistMyArm is offline
Reply With Quote
View Public Profile
 
Old 09-24-2007, 09:44 AM Re: I have no clue on what to put as the title, its to do with mkinga $var ... name?
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
I know no one seems to get what i mean i dont even thing it would work
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Reply     « Reply to I have no clue on what to put as the title, its to do with mkinga $var ... name?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 2.90641 seconds with 12 queries