I have no clue on what to put as the title, its to do with mkinga $var ... name?
09-22-2007, 04:00 PM
|
I have no clue on what to put as the title, its to do with mkinga $var ... name?
|
Posts: 6,521
Name: Dan
Location: Swindon
|
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_name, modules); 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 <<
|
|
|
|
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?
|
Posts: 843
Name: Mike
Location: United Kingdom
|
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_name, modules); foreach($modules as $module) { echo '<li>'.$module['module_name'].'</li>'; }
__________________
My Blog/Site: Please login or register to view this content. Registration is FREE
|
|
|
|
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?
|
Posts: 6,521
Name: Dan
Location: Swindon
|
Quote:
Originally Posted by rogem002
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_name, modules); 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 <<
|
|
|
|
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?
|
Posts: 134
|
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
|
|
|
|
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?
|
Posts: 7
Name: Dee Tee
|
$.$arrayval = $row;
The first $ is the issue....
|
|
|
|
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?
|
Posts: 6,521
Name: Dan
Location: Swindon
|
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 <<
|
|
|
|
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?
|
Posts: 843
Name: Mike
Location: United Kingdom
|
Quote:
Originally Posted by Dawg
$.$arrayval = $row;
The first $ is the issue....
|
Quote:
Originally Posted by dansgalaxy
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
|
|
|
|
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?
|
Posts: 6,521
Name: Dan
Location: Swindon
|
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 <<
|
|
|
|
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?
|
Posts: 483
|
... 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.
|
|
|
|
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?
|
Posts: 6,521
Name: Dan
Location: Swindon
|
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 <<
|
|
|
|
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?
|
Posts: 483
|
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.
|
|
|
|
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?
|
Posts: 6,521
Name: Dan
Location: Swindon
|
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 <<
|
|
|
|
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?
|
Posts: 483
|
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.
|
|
|
|
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?
|
Posts: 6,521
Name: Dan
Location: Swindon
|
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 <<
|
|
|
|
|
« 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 |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|