Jump to content

overlordofevil

Members
  • Posts

    123
  • Joined

  • Last visited

    Never

Everything posted by overlordofevil

  1. I am reading up on exporting data from mysql with php. Everything I find tells me how to get all data so what I am wondering is there a way to set up a script to select specific data and have the system download it to a csv file. To explain I am working on a db with multiple tables all tied together with a user id. What I would like to do is do a search for all users tied to a specific group/department. Take the id and get all the data for that user. As the group/department id is only in one table and the user id is in all of them, i know i can run a query to get the ids I need but how would I run addition queries to get the data from the other table and have them exported to the file. Since the queries would be in a loop going through all the tables with the specific id would it be possible to have the script write to the file and then continue to update.. is that possible? I am sure i can figure this out but I am wondering if anyone else has worked on something like this and has some advice on what to watch out for while programing the script. Any suggestion/advice is appreciated. Thanks Bill
  2. I am reading up on exporting data from mysql with php. Everything I find tells me how to get all data so what I am wondering is there a way to set up a script to select specific data and have the system download it to a csv file. To explain I am working on a db with multiple tables all tied together with a user id. What I would like to do is do a search for all users tied to a specific group/department. Take the id and get all the data for that user. As the group/department id is only in one table and the user id is in all of them, i know i can run a query to get the ids I need but how would I run addition queries to get the data from the other table and have them exported to the file. Since the queries would be in a loop going through all the tables with the specific id would it be possible to have the script write to the file and then continue to update.. is that possible? I am sure i can figure this out but I am wondering if anyone else has worked on something like this and has some advice on what to watch out for while programing the script. Any suggestion/advice is appreciated. Thanks Bill
  3. Thank you both for the feedback and help.. I used the code example to help modify my code and it made things work with no issues. Just one other question.. do special characters like & or % get taken care of by this function or is there another one i need to use. Thanks Bill
  4. cool sounds simple enough. so with the characters being escaped to make them db friendly if I do a query to call the same values and echo them on the screen will they display correctly or will i have the backslash in it.. I appreciate you guys explaining this to me just got confused on it. Thanks again Bill
  5. Hey all, I have a question and its probably a really simple thing to figure out but i am drawing a blank on how to do it. Basically I am trying to use single quotes or special characters when inputting data into my db but i have errors that come up. with the single quotes if I put in a name like de'salla or I use it in a contraction like it's, her's etc it will store in my db but when I try to use the data in another string or query I always get an error with php where it breaks on the single quote and won't continue to process the request. So I have 2 variables $name = De'salla; $reason = "Update for user $name"; When I go to insert the value Reason the query will error out becasue the $name value has a single quote in it. This is the basic issues and I know you might need more info but I am wondering is there a php function out that that i can use to correct this issue. Thanks Bill
  6. blargh..... Thanks for finding that.. I thought I caught all the errors... Hopefully that fixes it.
  7. here is the form code <?php echo "<table border='0'>"; echo "<tr><td align='right'>"; echo "<b>First Name:</b>"; echo "</td><td><p>"; echo "<input type='text' name='firstname' size='20' value='$firstname'>"; echo "<font color=red>*</font></td></tr>"; echo "</td></tr>"; echo "<tr><td align='right'>"; echo "<b>Last Name:</b>"; echo "</td><td><p>"; echo "<input type='text' name='lastname' size='20' value='$lastname'>"; echo "<font color=red>*</font></td></tr>"; echo "</td></tr>"; echo "<tr><td align='right'>"; echo "<b>Street Address:</b>"; echo "</td><td><p>"; echo "<input type='text' name='address1' size='50' value='$address1'>"; echo "</td></tr>"; echo "<tr><td align='right'>"; echo "<b></b>"; echo "</td><td><p>"; echo "<input type='text' name='address2' size='50' value='$address2'>"; echo "</td></tr>"; echo "<tr><td align='right'>"; echo "<b>City:</b>"; echo "</td><td><p>"; echo "<input type='text' name='city' size='30' value='$city'>"; echo "</td></tr>"; echo "<tr><td align='right'>"; echo "<b>State/Province/Territory:</b>"; echo "</td><td><p>"; echo "<input type='text' name='state' size='30' value='$state'>"; echo "</td></tr>"; echo "<tr><td align='right'>"; echo "<b>Zip Code:</b>"; echo "</td><td><p>"; echo "<input type='text' name='zipcode' size='10' value='$zipcode'>"; echo "</td></tr>"; echo "<tr><td align='right'>"; echo "<b>Country:</b>(US or Canada)"; echo "</td><td><p>"; echo "<input type='text' name='country' size='10' value='$country'>"; echo "</td></tr>"; echo "<tr><td align='right'>"; echo "<b>Phone Number:</b>"; echo "</td>"; echo "<td><p>"; echo "<input type='text' name='phone' size='12' value='$phone'>"; echo "</td></tr>"; echo "<tr><td align='right'>"; echo "<b>Email Address:</b>"; echo "</td><td><p>"; echo "<input type='text' name='email' size='30' value='$email'>"; echo "<font color=red>*</font></td></tr>"; echo "</td></tr>"; echo "<tr><td align='right'>"; echo "<b>User Access Level:</b>"; echo "</td><td><p>"; if ($_SESSION['user_rights'] == '2') { echo " <input type='radio' name='access' 'value='1' checked>Player "; } if ($_SESSION['user_rights'] == '3') { echo " <input type='radio' name='access' 'value='1' checked>Player <input type='radio' name='access' 'value='2'>Staff Admin "; } if ($_SESSION['user_rights'] == '4') { echo " <input type='radio' name='access' 'value='1' checked> Player <input type='radio' name='access' 'value='2'> Staff Admin <input type='radio' name='access' 'value='3'> Chapter Owner <input type='radio' name='access' 'value='4l'> Global Admin "; } echo "</td></tr>"; echo "</td></tr>"; echo "</tr></table>\n"; ?> I don't see any problem with the form code but then again this is all a test system so I can work out bugs. As I said Firefox processes everything fine so what is different with IE that could cause 1 variable to not translate over properly. And if it doesn't transfer over why isn't it reading the line I posted above to default to the lowest value to make sure things are added correctly?
  8. I am having an issue with my code and IE. What is happening is this is an add new user script for my site. When their info is added if I am using firefox it works fine but if I am using IE it is not getting the access level like it should and that throws off everything. I think this line is what is causing me the issue. $access = isset($_POST['access']) &&!empty($_POST['access']) ? $_POST['access'] : '1'; I added this in to check to make sure that if the "access" did not transfer over from the form it would default to the lowest level. but for some reason when an admin uses IE it doesn't read this line, so it skips the code and goes on to the next step which throws everything off. Any suggestions on what I can try with IE or any settings i should look at in IE. Thanks Bill
  9. cool thanks for the info I will try that out.
  10. Hello all, I am having a minor issue with my scripts when I have php pull data from mysql. Some times data put into the table have ' or " included in the text. So when php pulls that data and I include the variable I get a php error check the manual message. example: I am working with names the the following names are put in the table John Mike Joshua M'ekal So I am workign with the data and I need to add a note to the system that includes the names so I have something like this. $note = "order was updated for $name"; I then insert this into the table. Everything works just fine until it gets to the last name in the list. Then I get this error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ekal')' at line 1 So what I am wondering is there a way to turn the variable into a string so the ' stops kicking out this error anytime I try to insert it into a table? Any info or suggestions would be appreciated. Thanks Bill
  11. Thanks again but it wasn't an issue with my css... grr i had an issue on one of my pages in the html layout so that caused a problem with the layout.... sigh.... i feel silly now... Bill
  12. Thanks for the feedback.. I am using padding not the margin option along with 4 div's so that might explain the issue i am having with IE. Thanks for the info I appreciate it. Bill
  13. converting it over is pretty simple. I had to change my frames to css to help my site out. Are you asking for advise or looking for someone to code it for you? My advice is to use div tags, this is kinda like using frames and allows you to control the size and location but you will have to make sure to include requirements for the different browsers out there. Hope that helps ya Bill
  14. Hello All, I am still pretty new to css and I have a few issues/questions. 1) Do you have to write multiple CSS pages for different browsers or can you write one page that all browser can use. - My pages work fine in Firefox but IE the layout is off. 2) how can you setup a page break with a css page. I have tried to do this and it just isn't working for me. I figure all the issues are probably a mistake in my code so any suggestions on what to look at or a resource that will help teach me what to do properly woudl be appreciated. Thanks Bill
  15. cool thanks for the suggestion.. I think I got it fixed.
  16. Hello All, I am still new to coding but since i moved from php4 to php5 i am encountering some minor errors but things i want to fix. Like right now I am getting the error Notice: Undefined variable: canhave in /home/nerodbc/public_html/test/charfun.inc on line 205 now this is a function that I am callign from another file. So the main file starts off like this. $query = "SELECT * FROM skill_info where skillType = '3'"; $result = mysql_query($query) or die (mysql_error()); echo "<table border='0'>\n"; while ($row = mysql_fetch_array($result)) { extract($row); $cost = getskillcost($skillID, $classid, $raceid); $chkcost = checkcost($cost, $cid); if ($chkcost == 1) { echo "<tr><td>\n"; $preq= explode(",",$prereq); foreach ($preq as $value) { if ($value == $n) { echo "<a href='home.php?action=addskill&skillID=$skillID'>$skillName</a> ($cost)"; } if ($value != $n) { $canhave = checkprereq($skillID, $cid, $value); if ($canhave==1) { echo "<a href='home.php?action=addskill&skillID=$skillID'>$skillName</a> ($cost)"; } } } } echo "</td></tr>\n"; } The function looks like this. function checkprereq($skillID, $cid, $value) { $query = "SELECT * FROM skill1 where cid = '$cid' order by skillID"; $result = mysql_query($query) or die (mysql_error()); while ($row = mysql_fetch_array($result)) { $prereq = $row['skillID']; if ($value == $prereq) { $canhave = 1; } if ($skillID=='27' || $skillID =='28') { if ($prereq=='18' || $prereq=='19' || $prereq=='22' || $prereq=='23' || $prereq=='30' || $prereq=='31') { $canhave = 1; } else { $canhave = 0; } } return $canhave; } I have looked this code over and I can't see where there might be an issue. I can't see why it is not defining the variable $canhave.. just a bit confused. any suggestions would be appreciated. Thanks Bill
  17. LOL... now I feel stupid... I can't believe I made that mistake. Thanks for catching it guys I appreciate it... now time to go rewrite all my buttons.. Thanks again Bill
  18. ok so now I have an issue where I am working with php5 and things aren't working. basically I am using an html form with a hidden value to tell the program what set of code to use but the hidden values aren't being read once I hit the submit button. here is a bit of code <div id='header'><br></div><div id="main"> Please Select the Chapter you would like to access from the list. <form action="home.php" method="POST"> <?php include ("allchapter.inc"); ?> <input type="hidden" name="action" value="actualswitch"> <input type="submit" value="Chapter Switch" name="esubmit"> </form> </div> so after this form is submitted I would get a blank page. I added the following line to home.php to see if the results would change. $action = !empty($_GET['action']) ? $_GET['action'] : 'main'; so now when i submit the form it goes to the main option and not the one I have as a hidden value. any idea why the value wouldn't be passed or why it is not being read? I know this is a simple thing just can't figure it out at the moment. any help is appreciated Thanks Bill
  19. blargh.. why didn't i think of that.. completely forgot I had to use $_GET instead of just assuming that the value would be used... sigh... Thanks for the help... it's been a long day...
  20. Ok so as the title stated I am passing an action in the url and I programmed everything in php4. now I am working with php5 and I can't figure out how to correct it. For example once the users selects to logout I have the following code set up session_unset(); session_destroy(); $_SESSION = array(); header("Location: index2.php?action=logout"); So as you see from the code I redirecting to another page and using an action to specify what I want it to do but once it goes to the page all I get is a blank screen. The next set of code is from index2.php with the action. if ($action ==='logout') { echo "<table align='center' border='0' width='25%'><tr><td> <font color=red><b>Thank you for using the NERO National DB.</b></font></td></tr> <tr><td><font color=red><b>You are now logged out.</b></font></td> </tr></table>"; include ("index.php"); } As you can see the if statement comes up and looks for the action result. I know with php4 if I used 3 of the equal signs the system would process the request correctly. I know something has changed but I don't know what and I am a bit frustrated right now. If someone would tell me what I can do to get this to work with php5 I would appreciate it. Thanks Bill
  21. Ok figured it out.. seemed that because the query variables were the same ($query, $result, $row) it would knock out my initial request now it works with no problems...
  22. Hello All, So I am a bit confused about something and cant figure out how to fix it.. I am working with a db of user data. What I am trying to do is pull up the info and collecting data from other tables as well. The issue I am having is when I get the info based on the group id all the basic info will come up and the entire list of user data I want to get comes up no problem. When I try to add in the other code to get the info from other tables that i want it just stops at the first record. So when I do the first step of gathering the data i want and displaying it on the screen, here is the code. <html> <body> <?php include ("misc.inc"); include ("functions.inc"); include ("charfun.inc"); $query = "SELECT * FROM characters INNER JOIN id ON characters.id = id.id where id.chid='$chid'"; echo "<table>"; $result = mysql_query($query) or die (mysql_error()); while ($row = mysql_fetch_array($result)) { echo "<tr><td>"; extract($row); $cname = "$firstname $lastname"; $uid = $id; $classid=$clas; $armor = getarmor($cid, $classid); $gobbies = getgoblinpoints($uid); $racename = getracename($race); $classname = getclassname($clas); $pname= getplayersname($uid); $chname = getchaptername($uid); $notes=getnotes($cid); $email = getemail($uid); echo "<table width=100% border='1'> <tr><td align ='center'> <table><tr><td><big><big><big><b>NERO $chname Character Sheet</b></big></big></big></td></tr></table> </td></tr> <tr><td align ='center'> <table><tr> <TD ALIGN='right'><small><b>Player's Name: </b></td> <TD ALIGN='left'><small>$pname</td> <TD ALIGN='right'><small><b>Member's ID: </b></td> <TD ALIGN='left'><small>$uid</td> <TD ALIGN='right'><small><b>E-Mail Address: </b></td> <TD ALIGN='left'><small>$email</td> <TD ALIGN='right'><small><b>Goblin Points: </b></td> <TD ALIGN='left'><small>$gobbies</td> <TD ALIGN='right'><small><b></b></td> <TD ALIGN='left'><small></td> </tr></table> </td></tr> <tr><td align ='center'> <table><tr> <TD ALIGN='right'><small><b>Character's Name: </b></small></td><TD ALIGN='left'><small><b>$cname</b></small></td> <TD ALIGN='right'><small><b></b></td> <TD ALIGN='left'><small></td> <TD ALIGN='right'><small><b></b></td> <TD ALIGN='left'><small></td> </tr><tr> <TD ALIGN='right'><small><b>Race: </td><TD ALIGN='left'><small>$racename, $subrace</td> <TD ALIGN='right'><small><b>Build: </td><TD ALIGN='left'><small>$build</td> <TD ALIGN='right'><b><small>Body: </td><TD ALIGN='left'><small>$body</td> </tr><tr> <TD ALIGN='right'><b><small>Class: </td><TD ALIGN='left'><small>$classname</td> <TD ALIGN='right'><b><small>Free Build: </td><TD ALIGN='left'><small>$freebuild</td> <TD ALIGN='right'><b><small>XP: </td><TD ALIGN='left'><small>$xp</td> </tr><tr> <TD ALIGN='right'><small><b>Level: </td> <TD ALIGN='left'><small>$level</td> <TD ALIGN='right'><b><small>Max Armor: </td> <TD ALIGN='left'><small>$armor</td> <TD ALIGN='right'><b><small>Deaths: </td> <TD ALIGN='left'><small>$deaths</td> <td></td> </tr></table>"; //Place holder for other code. echo" </td></tr> </table> </td></tr>"; } echo "</table>"; ?> </body> </html> So with the above code it does the loop and pulls all the info as needed. Now If I add the following in to the code it just stops on the first record. <?php // code goes where the place holder line is at. <tr><td align ='center'> <table><tr> <td align='center'> <table width=100% align='center'><tr><td align = 'center'><big><b>Fight/Weapon Skills</b></big></td></tr></table> </td> </tr><tr> <td> <table width=100% align='center'><tr><td align = 'center'>"; echo "<table><tr><td align = 'center'><small><b>Weapons and Armor</b></small></td></tr></table>"; $query = "SELECT * FROM skill1 where cid = '$cid' and type = '3' ORDER BY skillID"; $result = mysql_query($query) or die (" Line 1 Query failed due to: ".mysql_error()); echo "<table>"; while ($row = mysql_fetch_array($result)) { extract($row); echo "<tr> <td align = 'center'><small>$skillName</small></td> </tr>"; } echo"</table>"; echo"</td></tr></table> </td> </tr></table> </td></tr> I have more code but the loop stops at anyone them so i just included this one to see if someone could explain why it would happen and what i am doing wrong with the scripts to pull the info. I know the layout might look off but this is not complete code I am just cutting and pasting what works and what happens when I add in the new code. Any suggestions would be appreciated. Thanks Bill
  23. ok I am a bit confused but then again I am still trying to figure this out.. If I am posting an array as this bit of code shows. foreach($_POST['cid'] as $cid){ //do whatever If I understand it correctly wouldn't the foreach loop through all the values in the array or would I need to right another loop. I can see how this would work but for some reason I just can't grasp how to make sure the id is passed so the include file has access to it and can preform its query.. Also I have tried this code and get You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 I know I am missing something simple but just cant see it right now... Anyway thanks for the suggestion and any other advice you could provide would be appreciated. Thanks Bill
  24. Hello All, I am working on bringing up a list of users and have a checkbox attached to the user id. What I want to do is let an admin go through the list and check as many users as they want and then when they submit the form have it pull up the information of the selected users. The issue i am having is that the script only brings up one user and nothing else. Form Code <form action="home.php" method="POST"> <?php //this pulls all members and characters to add build to their character. $chid = $_SESSION['chapter_id']; $query = "SELECT * FROM demographics, id where id.id = demographics.id AND id.chid='$chid' AND id.accesslvl='player' ORDER BY demographics.lastname, demographics.firstname"; $result = mysql_query($query) or die (mysql_error()); echo "<table border='1' cellspacing='15'>"; echo "<tr><td colspan='12'><hr></td></tr>"; echo "<tr><td></td><td>Players Name</td><td>Character Name</td></tr>"; while ($row = mysql_fetch_array($result)) { extract($row); $pname= getplayersname($id); $query1 = "SELECT * FROM characters where id = '$id'"; $result1 = mysql_query($query1) or die ("Couldn't execute query 36."); while ($row1 = mysql_fetch_array($result1)) { extract($row1); $cname= getcharname($cid); echo "<tr><td><input type='checkbox' name='cid_$cid' /></td><td>$pname</td><td>$cname</td></tr>\n"; } echo "<tr><td colspan='12'><hr></td></tr>\n"; } echo "</table>\n"; ?> <input type="hidden" name="action" value="apmcharsheet"> <input type="submit" value="Print Multiple Character Sheets" name="esubmit"> </form> As the code shows it limits the results to the specific group and if the user is listed as a "player". This works with no issues. Result script $query = "SELECT * FROM characters"; $result = mysql_query($query) or die (mysql_error()); while ($row = mysql_fetch_array($result)) { extract($row); $cid = $row['cid']; if ($_REQUEST['cid_' . $cid] != '') { include ("charsheet.php"); //echo "<p style='page-break-before: always'>"; - commented out to test main objective } } When I pass the info as I stated above I only get one result. The code above is the original script I tried. I thought if I changed variables or tried to change the "REQUEST" up it might work but nothing it still just pulls up 1 user. Also looking at this script I added the page break as I wanted to have the info separated to separate pages if the admin wanted to print out the info. So what I am looking for is a few things. 1) help in pointing me in the right direction. 2) Figuring out how to get multiple requests to process and show up instead of just 1. 3) Figuring out how to get the results to open in a new window not the main window. 4) making sure the page break works. Any suggestions or help is appreciated. Any advice on what I can try or a mistake I made would be appreciated. Thanks Bill
  25. Hello All, I am trying how to figure out how to open a new window when processing a html form with php variables. I know how to make a link open a new window with passing a php variable to get the specific results I want.. <a href='blanksheet.php?id=$id' onclick='window.open(this.href); return false;'>Print Sheet</a> But What I would liek to do is set up a form something like a compare screen where you can check on the items you want and it will bring those items up on a single page. My goal is to make the form with multiple items and then when the user clicks submit they are taken to a new window where the request is processed. I think this would be controlled by the form setup and the buttons but I haven't found any info on this and am hoping someone might have an idea that i can look into. Not sure if this is considered an html or php question but any help would be appreciated. Thanks Bill
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.