php - I want to print value in $s1 $ s2 $s3 instead of variable name -


i want print value in $s1 $ s2 $s3 instead of variable name. when value sent in database there goes variable names $s1,$s2,$s3 etc not values in them.

<?php echo $s1=$_post['1']; echo $s2=$_post['2']; echo $s3=$_post['3']; echo $s4=$_post['4'];  $proo=$_post['proo']; $semm=$_post['semm']; $shii=$_post['shii']; $secc=$_post['secc']; $subb=$_post['subb']; if($btnn) {     $sele=mysql_query("select * `sconfirmed` `pro`='$proo' && `sem`='$semm' && `section`='$secc' && `shift`='$shii' ");     $count=mysql_num_rows($sele);     $b='1';          {          $a='1';         $s='$s';         while($ro=mysql_fetch_array($sele))         {             $pic=$ro['pic'];             $sname=$ro['sname'];             $rollno=$ro['rollno'];              $sfather=$ro['sfather'];             $phone=$ro['phone'];             $email=$ro['email'];              $address=$ro['address'];             $dob=$ro['dob'];             $iddd=$ro['id'];             $sess=$ro['ses'];              $c=$s.$a;               $insert=mysql_query("insert `markssub1`(`sid`,`sname`,`sem`,`sec`,`pro`,`shi`,`rollno`,`ses`,`tid`,`tname`,`subject`,`marks`) values ('$iddd','$sname','$semm','$secc','$proo','$shii','$rollno','$sess','$id','$user','$subb','$c') ");             $a=$a+1;         }     }     while($count<=$b); } ?> 

i think should change

$s='$s'; 

to

$s="$s"; 

there difference on using double or single quotes in php. use double quotes when dealing variables.

added

if understood you're trying do, see if example helps you:

$s1 = "something"; $currentvar = "s"."1"; /*then here loop through whatever want (in example "s".$a */  echo $$currentvar; 

will return "something";

that's it?


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -