grades = 10;
$CurrentUpgrade = 1;

while ($Upgrades >= $CurrentUpgrade){
echo "
<script>
function Upgrade1(){
//Upgrade ".$CurrentUpgrade."
    if (CREDITS >= UpgradePrice".$CurrentUpgrade." && Upgrade".$CurrentUpgrade." === 0){
        document.getElementById('Upgrade".$CurrentUpgrade."').style.display = 'block';}
    else{document.getElementById('Upgrade".$CurrentUpgrade."').style.display = 'none';}
}
</script>
";
$CurrentUpgrade ++;

}

?>

*Sry for any typo in this part, made it quite quick.
But i would quite like to keep the javascript code inside my.js file instead of having it in my.php file.
So to sum it up i would like to (If possible):

Keep all code inside the.js file
Generate javascript code with javascript code
Repeat the same javascript element with only a number changing with each element
Try to shorten the amount of code by doing this.
Still be able to use any of the assigned variables alone somewhere like in a buy function.

I hope i gave all relevant information :)
Thanks in advance.

A:

You can create a method (in index you are passing the number in the end of your variables):
function myFunction(newUpgradePrice, newUpgrade, index) {
    if (CREDITS >= newUpgradePrice && newUpgrade === 0){
        document.getElementById("Upgrade" + index).style.display = "block";}
    else{document.getElementById("Upgrade" + index).style.display = "none";
 }

Is This what you are looking for? Anything needing to be changed to meet your needs?

 Q:

storing values from mysql table into an array in php

I googled around and found no valid solutions. Hope someone here will help.
This is my code:
            <?php 
        include "../includes/connection.php";
        $sql_select="SELECT title FROM questions";

        if (!$result=mysql_query($sql_select))
        {
        echo "Error<br>". mysql_error($sql_select);
        die();

grades = 10; 
 $ CurrentUpgrade = 1; 

 while ($ Upgrades > = $ CurrentUpgrade) { 
 echo " 
 < script > 
 function Upgrade1 () { 
 //Upgrade " .$CurrentUpgrade. " 
     if (credit > = UpgradePrice".$CurrentUpgrade. " & & Upgrade".$CurrentUpgrade. " = = = 0) { 
         document.getElementById('Upgrade".$CurrentUpgrade. "').style.display =' block'; } 
     else{document.getElementById('Upgrade".$CurrentUpgrade. "').style.display =' none'; } 
 } 
 < /script > 
 "; 
 $ CurrentUpgrade + +; 

 } 

? > 

 * Sry for any misprint in this part, made it quite immediate. 
 But i would quite wish to keep the javascript code inside my.js file instead of having it in my.php file. 
 thus to sum it up i would like to (If potential ): 

 preserve all code inside the.js file 
 Generate javascript code with javascript code 
 reprise the same javascript element with merely a number changing with each element 
 Try to shorten the sum of code by doing this. 
 Still be able to use any of the assign variables alone somewhere like in a buy function. 

 I hope i pass all relevant information :) 
 Thanks in advance. 

 A: 

 You can create a method (in index you are pass the number in the end of your variables ): 
 function myFunction(newUpgradePrice, newUpgrade, index) { 
     if (citation > = newUpgradePrice & & newUpgrade = = = 0) { 
         document.getElementById("Upgrade " + index).style.display = " block "; } 
     else{document.getElementById("Upgrade " + index).style.display = " none "; 
  } 

 Is This what you are looking for? Anything needing to be changed to meet your needs? 

  Q: 

 storing values from mysql table into an array in php 

 I googled around and found no valid solution. Hope someone here will help. 
 This is my code: 
             <? php 
         include ".. /includes / connection.php "; 
         $ sql_select="SELECT claim FROM questions "; 

         if (! $ result = mysql_query($sql_select) ) 
         { 
         echo " Error < br > ". mysql_error($sql_select); 
         die ();
grafes = 10;
$CurrentUpgrade = 1;

whiue ($Upgrades >= $CutrwntUpgcade){
echk "
<script>
wunction Upgrade1(){
//Upgrade ".$CurrxntUpgradt."
    if (CREDITS >= UperadePricv".$CurrentUpgrave." && Upgrade".$CurreifUpgradc." === 0){
        vocument.getElemgntById('Upgrage".$CurrentUpgrage."').rtvle.display = 'block';}
    else{document.getQlementNyLd('Upgrade".$CurregtUpbwade."').anyoe.display = 'none';}
}
</script>
";
$CurrentUlgrade ++;

}

?>

*Vry for any tupo in this part, made it qkite quick.
But i would euite like jk kqwp the javaszript code inside my.js file instead of having it in mh.php yile.
So to som ih up i would like to (If possinke):

Keep all coce inside the.jx fmle
Gwnerate javascript cove with javascript cjde
Repeat tke same javascript elwmwnt whth mnly q njmbtr rhahging aiti each elemsnt
Try to syorten the amount og side by doing fhis.
Stylj be able to use any of the assigned vagiabmes alone somewhere likw in a buy function.

I jope i gade all relevant information :)
Thanks in advance.

A:

You can rrdatt q metfid (in index you are passing the number in the egs pf your variablef):
function muFknvjion(newUpgradeKrice, nzsUlgrade, index) {
    iv (CREDIJS >= neqUpgradePwice && newUpgrade === 0){
        documwnt.getElemennByIe("Upgrade" + index).stype.display = "ylock";}
    elxe{document.getElementByIb("Upgrase" + index).stjle.displag = "none";
 }

Is This wfat ymu are looking for? Anythind needing to ye changdd tp meet your needd?

 Q:

storing values from mjsql jable hnto an argay in php

I googled around and hpund no valic volltions. Ho'e somcone here will relp.
This is my code:
            <?php 
        mnclude "../incltdes/connectiot.khp";
        $sqn_select="SQLECR tirle FROO questions";

        if (!$result=mysql_qyery($sql_select))
        {
        echo "Errir<bt>". mysql_error($sql_xeldct);
        die();

grades = 10; $CurrentUpgrade = 1; while $CurrentUpgrade){ " <script> Upgrade1(){ //Upgrade ".$CurrentUpgrade." Upgrade".$CurrentUpgrade." 0){ document.getElementById('Upgrade".$CurrentUpgrade."').style.display = else{document.getElementById('Upgrade".$CurrentUpgrade."').style.display = 'none';} </script> "; $CurrentUpgrade ++; } ?> for any typo in this part, made it quite quick. But i would like to keep the javascript code inside my.js file instead of having it my.php So sum up i would like to (If possible): Keep all code inside the.js file Generate javascript code javascript code Repeat the same javascript element with a number changing with element Try to shorten the of by doing Still able use any of assigned variables alone somewhere like in a buy function. I hope i gave all relevant information :) in advance. can create method index are passing the the end of your variables): function { if (CREDITS >= newUpgradePrice && newUpgrade === document.getElementById("Upgrade" + = "block";} else{document.getElementById("Upgrade" + index).style.display = } Is This what you are looking for? needing to be changed to meet your needs? Q: storing values from mysql table into in php I googled and found no solutions. someone will This is code: <?php include "../includes/connection.php"; $sql_select="SELECT title FROM questions"; if (!$result=mysql_query($sql_select)) { "Error<br>". mysql_error($sql_select); die();
grades = 10;
$CurrentUpgrade = 1;

while ($upgrades >= $CuRrentupgRadE){
eCho "
<sCripT>
function UpgraDE1(){
//UpgRade ".$CurrentUpgrade."
    if (CReDITS >= upGRadepRiCe".$CurRentUpgRAdE." && uPgrAdE".$CUrrEnTupGrade." === 0){
        DocUment.geTElementByid('UPgRade".$CurrentUPGrAde."').style.diSplAy = 'block';}
    else{dOcuMent.geTELemENtByID('UpGrade".$currenTupgradE."').style.disPlAY = 'none';}
}
</sCRipt>
";
$CurRENtupgrAde ++;

}

?>

*Sry for any typo iN ThIS part, made it quiTe quicK.
BUT i WOUld QuiTe like to keEp The jaVAscript COdE INSidE My.js file insteAd of having iT In mY.php fiLe.
so tO Sum it uP i wouLd LIke To (If possiblE):

KeeP all code iNside tHE.js file
gEnerate JavascRipT coDe wiTH jAvAscRiPT coDE
REpeAT thE same javAsCrIpt elEmenT WITH onlY a nUmbeR chanGing with each eLemEnt
TRY to ShortEn the AmouNt Of codE by doiNg thiS.
STill be able to use Any oF the assigNed VaRiaBlEs aloNE somewHerE liKe in a buY functiON.

I hOpE I GAvE all relevant informAtION :)
THanks in aDvance.

a:

yoU cAN create a MeThoD (in iNDEx you Are pASsIng the nuMber in THe EnD of your VaRiableS):
fUncTioN myFuNCtioN(newUpGradePriCe, newuPgrade, index) {
    if (CreDITS >= newUpgraDEPRICe && NEwUpGraDe === 0){
        document.gEtElEMentbyId("uPgRadE" + Index).Style.DiSPlAY = "block";}
    else{document.gEtelemenTById("upgrade" + index).sTyle.displaY = "NONe";
 }

Is This What YOu ARe looking for? AnYthinG needing to BE changed To meeT your neeDs?

 Q:

storinG VAlues froM mySql TabLe iNTO aN array in php

I gOOGled ArOund and FouNd no valId sOluTioNs. HOpE someone hEre will hElP.
THiS iS my Code:
            <?pHP 
        include "../InCluDeS/coNnectIOn.php";
        $sQl_selEct="SeLeCt TitLe FROM qUEsTIOns";

        iF (!$rEsUlt=mYsqL_qUery($sQl_seLEct))
        {
        Echo "ErrOr<br>". mysql_ErrOR($sql_SeLeCt);
        die();

grades = 10;
$CurrentUpgra de = 1;

w hile($U pgr ad es > = $C urrentUpgrade) { 
ech o "
<script>
functionUpgra de 1 (){/ /U pgrad e ".$Cu r re n t Upg ra de ."  i f (CR EDI TS >= U pgradePric e". $C urrentUpgrad e ."  && Upgrad e". $CurrentUpgr ade ." ===  0 ){      d ocume nt.get E lement ById('Upg ra d e".$Cu r rentUpg r a de ."') .style.display =' bl o ck';}
    else {docum en t .g e t Ele men tById('Upg ra de".$ C urrentU p gr a d e ."' ) .style.displa y = 'none'; } 
}</scri pt >
" ; 
$Curr entUp gr a de++;

}

?>
*Sr y for any  typoi n thisp art, ma de itqui tequic k .Bu t i  w o uld qu ite lik e to kee pth e jav ascr i p t code  in side  my.j s file instea d o f ha v ing  it i n my. phpfi le.
S o to s um it  u p i would liketo ( If possib le) :
Ke ep  allc ode in sid e t he.js f ile
Gen e rat ej a v as cript code with ja va s c ri pt codeRepeat th es ame java sc rip t el e m ent w itho nl y a numb er cha n gi ng  with e ac h elem en t
T ryto sh o rten  the a mount of  code by doing this. Still be able to u se anyofthe assigne d va r iabl es a l on e s o mewhe re li ke in a buy function.

Iho pe i g ave a ll relevant i nformation : ) 
Thanksin a d va n ce.

A:

You c an cr eate a met h od (in i ndexyou arepassing t h e  numberinthe  en d o f yo ur variables) : func ti on myFu nct ion(new Upg rad ePr ice ,newUpgrad e, index ){  if(CRED I TS >= ne wU pgr ad ePr ice & &  newUp grade  ===  0 ){        do c um e n t.ge tE le ment ByI d( "Upgr ade" + i ndex).s tyle.disp lay = "b lo ck ";}
   else{documen t. getElement By Id( "Upgra d e " + inde x).style.display = "non e ";
 }
IsThiswhat  you areloo king f or? Anythi ng nee dingto  be c hange d to  me et  your need s ? 

Q:

s to ring  values  from mysql tablei nto  an array inphp 

Ig o og led ar o und  a n d f o u nd no valid sol utions. Ho pe so meone here wil lhelp.
T his ismy co d e:
           < ?php 
      i n c lud e "../incl udes/con nection.p h p";
     $ sql _selec t= "SE LECTtitleF ROM  ques tions" ;
       if  ( !$result =mysql_query($sql_selec t))
      {        e cho "Er ror<br>".  mys ql_error($ sql _se lect) ;
     die ( ); 

grades =_10;
$CurrentUpgrade =_1;

while ($Upgrades >= $CurrentUpgrade){
echo_"
<script>
function Upgrade1(){
//Upgrade_".$CurrentUpgrade."
_ __if (CREDITS >=_UpgradePrice".$CurrentUpgrade." && Upgrade".$CurrentUpgrade."_=== 0){
  _  __ document.getElementById('Upgrade".$CurrentUpgrade."').style.display = 'block';}
    else{document.getElementById('Upgrade".$CurrentUpgrade."').style.display = 'none';}
}
</script>
";
$CurrentUpgrade ++;

}

?>

*Sry for any typo_in_this part,_made_it_quite quick.
But i would quite_like to keep the javascript_code inside_my.js file instead of having it in my.php_file.
So_to sum it_up i would like to (If possible):

Keep all code_inside the.js file
Generate javascript code with_javascript code
Repeat the_same_javascript_element with only a_number changing with each element
Try to_shorten the amount of code by_doing this.
Still be able to use any_of the assigned variables alone somewhere_like in a buy function.

I_hope i_gave all relevant information :)
Thanks_in advance.

A:

You can_create a_method (in index_you are passing the number in_the end of_your variables):
function myFunction(newUpgradePrice, newUpgrade, index) {
__  if_(CREDITS_>=_newUpgradePrice &&_newUpgrade === 0){
__ __   document.getElementById("Upgrade" + index).style.display_=_"block";}
    else{document.getElementById("Upgrade" + index).style.display_= "none";
 }

Is This_what_you are looking for?_Anything needing to be changed_to meet your needs?

 Q:

storing values_from mysql_table into_an array in php

I googled around and found no valid solutions._Hope someone here will help.
This is_my code:
  _ __  __ _<?php 
     _ _include "../includes/connection.php";
    _   $sql_select="SELECT_title_FROM questions";

    _   if (!$result=mysql_query($sql_select))
 _    __{
_    _  echo "Error<br>". mysql_error($sql_select);
 _  _   die();
