Solved

JQuery Mobile - Select Menu From MySql Table

Posted on 2013-01-22
3
1,042 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

862 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

23 Experts available now in Live!

Get 1:1 Help Now