WordPress.org

Ready to get started?Download WordPress

Forums

Present data from database into page (1 post)

  1. zeroprime
    Member
    Posted 1 year ago #

    Ok, i'm new on using wordpress and have problems with presenting data from database. I created a new page and edit the body of the page's theme. here is the code:

    <?php
    	/*Template Name: Study Abroad*/
    ?>
    <?php global $SMTheme;?>
    
    <?php
    	get_header();
    ?>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    
    <head>
    <script type="text/javascript" src="./jquery-1.9.1.js" ></script>
    <script>
    function showUser(str) {
        if (str.length == 0) {
        } else {
    
           $.post("getuser.php", {queryString: "" + str + ""}, function(data) {
                if (data.length > 0) {
    
                    $('#txtHint').html(data);
                }
            });
        }
    }
    </script>
    </head>
    
    <body>
    <?php
    
    <div class='articles'>
    		<div class='one-post'>
    		<div id="post-<?php the_ID(); ?>" <?php post_class("post-caption"); ?>>
    			<?php if (!is_single()&&!is_page()) { ?>
    			<h2><a href="<?php the_permalink(); ?>" title="<?php printf( $SMTheme->_( 'permalink' ), the_title_attribute( 'echo=0' ) ); ?>" class='post_ttl'><?php the_title(); ?></a></h2>
    			<?php } else { ?>
    				<h1><?php the_title(); ?></h1>
    			<?php } ?>
    		</div>
    
    			</div>
    		</div>
    
    			<div class='studyaboard' style="height:800px ">
    			<div class="country" ">
    			<div id="form_container" >
    
    		<form  id="form_222202" >	
    
    				<li id="li_1" style="position: absolute; left:3%; top: 3%; font-weight:bold; color:black;">
    					<label class="description" for="element_1">Choose Country </label>
    						<div>
    							<?php
    							include("config.php");
    							$sql = "SELECT countries FROM studyAbroad";
    							$result = mysql_query($sql);
    							?>
    								<select name="users" onchange="showUser(this.value)">
    									<?php
    									while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
    									?>
    								<option value="<?php echo $line['countries'];?>"> <?php echo $line['countries'];?> </option>
    
    									<?php
    									}
    									?>
    
    								</select>
    						</div>
    				</li>
    
    		</form>	
    
    	</div>
    
    			</div>
    			</div>
    			<div id="txtHint" class="txtHint">dfg</div>
    </body>
    
    <?php
    	get_footer();
    ?>
    </html>

    I have created a drop-down list which populated from database and by using Jquery i'm trying to present the selected column to the last div (id=txtHint) but simply doesn't return anything. I tried this html code individually without the WP parts into another test page and worked perfectly, also in the current page i removed all the WP related php files and didn't worked. Any solution?

Topic Closed

This topic has been closed to new replies.

About this Topic