Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by takis_kalas · May 09, 2016 at 07:20 PM · yieldmysqlwwwformtable

Yield return tables selectable with mysql data

Hallo i am new in unity and i have searched all over inernet for answears. I am trying to make a selectable list that retrieves and stores data on mamp with php and mysql form using c#. I am trying to receive data and display it properly but with my return i get a window showing code first and after that the data stored that i want to display. I want to make it with an foreach statement to show up like scrolable list that i can select one. Any help appriciated. Thank you.

using UnityEngine; using System.Collections; using UnityEngine.UI; public class LatestTech : MonoBehaviour { string answer; Vector2 position; private Rect windowRect = new Rect(530, 100, Screen.width/3, Screen.height/2); public string Name; public string Surname; public string Address; public string Phone; public string[] top10Techs; public string db_url="http://localhost/";

void OnGUI(){ windowRect = GUI.Window(0, windowRect, DoMyWindow, "Τεχνικοι"); Name = GUI.TextField(new Rect(305, 240, 200, 20), Name, 25); Surname = GUI.TextField(new Rect(305, 290, 200, 20), Surname, 25); Address = GUI.TextField(new Rect(305, 340, 200, 20), Address, 25); Phone = GUI.TextField(new Rect(305, 390, 200, 20), Phone, 25);

     if (GUI.Button (new Rect (303, 170, 215, 30), "Click here to add")) {

StartCoroutine (SaveScoress ()); }

if (GUI.Button (new Rect (303, 110, 215, 30), "Click here to display")) {

         WWW get_www = new WWW(db_url);

         StartCoroutine (LoadScoress ());

     }
 }

void DoMyWindow(int windowID) { position = GUILayout.BeginScrollView(position); GUILayout.Label(answer); GUILayout.EndScrollView();
}

IEnumerator SaveScoress() { // first we create a new WWWForm, that means a "post" command goes out to our database (for futher information just google "post" and "get" commands for html/php WWWForm form = new WWWForm ();

     // with this line we will give a new name and save our score into that name
     // those "" indicate a string and attach the score after the comma to it
     form.AddField ("newName", Name);
     form.AddField ("newSurname", Surname);
     form.AddField ("newAddress", Address);
     form.AddField ("newPhone", Phone);
     
     // the next line will start our php file that saves the Score and attaches the saved values from the "form" to it
     // For this tutorial I've used a new variable "db_url" that stores the path
     WWW webRequest = new WWW (db_url + "SaveScore.php", form);
     // with this line we'll wait until we get an info back
     yield return webRequest;
     print("Success on Ienum save");
 }

IEnumerator LoadScoress()

 {
     // we don't need to store any variable in this, just run the php file
     WWW webRequest = new WWW(db_url + "LoadScores.php");
         
     // now we wait again for the feedback of the command
     yield return webRequest;


     // this is a GUIText that will display the scores in game.
      //gameObject.GetComponent<Text>().text = "" + webRequest.text;
     print("Success on Ienum Load");
         
     answer = webRequest.text.ToString();

 }

}

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Is it possible to send a table name through a wwwform and use it in a php query? 0 Answers

WWW form isn't working in Build 1 Answer

WWWForm Question 2 Answers

How to format data returned from Mysql? 0 Answers

Mysql PDO Register user insert not inserting, no error feedback 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges