Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    mySQL POST & mouseClick

    Hi,

    I am new to this forum but I really need some help. I am having some trouble with understanding how to post entries to a mysql database with php using the mouseClick event with modx. The get method didn't seem to work on the modx database so I'm trying to use the post method instead to see if this works. I want to post the value of the user's id to the page that is created and create a snippet (modx) that will read the value of the post data and display the row in the database that corresponds to the id on a page in the document tree.

    This is the code I have so far.

    Code:
    <table border="2" cellspacing="2" cellpadding="2" width="50%">
    <tr>
    <th><font face="Arial, Helvetica, sans-serif">Name</font></th>
    <th><font face="Arial, Helvetica, sans-serif">Email</font></th>
    </tr>
    
    <?php
    // memberListing.inc.php - a customised php page that works from a snippet call to list web users in // the database. It provides links to each of the user profiles stored in the database
    // author: sarah vardy
    
    	// Establish a connection to the MySQL DBMS
    	$connection = mysql_connect("localhost", "root", "s0laspie");
    
    	// Use the modx database
    	mysql_select_db("modx", $connection);
    
    
       	// Run a query through the connection
       	$result = mysql_query("SELECT id, fullname, email, photo FROM modx_web_user_attributes ORDER BY id", $connection);
      
       
       	//run the while loop that grabs all the web users
      	while($r=mysql_fetch_array($result)) 
       	{ 
          	//grab the title and the ID of each user
          	$fullname=$r["fullname"];//take out the title
          	$Uid=$r["id"];//take out the id
    		$email=$r["email"]; //take out the email
    		$photo=$r["photo"]; //take out the photo
    
    ?>
    
    <tr><td bgcolor="#CCCCCC" ><div align="center"></div>
    <!--<form id="userIdentification" action="displayMember.php" method="post" name="userIDform">-->
    <?php
    		// store the url in a variable
    		$url = $modx->makeUrl(48, '', "Uid=$Uid");			
    		?>
    		<!--<input type="hidden" value="Uid" id="KeyName">-->
    		<?php
    		//make the title a link
          	echo "<a href='$url'>$Uid $fullname</a>";
    		?>
    		</td>
    		<!--</form>-->
    		<td>
    		<?php echo "$email"; ?>
    		</td>
    		</tr>
    		</div>
    		<?php
    	}   		
    ?>
    
    <?
    echo "</table>";
    ?>
    Any help I could get would be greatly appreciated!!!!

    Thankyou!

    Cheers,

    Sarah

  • #2
    Regular Coder
    Join Date
    Jan 2007
    Posts
    213
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This is possibly because you have not validated your code, if you used the W3 validation tool you would have seen a LOT of overlapping tags.

    I have cleaned up the code for you now so this should work, if it does not work then you need to post your displaymember.php script as the problem probably lies in there

    PHP Code:
    <table border="2" cellspacing="2" cellpadding="2" width="50%">
        <tr>
            <th><font face="Arial, Helvetica, sans-serif">Name</font></th>
            <th><font face="Arial, Helvetica, sans-serif">Email</font></th>
        </tr>
        <?php
    // memberListing.inc.php - a customised php page that works from a snippet call to list web users in // the database. It provides links to each of the user profiles stored in the database
    // author: sarah vardy

        // Establish a connection to the MySQL DBMS
        
    $connection mysql_connect("localhost""root""s0laspie");

        
    // Use the modx database
        
    mysql_select_db("modx"$connection);


           
    // Run a query through the connection
           
    $result mysql_query("SELECT id, fullname, email, photo FROM modx_web_user_attributes ORDER BY id"$connection);
      
       
           
    //run the while loop that grabs all the web users
          
    while($r=mysql_fetch_array($result)) { 
              
    //grab the title and the ID of each user
              
    $fullname=$r["fullname"];//take out the title
              
    $Uid=$r["id"];//take out the id
            
    $email=$r["email"]; //take out the email
            
    $photo=$r["photo"]; //take out the photo

    ?>
        <tr>
        <td bgcolor="#CCCCCC" >
        <form id="userIdentification" action="displayMember.php" method="post" name="userIDform">
    <?php
            
    // store the url in a variable
            
    $url $modx->makeUrl(48''"Uid=$Uid");            
    ?>
        <input type="hidden" value="Uid" id="KeyName">
        <a href="<?=$url;?>"><?=$Uid." ".$fullname;?></a>
        </form>
        </td>
        <td><?=$email;?> </td>
        </tr>
    <?php
        
    }           
    ?>
    </table>
    Matthew Bagley
    Paramiliar Design Studios
    Website Design | Website Development | Search Engine Optimisation (SEO)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •