Solved

JQuery Mobile - Select Menu From MySql Table

Posted on 2013-01-22
3
1,030 Views
Last Modified: 2013-01-22
Hi,

I take the data from a table and display it in a select menu component, I tried the code below but I get only blank lines worthless.
Is there any example or you can fix my code?
Thank you all,
Regard

			<select name="cliente" id="cliente" class="select" data-inline="false" data-native-menu="false">
			<option>Seleziona Cliente</option>
			<?php
                        $query = mysql_query("SELECT * FROM clienti ORDER BY RagioneSociale desc");
                        while($data = mysql_fetch_assoc($query)) {
                        ?>
                        <option value="<?php echo $data["RagioneSociale"]; ?>><?php echo $data["RagioneSociale"]; ?>"</option>
                        <?php } ?>
			</select>

Open in new window

0
Comment
Question by:danz67
3 Comments
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 140 total points
ID: 38804453
tyr like this

<select name="owner">
<?php
$sql = mysql_query("SELECT username FROM users");
while ($row = mysql_fetch_array($sql)){
echo "<option value=\"owner1\">" . $row['username'] . "</option>";
}
?>
</select>

refer
http://stackoverflow.com/questions/8022353/how-to-populate-html-dropdown-list-with-values-from-database
0
 
LVL 28

Expert Comment

by:chilternPC
ID: 38804471
it may depend on what the data is in the $data array, is it a string or an integer?

try replacing:

echo $data["RagioneSociale"]

with

echo gettype($data["RagioneSociale"]);

also are you sure there is data in the array?
0
 

Author Closing Comment

by:danz67
ID: 38804486
Best Solution for me
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now