Jump to content

WebStyles

Members
  • Posts

    1,216
  • Joined

  • Last visited

Everything posted by WebStyles

  1. I really don't see what the problem is, if you have a filed called 'pic' where you store the image name (or name and path), simply display it with everything else. for the purpose of this example, I'll assume you are only storing the image name in the database and that you have a folder called 'bandImages' (or whatever) change <? echo $row["pic"]; ?> for this: <img src="bandImages/<? echo $row["pic"]; ?>"> hope this helps
  2. Since you do not have a database for tracking the users votes yet, and seeing an html page does not give me access to your php code, that really does not help me understand better. Create a table in the database like I said, with whatever extra info you might want to store, I suggest: table: userVotes id, questionID, userID, vote, date, time, ip and then do what I suggested: everytime a user votes on a question, insert a line in that database (the vote filed is to store 1 or -1 depending on the vote) then, when you load the page, you can count all the votes for each question and also track if a certain user has already voted.
  3. How do people get to vote on the questions? do they have to be registered and logged in? if so, you can store whatever questions they have already voted for in a database (i.e database with: userid, questionid). then, whenever a user tries to vote on a question (or before you display the questions to the user, whichever way you prefer) you check that database for matches. if there is a match, it means the user has already voted. ... and, of course, when a user votes, you insert userID + questionID in the database. You can also store the users answer, date, time, etc... May be useful later. Hope this helps
  4. maybe something like this (comments explain my logic. Untested code off the top of my head) <?php // added a 'distinct' clause, just because there's no point in pulling out duplicates $items = odbc_exec($odbc, "SELECT distinct keywords FROM faq WHERE visible = 'true'") or die (odbc_errormsg()); // start my empty string $kwords = ''; while ($detail = odbc_fetch_array($items)){ // I'm assuming database can return more than one result, // so I'm ading them all in a string first $kwords .= " ".$detail['keywords']; } // explode all words into single array $allWords = explode('',$kwords); // get unique words $unique = array_unique($allWords); // show me echo '<pre>'; print_r($unique); echo '</pre>'; ?>
  5. If you mean when a new window is opened (popup) and you want to hide all the browser buttons, no, you cannot do it with Php. Since the browser is installed on the client computer, the control over it is client-side, and php is a server-side language, therefor, you need to use javascript to open a popup. Hope this helps
  6. Let me ask that again: What exactly is the problem? What has gone wrong? What errors are you getting? What is not working?
  7. well that's a bit vague, don't you think? What exactly have you done so far, and what has gone wrong?
  8. I actually didn't say that. I said if checked it would send 1, if not checked it wouldn't even be posted with the form. From what I see in your code, you need to understand some other things first. An array will hold several values. These values all have a key so that you can access them. as in $var = array("A","B","C"); $var[0] would be A (the key is 0), $var[1] would be B (the key is 1)... etc. These keys can also be names, so I could do this: $var = array("key1"=>"A","johnny"=>"B","SimpleSimon"=>"C"); $var['SimpleSimon'] would be C, $var['johnny'] would be B... etc. Keeping this in mind, I could say that $var['johnny'] = array("A","B","C"); (instead of it's current value that is B. Now johnny is an array inside or another array ($var). $var['johnny'][1] would be B. now look at your code again and think about this... if( isset($_POST['core[]']) ){ what you want to find out with that is if the array called core exists in the $_POST variable. Even though core is an array, you access it by it's name only, so if( isset($_POST['core']) ){ is the correct code. The fact that the array core exists, does not mean it has any data, so you can check that with: if( isset($_POST['core']) && !empty($_POST['core']) ){ ... so far so good... but now you have another problem. You told your html form, that there would be an element named core and it would be an array (core[]). this means that when core gets posted, the values in it will be in indexed from 0 to .. whatever $_POST['core'][0] $_POST['core'][1] $_POST['core'][2] ... How will you know which is the one you need? Either you're only sending 1 in each POST, and in that case $_POST['core'][0] will always be the correct one, but that also eliminates the need for core to be an array, and all this conversation would be a waste... Or you can add the module code to it, so that you can use it as the key to check if the checkbox was clicked or not, like this: $category_list .= '<input type="checkbox" name="module[]" id="module[]" value="'.$moduleID.'" /> <input type="checkbox" name="core['.$moduleID.']" value="1" /> '.$catName.'<br>'; Now you know, that when it gets posted, the final result can be accessed with: $_POST['core'][<MODULEID>]... since you're already looping through $_POST['module'] with your foreach loop, what you need to do is something like this: foreach($_POST['module'] as $cats){ if( isset($_POST['core'][$cats]) ){ Get it? you will be using each ModuleID as a key to access your core[] array. And if $_POST['core'][$cats] exists, it's value will always be 1. (as I told you before, unchecked checkboxes do not get sent in the form, so they do not exist) Hope this helps (and that it makes sense)
  9. in that case, I'm guessing your database password field is not long enough for md5 hashes and they're being truncated (cut off) when inserted. You need 32 characters to store an md5 encrypted string. check if password field is varchar (32)
  10. try something like this (untested) I removed the second $_POST from inside the function, <?php function AssignReps ($depart_id, $shift_id, $task_id){ echo '<p>Please Assign Reps to '.$task_id.'</p>'; $realID=SelectEmps($depart_id, $shift_id) ; $friendlyname= DisplayEmpNames($realID); echo '<form method="post" action="" name="testform">'; $menu= createDropdown($realID, "name", $friendlyname); print_r($menu); echo '<input name="assign" type="submit" value="Continue" />'; echo '</form>'; } if(isset($_POST)){ if(isset($_POST['assign'])){ $submission= isset($_POST['name']) ? trim($_POST['name']) : die('Missing entry: Rep Selection'); echo $submission; $myFile = $task_id."file.txt"; file_put_contents($myFile,$submission); }else{ $shift_id= isset($_POST['shift']) ? trim($_POST['shift']) : die('Missing entry: Shift Selection'); $depart_id= isset($_POST['department']) ? trim($_POST['department']) : die('Missing entry: Department Selection'); $task_id= isset($_POST['task']) ? trim($_POST['task']) : die('Missing entry: Task Selection'); AssignReps ($depart_id, $shift_id, $task_id); } } ?>
  11. just try something like: $emote[1] = ""; $emoteimg[1] = "lol.gif"; $emote[2] = ":S"; $emoteimg[2] = "caring.gif"; $msg = " hahahahaha very funny :S"; foreach($emote as $k=>$e){ $msg = str_replace($e,'<img src="emos/'.$emoteimg[$k].'" />',$msg); } echo $msg;
  12. ok, try this: remove and password='$password' from your $query then go back to your original code and change this: if (mysql_num_rows($result) != 1) { //$error = "Bad Login"; echo "Bad Login"; } for this: if (mysql_num_rows($result) != 1) { //$error = "Bad Login"; echo "Bad Login: Cannot find that email"; }else{ echo "Must be wrong password"; } Also, keep in mind that mysql_num_rows($result) != 1 checks to see if the result is 1 row. If that emails exists more than once in the database this will also fail because num_rows will be 2 or more. Hope this helps
  13. all I can suggest is replicate what I did. If it works for me, it HAS to work for you. Delete database, create new one, set variables manually, test. this is the code I used: (the only thing that's different is that I use a function to handle the database connection) require_once('_conn.php'); $conn = conn('phpfreaksTests'); $a = 'testing'; $b = 'O'; $c = '19.99'; $d = 'Test Description'; mysql_query($sql = "INSERT INTO kb_services (serv_text,serv_freq,serv_cost,serv_desc,serv_type) VALUES ('$a','$b','$c','$d','D')",$conn); @mysql_close($conn);
  14. since it worked fine for me, the only thing I can think of is maybe your database is not the EXACT same as the CREATE TABLE code you posted here. I basically, dumped that into phpmyadmin, created the database, copied your code, set the variables manually, and everything worked. That's about all I can suggest right now.
  15. you can use something like foreach($projects as $key=>$value){ ... }
  16. yep. unless I'm missing something, code seems fine to me. what exactly is the error? you just asked if there was anything wrong but you never told us what was happening when you try to login. are you sure the stored passwords were also encrypted with md5() ? are you sure you're using the correct password? set one of the passwords to 123, remove the md5() line and test again just to be sure.
  17. it worked for me. (your exact same code) except I set $a,$b,$c,$d variables manually (so I wouldn't have to create a page to post stuff. could you, by any change, have a copy of the database for test reasons, and are connecting to the wrong one?
  18. use a hidden element with a different set of id's that will allow you to index the real id in your session array.
  19. still, the problem will be the same. how do you know which record was selected by the user if you do not POST some sort of identifier?
  20. No prob. Glad I could help out. The only websites I use are php.net and google. This is not really an 'area' of php. it's about programming logic. the code I gave you: $percent = $row['played'] > 0 ? round($row['points']/$row['played']*100, 2) : 0; is basically shorthand for this: (EXACTLY THE SAME THING) if($row['played'] > 0){ $percent = round($row['points']/$row['played']*100, 2); }else{ $percent = 0; } basically you set the $percent variable to whatever you want, and always display the same html code (since the only difference was the $percent, it's easier to just display it anyway, than to repeat all the html for each condition)
  21. yeah, I got that, but to pass it through the session, first you need to know what it is, then you need to place it in the session. so you use the hidden field so you can grab it and place it in the session, otherwise how do you know which one was selected by the user?
  22. Please be more specific. what exactly is not working? what error are you getting? Does it do nothing? does it give an error? does it redirect to the wrong page? header("Location: $url"); is fine, as long as there has not been any output yet, otherwise you'll get an error saying "headers already sent" or something of the sorts. are you sure $url is the correct address? Where is that variable coming from? (I don't see it in the code) echo $url just to be make sure it's correct. or change it to header("Location: http://www.google.com"); just to test. Also, consider tidying the curl stuff and the redirect into a function, since you'll be calling it several times until it evaluates to TRUE. turn on php errors and post error here.
  23. just add a hidden element with the id: <form action='' method='post' name='fr'> <input type='image' src='images/edit.png' name='task' value='Edit' /> <input type='hidden' name='ElemID' value='123' /> </form>
  24. if > is displaying correctly, simply convert the values of the variable before displaying them, but leave the original variable intact so it gets posted correctly. Something like: $hello ='<vvvvv>'; echo htmlentities($hello); EDIT: * Opppss. Seems MrAdam beat me to it. There you have it, 2 people saying the same thing, means it will work.
  25. you can try something like: instead of this: <input type="radio" name="color" value="yellow" />Yellow $19.99</td> add the price to the value that gets posted: <input type="radio" name="color" value="yellow 19.99" />Yellow $19.99</td> ... when it's posted, grab the value and split it where the space is: $color_and_value = explode(" ",$_POST['color']); $selectedColor = $color_and_value[0]; $selectedPrice = $color_and_value[1];
×
×
  • 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.