...

View Full Version : mySQL POST & mouseClick



vardz
02-09-2007, 07:36 AM
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.


<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

neomaximus2k
02-09-2007, 12:07 PM
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


<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>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum