Woodburn2006 Posted August 31, 2006 Share Posted August 31, 2006 can you put sql queries in a function, whenever i have tries i cannot seem to get it to work.is there anything specific that you need to do? Quote Link to comment Share on other sites More sharing options...
techiefreak05 Posted August 31, 2006 Share Posted August 31, 2006 yes. heres a function that uses SQL code.. i use this on my site[code]<?phpfunction yourInfo(){$sql = "SELECT * FROM users WHERE username = '$_SESSION[username]' LIMIT 1";$query = mysql_query($sql);while($row = mysql_fetch_array($query)) {echo "<center><b>Getting Info for: " .$row[username]. "</b></center>";echo "<b>First Name: <u>".$row['fname']."</u><p>";echo "Username: <u>".$row['username']."</u><p>";echo "zyPoints: <u>".$row['zypoints']."</u><p>";echo "E-mail: <u>".$row['email']."</u><p></b>";echo "<center><a href='editAccnt.php'>Edit Account</a></center>";}}?>[/code] Quote Link to comment Share on other sites More sharing options...
techiefreak05 Posted August 31, 2006 Share Posted August 31, 2006 oh, and to call the function, put this on any page you want to use the function on:[code]<?php yourInfo() ?>[/code]if you in clude all your functions in a seperate file than what your displaying them in.. you have to put[code]<?phpinclude("file.php");?>[/code]at the top of the page u wish to use the functon. "file.php" is the filename that has the function Quote Link to comment Share on other sites More sharing options...
Woodburn2006 Posted August 31, 2006 Author Share Posted August 31, 2006 ok, cool thanks alot Quote Link to comment Share on other sites More sharing options...
techiefreak05 Posted August 31, 2006 Share Posted August 31, 2006 yep. np. if you need any help understading it more.. email me: techiefreak05@gmail.com .. or IM me Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.