Jul 6, 2008

Calling A False Variable... - like $count . $val

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > PHP Programming

free web hosting

Calling A False Variable... - like $count . $val

moldboy
Okay I'm very new to PHP still, although you may recognize me from the threa before, just go finished finals so now back to PHP!

On one page I accept an input which will tell the next page how many form lines to generate, that part I have worked out, or so I think. Because the number of forum fields could vary I need to have a number of forum variables, so I used this code:
CODE
echo   "<td><input name=\"wname" . $appendval . "\" type=\"text\" id=\"wname" . $appendval . "\" value=\"Catagorie Name\"></td>";

where $appendval is a variable what goes up one at a time, so at the end of this block of code it would say $appendval++
This appears to work quite well, however when it comes to he next page and I want to call that variable which would be the result of wname and the number that happened to be assigned to appendval at the time I run into troubles, is there anyway I can call a variable that is the result of two variables combined?
I'm quite certian it can be done, I just havn't a clue how.

 

 

 


Reply

HmmZ
Let me try to get this straight,

you are trying to have an input field where the input (assuming a category name) will have effect on the next page.

where, on the next page, it displays the amount of form lines based on what categorie name it is?

or is it more like (simplified) it should ADD a next line when a new category is inputted (sounds more likely..)

Assuming it is option 2 (i figured it out while writing this posts, just too tired to delete the former lines..) you are making it harder then i think it should be

I created a news script and projects script yesterday and this is the method i used..

make_new.php
CODE

echo "<td><input name=\"wname\" type=\"text\" id=\"cname\" value=\"Category Name\"></td>";


insert_new.php
CODE

$id=$_POST['cname'];
$name=$_POST['wname'];
$qry="INSERT INTO your_table (id,name) VALUES('$id','$name')";
$result=mysql_query($qry) or die("error..");


display_all.php
CODE

$qry="SELECT name,id from your_table";
$result=mysql_query($qry);
if(mysql_num_rows($result)==0){
//print something if there are no entries..
}
while($cats=mysql_fetch_array($result, MYSQL_ASSOC)){
print "<tr><td>$cats[name]</td><td>$cats[id]</td></tr>";
}


I am of course not sure if this works the same with forum categories, but the concept is the same, it gets the array of all name/id inputs of your category table and prints a row(<TR><TD></TD></TR>) for every entry

I am tired but if you understood it, while(){} is a loop that fetches all data and prints something for every entry (you could even display $cats[name] and then a <br>, making it go to the next line..)

Hope this helps just a tiny bit sad.gif

 

 

 


Reply

moldboy
I'm no where near SQL accessing, no what I'm wanting is to make three pages, one html that asks for two numbers.

Then on the next page a php script, which I have alreay created that will build a HTML table inside a form, that will accept input from the user, based on the info from the previous page. So for example if I put 4 as the value on the previous page there would be 4 text entrie fields on the next page, now because the text areas in a single form must have diffrent names I have assigned a starter name, which in my above code is called wname, and then to make each field diffrent I would then add, using the " . " the value of $appendval a number that goes up every time the while, loops.

Now my problem comes in when I want to display the variable on the next page, which in my case happens to be in a dropdown box, but that's not important. If I call $wname there is nothing assigned to it because on the previous page it would be $wname1, $wname2, $wname3 ect. How do I call these variables bearing in mind that I have no predetermined way of know how many variables there are.

I would assume it would look something like this:
CODE
echo "And your're number is," ${wname . $appendval}"


That probably looks nothing like any PHP you've seen (which would be why it doesn't work!), but the important thing is that before the variable is called I need to define it as wname plus a number, hence the { }.

Any thoughts?

Reply

HmmZ
if i got that right

<input name=\"wname\" id=\"cname\">
$wname=intval($_POST['wname'];
while(($wname=$wname++) && ($cname=$cname++)){
echo "You\'re number $wname";}

Not sure if it works tho..

Reply

moldboy
If I understand PHP at all I think that
CODE
while($wname = $wname++)
will never work as 3 can never equal 3+1!

That isn't however what I wanted, I really apprecieate you're trying to help, um how cvan I put this?

...

Okay you know how when you call a variable you simply use it in code for example
CODE
echo "You're name is" $name
should (I stree Should) simply write You're name is and then whatever the value assigned to $name was. That easy enough. And we also know that to accept input from a form we use a variable name which in this case would be "name".

But what if to get the variable name on the previous page I had to assign it by merging two vars together something like :
CODE
$part1 = "na";
$part2 = "me";
//something about input, I don't know the HTML input code but the var would be:
name="$var1 . $var2";


This ofcorse is a very silly example, but when precessed it would read:
CODE
name="name"

so my question is after pressing submit whatever information was in the form called "name" would be stored in the variable $name, Correct. So on the next page how do I retreve the information from $name without knowing it is called $name because it was derived from $var1 . $var2 (na . me) Again it wouldn't be hard if I knew what the two vars were at any given time, but what if $var2 were a random number that was passed on to the next page then the form information could be stored in $na194939, or $na295654, or $na111222, and so on. As I'm reading I think it could be done with the
CODE
=intval($_POST['wname'];
But I don't know how.

Notice from BuffaloHELP:
Edited per request.

Reply

moldboy
I just though I'd let everyone know that I solved the problem, Thankyou HmmZ for your help, I don't know if you really ever understood my question but here's the code I've ended up using:
CODE
   while ( $weighthist <= $weightnum ){
$dropval = ${wname . $weighthist};
$perval = ${wper . $weighthist};
echo '<option value="' . $perval . '"> ' . $dropval . '</option>';
$weighthist++;      
}

Reply

HmmZ
Heh, guess I didn't understand your question sad.gif

ahwell, i'm still in the long but adventureous exploring stage of PHP

Glad you solved your problem though smile.gif

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Recent Queries:-
  1. php parse error as3 - 723.27 hr back.
Similar Topics

Keywords : calling, false, variable, count, val

  1. Unexpected T_variable...
    Help! (3)
  2. Boredom
    Boredom is such a false feeling that people should deal with (4)
    “I’m bored…” How many times in a day do you say that, or hear it said? Too many. My parents used to
    always criticize me for saying I was bored. “there’s no excuse for being bored,” they would say,
    “you can find something to do.” “whatever,” I would say and just walk away. “there’s nothing to do…”
    this is also a phrase we hear too often. What is true about that? There is so much to do! I
    think we really mean we’re too lazy to actually do anything. There really is so much to do, I’m not
    even going to name anything because that list could go on and on. And even if you d....
  3. Debit Cards
    True/False? (10)
    Is it possible to get some kind of a debit card that is likely to be virtual one issued by some
    internet company or by the real one? I don't know actually it is true or false. What I know this
    debit card can be loaded by internet cash payment processors such as paypal, e-gold, e-Bullion and
    others. If you obtain this card, you can withdrawal money from any ATM machine around the world due
    to the fact that it's accepted by VISA/MasterCard stuff. The one web-site I found for it is
    www.epayarea.com. So, what do you think about it?....
  4. Image Calling Problem Solved
    I was having issues trying to call an image from a folder. (1)
    Alright so this is for example You'd have a site and the structure is like this.
    http://www.url.com/ a folder of images /images/ and some pages in this parent directory. However,
    I have another folder so it's http://www.url.com/other/ and this index page needs to call
    things from http://www.url.com/images/ and it can't. It won't load. I've had the
    call be to CODE <img src="images/" or <img src="../images/" and
    <img src="http://www.url.com/images/" It doesn't work. I can't....
  5. Calling All Bf2142 Clans!
    (0)
    There are very few EU leagues left in the world of BF2142, so calling to all dedicated BF2142,
    sign-up now! Sign-up to a league, ladder, a cup, anything! The activity in competitve
    sports for BF2142 is dropping. Here are 3 of the ladders which are active for BF2142:
    http://www.esl.eu/eu/bf2142/ http://www.enemydown.co.uk/game.php?game=2142
    http://clanbase.ggl.com/rating.php?lid=2856 Sign-up your team, today. It's worth it. Lots of
    fun to be made!....
  6. Script Help Required: Undefined Variable
    A fault I cannot spot in PHP (3)
    Hi, when running a PHP script I keep getting the error: QUOTE Notice: Undefined variable: bret
    in c:\program files\easyphp1-8\home\poll.php on line 294 Notice: Undefined
    variable: bret in c:\program files\easyphp1-8\home\poll.php on line 294 (And,
    yes, I get it twice). The code related to the variable is as follows: CODE function
    LogString($string,$type)     {         $t_log = "\n";
            $t_log .=
    $this->globaldata->server_vars['REMOTE_ADDR']."....
  7. Calling All Css Experts (i Need Some Help)
    (5)
    Ok, whenever I try to code a web site using tags I run into one problem... the only run
    vertically... laying on top of one another...... I know there is a way to get div tags to run
    side-by-side... but how? (Diagram of what I mean) When I attempt: CODE
    ************************* Banner ************************* ************************* Content Area
    ************************* Content Different Content Area ************************* What I want
    to happen: CODE ************************* Banner ************************* Content Area     *  
    Content Area      ....
  8. Count Number Of Div's By A Class Name
    (3)
    I have a situation where I need to be able to count the number of div elements in a page and then
    use that number for a loop. I've already tried this but it returns all child div elements.
    ocument.getElementById("char_list").getElementsByTagName("div").length; I need only the child nodes
    directly below the parent div 'char_list'. THe structure is like this The
    problem here is I also have nested div's inside the 'char_node' divs so the first code
    returns them all. I'm trying to just gather the char_node class divs and use i....
  9. True Or False Mail From Computinghost ? [resolved]
    about billing system (8)
    Hello, I have just received a mail from ComputingHost. This mail tells the billing system is
    changing and I have to click to approve. I know these kinds of mails are often used for phishing,
    but no code number is asked. Not the less explanation about the change nor why I had to approve the
    transfer. Have you received the same mail ? does it actually comes from ComputingHost ? I hope you
    can understand my english, my latest lessons were on the sixties. /rolleyes.gif"
    style="vertical-align:middle" emoid=":rolleyes:" border="0" alt="rolleyes.gif" />....
  10. Php Variable Basics
    Where would PHP programmers be without the variable? Learn all about t (9)
    CODE <?php $var= "This is a variable"; echo $var; ?> Outcome This is
    a variable Using what we know about the echo function, we can see that we have created a
    variable, and then used the echo command to display it. This is fairly simple, and can have many
    uses, but there is much more too it! CODE <?php $var1 = "This is variable
    one"; $var2 = "This is variable two"; $varall = "$var1. $var2.
    You just combined three variables in one!"; echo $varall; ?> Outcome This is....
  11. Php Echo
    Learn what the echo can do for you. Includes basic echo and variable p (10)
    PHP Echo Description The echo() command has one purpose, displaying whatever you put in between the
    brackets. Learn to use it to your advantage. Try It Out There is your echo command. For now,
    it does nothing. It has no value to display. Outcome This is my text. Now this echo command
    has a value to display. Whatever you replace "This is my text." with will be displayed. Alright,
    lets move onto the next step. This time, we will include a variable in the echo command.
    $var = "This is a variable"; echo "$var. Congratualations, you just parsed a....
  12. Getting An Array Value Of A Dynamic Variable
    (9)
    Ok i can't believe I need help in php but I can't figure this out... If i have an array,
    lets say called test, how do i get a certain value from that array when referencing it dynamically
    by either a string or another variable? Example: CODE $test=array(1,2,5);
    $name="test"; //Doesn't work: echo $$name[0]; /Doesn't
    work: echo ${$name}[0]; ....
  13. Calling All Internet Marketing Newbies!
    (0)
    For the next two weeks, I will be accepting applications from people who want to learn the internet
    marketing business. This will be limited to Trap17 members ONLY! Out of the applications, I will
    select two or three people to work with me directly as I teach them how to succeed online in
    internet marketing. I am limiting the number of people I help so That I can fully give them my 1 on
    1 personal guidance The requirements to be accepted are as follows: 1. You MUST be computer
    literate. I can’t help you if you don’t know how to turn a computer on or you don’t know ....
  14. Bandwidth Count Up
    Problems in cpanel (6)
    Currently my cpanel bandwidth is not counting anything! And while I am quite happy to keep this
    option... (unlimited bandwidth) I have a feeling that bandwidth IS getting registered somewhere, but
    I am not getting it recorded in my cpanel. I would be glad for any assistance, cheers....
  15. Count Problem
    (2)
    Hey guys, I'm currently trying to count a number of rows in a table and then echo it out as the
    number of players in my game. I've checked the SQL sites and I'm following proper syntax and
    everything. But when I view the page, I get 'Resource id #11', and not 3 like it should
    be... Below is the code: CODE <?php //connection require
    ("../session.php"); require ("../configure.php");
    mysql_connect ("$dbhost", "$dbuser", "$dbpass")or
    die("Coul....
  16. Free Long Distance Calling From Computer To Phone
    (4)
    Does anybody know of a website or application that allows you to place FREE long distance calls from
    your computer to an actual phone? I remember there used to be a company called dialpad that allowed
    you to do this. I don't know if they are still around though. I think they started charging for
    the service. All the companies I've found require you to pay. There's gotta be a free one
    somewhere. Anybody know of one?....
  17. Runescape Cheats From Players
    Calling all RS players (3)
    I play RS some of the time and am wondering cheats for RS. I don't know any, but if you know
    some PLEASE POST THE CHEATS. It would help me alot and other ppl too... thanks. Cheats and
    specifically Hacking, are not Topics for discussion here at the trap17 ....
  18. Calling All Game Modders!
    Freelancer: Dark Frontier Mod Project (0)
    Hello All. The game being modded is Freelancer, is was put out I think in late 2003 and Microsoft
    Ensemble Studios + Firefly were the developers. If you haven't heard of it, don't be lazy,
    everyone can google it. If you have experience in modifying games and are looking for a new project
    consider modding this game with me. I'm new to modding Freelancer and I'm looking for some
    help in my project. What I am looking for are people who can edit models and create new ones, using
    3ds max or milkshape 3d. I'm also looking for people who can work with game ....
  19. Help Me Count... Please....
    12? or 13? (2)
    Help me count... please.... how many people are here in this picture? /tongue.gif"
    style="vertical-align:middle" emoid=":P" border="0" alt="tongue.gif" /> ....
  20. How High Can We Count?
    (10)
    As the name says!!! Rules: 1. No posts by the same auther one after another 2. Count in
    order! Don't miss and numbers out! 3. Have fun!!! /tongue.gif"
    style="vertical-align:middle" emoid=":P" border="0" alt="tongue.gif" /> I'll start... 1 ....
  21. The Days Count Down
    The end of final year - mixed feelings? (4)
    Well I realised the other day that I have less than a month of school left ever, and I started to
    think about the years and years I'd spent with most of my classmates and came to realise, "Hey,
    I won't be seeing them ever again." I mean, don't get me wrong, I love to see school end
    forever, however I can't help but think just how sad it will be saying goodbye to some of those
    people forever. Am I the only one who gets/got that feeling?....
  22. Post/credit Count Add-on
    I can't believe that I just thought of it. (11)
    I can't believe I just thought of after so long of being here. this is a simple code it terms
    of the idea but implentmenting it could be a challange but of course that would depend what need to
    be involoved. To help people get good posts we should implent a credit counter somewhere in the
    post saying how much the post is worth. This way people can either edit their post to add on to it
    if they can (of course it has to be legit and all that). Also it will help learn that that better
    quality post is the best way to go any thoughts? Counter Mod Plan -Counter....
  23. False Advertising
    Lame (13)
    Commercials are used to advertise a product and/or company. There is something called
    'truth' in advertising, yey somehow, most prefer to lie. Ok, this 1800PetGo commercial
    says that it's faster than going to the store, and it gets delivered free. But in small print it
    says "free shipping only to value of over $30" And how is it faster? You order it online, you
    wait about 2 days, then you pay an extra $8 for it. When you can just go to the pet store, by
    it in CASH and it's more secure than online too. Alright, the make-up commercials. As if....
  24. Javascript Help
    Can't do simple variable functions ¬_¬ (1)
    Edit: Haha, nevermind....I've had it fixed now /biggrin.gif" style="vertical-align:middle"
    emoid=":D" border="0" alt="biggrin.gif" /> an admin/mod can delete this if s/he feels like it
    /tongue.gif" style="vertical-align:middle" emoid=":P" border="0" alt="tongue.gif" /> Slide show
    So i'm trying to make my own slideshow, see above. I have the pictures showing depending what
    "num" equals...Well, the code's here: CODE <script TYPE="text/javascript">
    <!-- var num = 1; var pic = "pic.gif"; switch (num) { default&....
  25. Need A Java Script/ Help
    How to display download count on site? (6)
    /dry.gif" style="vertical-align:middle" emoid=" I am offering some download stuffs to the
    visitors of my site.. I have seen on some sites that they host download files on a box with 2
    columns, the left one showing the filename and the right column showing the number of times the file
    has been downloaded.. I want to know how to do these.. Is there any javascript available for this..
    if yes then please provide the link for the script.....
  26. Hosting credits count with Opera browser
    (2)
    I recently made three posts from a Opera Browser, I foun that the credits for those posts were not
    added to my credits. I've already faced this problem before. So please admin check the credits
    awarding system to be compatiable with Opera browsers.....
  27. Entertainment Post Count.
    (5)
    I think we all find ourselves listen to music, watching TV, or movies almost everyday. I think
    entertainment deserves a post count. I know its a huge part of my life.....
  28. Variable Definition
    (6)
    I am creating a checkbook balancing program that uses multiple forms. The first form will allow the
    user to enter a certain number of deposits, withdrawals, etc. I want to have the ability to have the
    user be able to enter more than what this first screen will provide by allowing them to transfer to
    another form. I would like to store the data entered for each of these transaction types into a
    global variable (to be used throughout the project) array, and produce a total of the dollar amount
    of this transaction type to be used in coming up with an ending balance of the a....
  29. Calling all University students...
    (15)
    Ok, and now for $50... For those who study at the university, where and what do you study?
    I study Classical Languages and Literatures (yup, Latin, Greek and stuff /biggrin.gif'
    border='0' style='vertical-align:middle' alt='biggrin.gif' /> ) at the " Faculdade de Letras da
    Universidade de Lisboa ", (the Humanities section of the University of Lisbon). So how about you?
    /smile.gif' border='0' style='vertical-align:middle' alt='smile.gif' /> ....
  30. Php Unique Hit Counter
    Count page hits with php. (28)
    Hello all, Here is a neat and helpful PHP script that can count unique page views on your website.
    First you need to open up a new page in your text editor and paste in this code. CODE <?php
    $filename = "hits.txt"; $file = file($filename); $file =
    array_unique($file); $hits = count($file); echo $hits; $fd
    = fopen ($filename , "r"); $fstring = fread ($fd , filesize
    ($filename)); fclose($fd); $fd = fopen ($f....

    1. Looking for calling, false, variable, count, val

Searching Video's for calling, false, variable, count, val
advertisement



Calling A False Variable... - like $count . $val



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE