Jump to content

php_padawan

Members
  • Posts

    8
  • Joined

  • Last visited

php_padawan's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. but the problem sir is that I am just doing a maintenance on a system. I have no way of modifying how the javascript is being handled and currently, the variable that I needed was coded in javascript as a variable.
  2. Hi Guys, Will you please help me with this? As from what you could see, the value of $bbbb is dynamic during runtime. I am trying to get a value from a javascript variable to compare it against another variable in just true and false condition. The problem is that it seems that php is not allowing a comparison between a php variable and javascript. no matter what I try, it can't bring the right output or the true and false from $bbbb is not working. WHener I try to just put a simple true and false string to $bbbb, it works fine and normal. the only problem is that whenever it has a value coming from javascript or '<script type="text/javascript">document.write(IsUserLoggedIn);</script>'; I already tried the following: if ($bbbb == true) { if ($bbbb == 'true') { if ($bbbb == '<script type="text/javascript">document.write(IsUserLoggedIn);</script>' I am trying to fix this for a week, hope that someone could help me. thanks I really think that the problem lies in the part where I am trying to get the true and false value of a variable from a Javascript. It is like I need to convert it to php string or something like that. $save_creation ='<a href="' . create_link( MENU_MYACCOUNT,'creations') . '\"> '.$CI->lang->line('glb_SaveSauvegarder').'creations'.'</a>'; $dialog_box ='<a href="#" onclick="SignInDialog(\'\', \'\', \'' . create_link( MENU_MYACCOUNT) . '\'); return false;">'.$CI->lang->line('glb_SaveSauvegarder').' dialog_box'.'</a>'; $bbbb = '<script type="text/javascript">document.write(IsUserLoggedIn);</script>'; if ($bbbb = true) { $return .= '</ul><span class="link">' .$save_creation. '</span></div>'; return $return; } else { $return .= '</ul><span class="link">' . $dialog_box . '</span></div>'; return $return; }
  3. here is my most updated code, I have managed to connect to database and also return the data on the HTML page. Still, my problem is how to compare two data to return the equivalent data on the third row but I am working on it. I am still researching what is the best approach for this. <html> <head> <title>JMData Decode</title> </head> <body> <?php $JMData = "{\"a_stepActual\":\"99\",\"a_StepReached\":\"99\",\"a_ShowBack\":\"1\",\"a_Similar\":\"\",\"a_JMStarted\":\"1\",\"a_GarmentStatus\":\"2\",\"s_Step1\":\"1\",\"s_Step2\":\"3\",\"s_Step3\":\"7\",\"s_Step4\":\"19\",\"s_Step4_s\":\"2\",\"s_Step5\":\"22\",\"s_Step5_s\":\"2\",\"s_Step6\":\"2816\",\"s_Step7\":\"2819\",\"s_Step8\":\"2821\",\"s_Step8_s\":\"2\",\"s_Step8_r\":\"3\",\"s_Step9\":\"36\",\"s_Step9_s\":\"0\",\"s_Step9_r\":\"0\",\"s_Step10\":\"2826\",\"s_Step10_s\":\"2\",\"s_Step10_r\":\"0\",\"s_Step11\":\"2830\",\"s_Step11_s\":\"2\",\"s_Step11_z\":\"0\",\"s_Step11_r\":\"3\",\"s_Step12\":\"2836\",\"s_Step12_s\":\"0\",\"s_Step12_z\":\"0\",\"s_Step12_r\":\"0\",\"s_Step13\":\"44\",\"s_Step13_s\":\"2\",\"s_Step13_z\":\"1\",\"s_Step13_b\":\"20\",\"s_Step14\":\"47\",\"s_Step14_s\":\"2\"}"; $dec = (json_decode($JMData)); echo "<table border = 1>"; echo "<tr><td>First Row</td><td>Second Row</td><td>Third Row</td></tr>"; foreach ($dec as $key => $value) { echo "<tr><td>". $key."</td><td>". $value ."</td><td>$nbsp</td></tr>"; }; echo "<table/>"; ?> <?php $con=mysqli_connect("localhost","test","test","db_test"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $result = mysqli_query($con,"SELECT * FROM Step1Table"); echo "</br></br>"; echo "<table border = 1>"; while($row = mysqli_fetch_array($result)) { echo "<tr> <td>".$row['id']."</td> <td>".$row['StepWithoutQuotations']."</td> <td>".$row['StepValue']."</td> <td>".$row['StepWithQuotations']."</td> <td>".$row['InternalReference ']."</td> </tr>"; } echo "<table/>"; mysqli_close($con); ?> </body> </html>
  4. Sorry, sir. I think it did not attach last night. here is the attachment that I was referring to: newtable.txt
  5. Hi Sir, Please refer to the new table arrangement that I created. This time, I made different tables for different steps.
  6. Can you please help and advice me the best way to approach this requirement? As you can see, I have three columns. The First Row, Second Row and Third Row. I already managed to accomplish the First and Third Row, but this time, it is a bit challenging. I need to match the data found in First and Second Row to come up with the Third Row. I attached a copy of my table for your reference (testdb.txt). For example: If the value of the First Row is 's_Step1' and the Second Row is '1' the value of the Third Row should be 'Women'. If the value of the First Row is 's_Step2' and the Second Row is '3' the value of the Third Row should be 'Straight Women' and so on and so forth. Please guide me the best way to approach this. Thanks Here is what I have accomplished so far: <html> <head> <title>JMData Decode</title> </head> <body> <?php $JMData = "{\"a_stepActual\":\"99\",\"a_StepReached\":\"99\",\"a_ShowBack\":\"1\",\"a_Similar\":\"\",\"a_JMStarted\":\"1\",\"a_GarmentStatus\":\"2\",\"s_Step1\":\"1\",\"s_Step2\":\"3\",\"s_Step3\":\"7\",\"s_Step4\":\"19\",\"s_Step4_s\":\"2\",\"s_Step5\":\"22\",\"s_Step5_s\":\"2\",\"s_Step6\":\"2816\",\"s_Step7\":\"2819\",\"s_Step8\":\"2821\",\"s_Step8_s\":\"2\",\"s_Step8_r\":\"3\",\"s_Step9\":\"36\",\"s_Step9_s\":\"0\",\"s_Step9_r\":\"0\",\"s_Step10\":\"2826\",\"s_Step10_s\":\"2\",\"s_Step10_r\":\"0\",\"s_Step11\":\"2830\",\"s_Step11_s\":\"2\",\"s_Step11_z\":\"0\",\"s_Step11_r\":\"3\",\"s_Step12\":\"2836\",\"s_Step12_s\":\"0\",\"s_Step12_z\":\"0\",\"s_Step12_r\":\"0\",\"s_Step13\":\"44\",\"s_Step13_s\":\"2\",\"s_Step13_z\":\"1\",\"s_Step13_b\":\"20\",\"s_Step14\":\"47\",\"s_Step14_s\":\"2\"}"; $dec = (json_decode($JMData)); echo "<table border = 1>"; echo "<tr><td>First Row</td><td>Second Row</td><td>Third Row</td></tr>"; foreach ($dec as $key => $value) { echo "<tr><td>". $key."</td><td>". $value ."</td><td>$nbsp</td></tr>"; }; echo "<table/>"; ?> </body> </html> testdb.txt
  7. thanks for the advice. using JSON is much simpler and cooler. many thanks! here is the final working code: <html> <head> <title>JMData Decode</title> </head> <body> <?php $JMData = "{\"a_stepActual\":\"99\",\"a_StepReached\":\"99\",\"a_ShowBack\":\"1\",\"a_Similar\":\"\",\"a_JMStarted\":\"1\",\"a_GarmentStatus\":\"2\",\"s_Step1\":\"1\",\"s_Step2\":\"3\",\"s_Step3\":\"7\",\"s_Step4\":\"19\",\"s_Step4_s\":\"2\",\"s_Step5\":\"22\",\"s_Step5_s\":\"2\",\"s_Step6\":\"2816\",\"s_Step7\":\"2819\",\"s_Step8\":\"2821\",\"s_Step8_s\":\"2\",\"s_Step8_r\":\"3\",\"s_Step9\":\"36\",\"s_Step9_s\":\"0\",\"s_Step9_r\":\"0\",\"s_Step10\":\"2826\",\"s_Step10_s\":\"2\",\"s_Step10_r\":\"0\",\"s_Step11\":\"2830\",\"s_Step11_s\":\"2\",\"s_Step11_z\":\"0\",\"s_Step11_r\":\"3\",\"s_Step12\":\"2836\",\"s_Step12_s\":\"0\",\"s_Step12_z\":\"0\",\"s_Step12_r\":\"0\",\"s_Step13\":\"44\",\"s_Step13_s\":\"2\",\"s_Step13_z\":\"1\",\"s_Step13_b\":\"20\",\"s_Step14\":\"47\",\"s_Step14_s\":\"2\"}"; $dec = (json_decode($JMData)); echo "<table border = 1>"; foreach ($dec as $key => $value) { echo "<tr><td>". $key."</td><td>". $value ."</td></tr>"; }; echo "<table/>"; ?> </body> </html>
  8. I would like to request a little help from all of you. I would like to know how can I approach this in php. I have this string of data: {"a_stepActual":"99","a_StepReached":"99","a_ShowBack":"1","a_Similar":"","a_JMStarted":"1","a_GarmentStatus":"2","s_Step1":"1","s_Step2":"3","s_Step3":"7","s_Step4":"19","s_Step4_s":"2","s_Step5":"22","s_Step5_s":"2","s_Step6":"2816","s_Step7":"2819","s_Step8":"2821","s_Step8_s":"2","s_Step8_r":"3","s_Step9":"36","s_Step9_s":"0","s_Step9_r":"0","s_Step10":"2826","s_Step10_s":"2","s_Step10_r":"0","s_Step11":"2830","s_Step11_s":"2","s_Step11_z":"0","s_Step11_r":"3","s_Step12":"2836","s_Step12_s":"0","s_Step12_z":"0","s_Step12_r":"0","s_Step13":"44","s_Step13_s":"2","s_Step13_z":"1","s_Step13_b":"20","s_Step14":"47","s_Step14_s":"2"} and I needed it to be converted to the attached file or be converted to a more readable format. I tried looping to no success. Here is what I have done so far, by the way: <html> <head> <title>Test String</title> </head> <body> <?php $JMData = "{\"a_stepActual\":\"99\",\"a_StepReached\":\"99\",\"a_ShowBack\":\"1\",\"a_Similar\":\"\",\"a_JMStarted\":\"1\",\"a_GarmentStatus\":\"2\",\"s_Step1\":\"1\",\"s_Step2\":\"3\",\"s_Step3\":\"7\",\"s_Step4\":\"19\",\"s_Step4_s\":\"2\",\"s_Step5\":\"22\",\"s_Step5_s\":\"2\",\"s_Step6\":\"2816\",\"s_Step7\":\"2819\",\"s_Step8\":\"2821\",\"s_Step8_s\":\"2\",\"s_Step8_r\":\"3\",\"s_Step9\":\"36\",\"s_Step9_s\":\"0\",\"s_Step9_r\":\"0\",\"s_Step10\":\"2826\",\"s_Step10_s\":\"2\",\"s_Step10_r\":\"0\",\"s_Step11\":\"2830\",\"s_Step11_s\":\"2\",\"s_Step11_z\":\"0\",\"s_Step11_r\":\"3\",\"s_Step12\":\"2836\",\"s_Step12_s\":\"0\",\"s_Step12_z\":\"0\",\"s_Step12_r\":\"0\",\"s_Step13\":\"44\",\"s_Step13_s\":\"2\",\"s_Step13_z\":\"1\",\"s_Step13_b\":\"20\",\"s_Step14\":\"47\",\"s_Step14_s\":\"2\"}"; //$JMData = "s_Step1":"1","s_Step2":"3","s_Step3":"7","s_Step4":"19","s_Step4_s":"2","s_Step5":"22","s_Step5_s":"2","s_Step6":"2816","s_Step7":"2819","s_Step8":"2821","s_Step8_s":"2","s_Step8_r":"3","s_Step9":"36","s_Step9_s":"0","s_Step9_r":"0","s_Step10":"2826","s_Step10_s":"2","s_Step10_r":"0","s_Step11":"2830","s_Step11_s":"2","s_Step11_z":"0","s_Step11_r":"3","s_Step12":"2836","s_Step12_s":"0","s_Step12_z":"0","s_Step12_r":"0","s_Step13":"44","s_Step13_s":"2","s_Step13_z":"1","s_Step13_b":"20","s_Step14; $JMData1 = str_replace("\"","",$JMData); $JMData2 = strpos($JMData1, "s_Step1"); $JMData3 = substr($JMData1, strpos($JMData1, "s_Step1"), 500); //echo $JMData1; //echo $JMData2; echo $JMData3; ?> </body> </html>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.