Current location: Hot Scripts Forums » Programming Languages » PHP » eval variables syntax


eval variables syntax

Reply
  #1 (permalink)  
Old 07-07-03, 01:11 PM
banquet banquet is offline
New Member
 
Join Date: Jul 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
eval variables syntax

Hi guys,

I have read many tutorials on eval for php and its just getting any
clearer. Im used to javascript and flash eval.

I have 5 text boxes answer1...answer5 that will be submited to insert
into a
database. When I retreive the form values I would like to put them
into a variable ($answer1,$answer2 ...) like this:


$i++;
//update actions for 5 answers
$sAnswer = eval("$answer".$i);


So I would like $sAnswer to equal and evaluate $answer1...$answer5

I cant seem to figure out how the heck to create the syntax.

Thanks for your help in advanced.

David
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 07-09-03, 05:49 AM
Chris Boulton Chris Boulton is offline
Wannabe Coder
 
Join Date: Jun 2003
Location: Sydney, Australia
Posts: 208
Thanks: 0
Thanked 0 Times in 0 Posts
Here is a simple fix...

Change all the textbox names's to something like this answer[1],answer[2],answer[3] etc.

Then change your code to something like
PHP Code:

<?php

while(list($key$val) = each($answer)) {
 echo 
"$key - $val<br>";
}
?>
That code will output something like

1 - Answer for Q1
2 - Answer for Q2

__________________
Chris Boulton
SurfiOnline!
MyBulletinBoard
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
syntax error plz help darkcarnival PHP 40 08-10-04 05:02 AM
PAssing variables dbalka Perl 3 10-29-03 06:00 PM
Variables -> MS Word Template???? lyndonw PHP 0 10-09-03 06:03 PM
adding more variables to the mail() result spinicrus PHP 6 08-28-03 05:55 PM
Extract variables from a database andreasberglind ASP.NET 1 08-28-03 10:17 AM


All times are GMT -5. The time now is 08:57 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.