Jump to content

Elridan

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Elridan's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I've figured out the problem. The code would only run once with the same values under the same session. After inserting session_start() and session_destroy() at the beginning and end of the actual edit code it works just fine.
  2. if you are working on a larger project, such as one where you figure out the databse beforehand, how do you decide what you need in the database? I'm working on my first PHP project and I've made alot of progress on it (to me anyways) having never used php or mysql before, but I've had to start with a basic mysql database and table and work my way from there. I didn't know what I would need beforehand so I just kept adding things and revising things as needed until I got to where I am now (which is probably very near to it's final design). Is this something that just starts coming to you as you work with more and more databases?
  3. I hope I'm not leading you completely astray, and if I am I hope someone comes by and tells me how wrong I am and why. I'm not sure if this code would work, I haven't been working with PHP for very long, but this is what I thought about when you told me your problem: page.php?countryid=10 <? $countryid = $_GET['countryid']; $query = "select arena, arenaid from database where countryid = '".$countryid."'"; $result = mysql_query($query); $numrows = mysql_num_rows($result); $i = 0; while ($i < $numrows) { $arenano = $i+1; $arena = mysql_result($result, $i, "arena"); $arenaid = mysql_result($result, $i, "arenaid"); $slct = "arena".$arenano; $$slct = "<option value = '".$arenaid."'>".$arena."</option> "; $slcts .= ".arena".$arenano; $select = $$slcts."."; i++; } echo " <div class='field required'> <label for='arena'>Arenas</label> <select class='dropdown' name='arenas' id='arenas' title='Arenas'>" .$$select. "</select> <span class='required-icon tooltip' title='Required field - This field is required, it cannot be blank, and must contain something that is different from emptyness in order to be filled in. '>Required</span> </div>"; ?> The code *should* get the arenas and generate a variable containing a select tag with each arena in it. It then creates another variable that contains all the option tags. Afterwords the variable is inserted between the select statement. Hopefully this works the way I think it does, and if not hopefully it at least gives you an idea of what you want to do. edited: modified code
  4. I just did something similar where I just supplied the values.
  5. I would look into getting an ODBC driver for Access and connecting to it that way. Here is the manual for ODBC Functions and a possible driver; I've never done it myself. http://www.php.net/manual/en/ref.uodbc.php http://www.easysoft.com/products/data_access/odbc-access-driver/
  6. One more minor error fix Thanks for that, completely missed it.
  7. @upp I may be wrong, but I think he was looking for this: <?php $input_value = 'a tall order'; if ( $input_value == 'a tall order' ) { echo 'Correct!'; } elseif ( $input_value = 'err on the side of caution' ) { echo 'correct!'; } else { echo 'Sorry, try again.'; } ?> Let us know teisenhood. As for the form part, are you posting back to the page or to another page? Either way: <form name="formName" action="page.php" method="post"> <select name="selectName"> <option value = "a tall order"> <option value = "err on the side of caution"> <option value = "Something Else"> </select> </form> ####page.php $input_value = $_GET['selectName']; ...etc.
  8. I'm working on a member modification page that works off of the javascript "onblur" method. Ideally the way I want it to work is when a person leaves the field they were in the second php script runs and returns to the page a value to the page. Right now it does just that with one problem - it won't run the attached script twice if the values are the same twice. For instance: If I'm tabbing through the fields several times for whatever reason and accidentally add an "a" to the name field one of those times, i realize this and want to go back to fix it. After I've fixed it I tab out and what should happen is the script runs, the new info is written to the databse, and the script returns new info for the page. What is currently happening is nothing - it doesn't seem to run the script. Using Chrome I see that it's executing the script but it isn't writing back to the page or updating the database. Any help or pointers I could get would be very welcome. Thanks! Scripts Below and attached: Member Edit Page: <?php $title = "TAPCO File Upload Data"; $top1 = "<!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> <meta http-equiv='Content-Type' content='text/html; charset=UTF-8' /> <title>"; $top2 = "</title> <link href='css.css' rel='stylesheet' type='text/css' /> <script type='text/javascript'> function attach_file( p_script_url ) { // create new script element, set its relative URL, and load it script = document.createElement( 'script' ); script.src = p_script_url; document.getElementsByTagName( 'head' )[0].appendChild( script ); } </script> </head> <body>"; $host="localhost"; // Host name $username="ftpuploads"; // Mysql username $password="password"; // Mysql password $db_name="ftpuploads"; // Database name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $unam = $_GET["unam"]; $q = "select * from members where username = '".$unam."'"; $r = mysql_query($q); $name = mysql_result($r, 0, 'name'); $email = mysql_result($r, 0, 'email'); $sp = mysql_result($r, 0, 'sp'); $sno = mysql_result($r, 0, 'sno'); $snow = "Sales Number: ".str_pad(mysql_result($r, 0, 'sno'), 3, 0, STR_PAD_LEFT); $fa = mysql_result($r, 0, 'fa'); $user = mysql_result($r, 0, 'user'); $admin = mysql_result($r, 0, 'admin'); $active = mysql_result($r, 0, 'active'); mysql_close(); if ($user == "0" && $admin == "1") { $disuoa = "Admin"; } elseif ($user == "1" && $admin == "0") { $disuoa = "User"; } else { die("Something is wrong, both admin and user have the same value"); } if ($active == "1") { $disactive = "Active"; } else { $disactive = "Inactive"; } if ($sp == "0") { $spcell = "<option value='1'>Yes</option> <option value='0' selected>No</option>"; } else { $spcell = "<option value='1' selected>Yes</option> <option value='0'>No</option>"; } if ($fa == "0") { $facell = "<option value='1'>Yes</option> <option value='0' selected>No</option>"; } else { $facell = "<option value='1' selected>Yes</option> <option value='0'>No</option>"; } if ($user == "0" && $admin == "1") { $uoacell = "<option value='User'>User</option> <option value='Admin' selected>Admin</option>"; } else { $uoacell = "<option value='User' selected>User</option> <option value='Admin'>Admin</option>"; } if ($active == "0") { $actcell = "<option value='1'>Yes</option> <option value='0' selected>No</option>"; } else { $actcell = "<option value='1' selected>Yes</option> <option value='0'>No</option>"; } echo $top1.$title.$top2; echo "<span id='disname'>".$name."</span><br /> <span id='disuname'>".$unam."</span><br /> <span id='disemail'>".$email."</span><br /> <br /><span id='dissno'>".$snow."</span><br /> <br /><span id='disuoa'>".$disuoa."</span><br /> <br /><span id='disactive'>".$disactive."</span><br /><br />"; echo "<form> <table> <tr> <td> Name </td> <td> Password </td> <td> Sales Person? </td> <td> Sales Number </td> <td> Full Access? </td> <td> User or Admin? </td> <td> Active? </td> </tr> <tr> <td> <input type='text' name='name' value='".$name."' onblur=\"javascript:attach_file('updatefield.php?span=disname&unam=".$unam."&fchan=name&val='+this.value)\" /> </td> <td> <span id='passres'><a href=\"javascript:attach_file('resetpassword.php?uname=".$unam."&email=".$email."')\">Reset and Send</a></span> </td> <td> <select name='sp' onblur=\"javascript:attach_file('updatefield.php?span=&unam=".$unam."&fchan=sp&val='+this.value, this.value)\"> ".$spcell." </select> </td> <td> <input type='text' name='sno' onblur=\"javascript:attach_file('updatefield.php?span=dissno&unam=".$unam."&fchan=sno&val='+this.value)\" /> </td> <td> <select name='fa'> ".$facell." </select> </td> <td> <select name='uoa'> ".$uoacell." </select> </td> <td> <select name='active'> ".$actcell." </select> </td> </table> </form> "; ?> updatefield page: <? $host="localhost"; // Host name $username="ftpuploads"; // Mysql username $password="password"; // Mysql password $db_name="ftpuploads"; // Database name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); header( 'Content-Type: text/javascript' ); $span = $_GET['span']; $username = $_GET['unam']; $fchan = $_GET['fchan']; $val = $_GET['val']; $q = "select ".$fchan." from members where username = '".$username."'"; $r = mysql_query($q); $fchanOrVal = mysql_result($r, 0, name); if ($fchanOrVal == $val) { die(); } else { $qu = "update members set ".$fchan." = '".$val."' where username = '".$username."'"; $ru = mysql_query($qu); echo "if ('".$span."' != '') { fchan_span_obj = document.getElementById( '".$span."' ); fchan_span_obj.innerHTML = '".$val."'; } else if ('".$span."' == '') { }"; } mysql_close(); ?> [attachment deleted by admin]
×
×
  • 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.