-
Posts
2,965 -
Joined
-
Last visited
Everything posted by mikesta707
-
[SOLVED] printing individually selectable mysql rows to screen
mikesta707 replied to debuitls's topic in PHP Coding Help
you have an extra square bracket around your $row array's key. this \"window.location='/results.php&id=$row['[proposalid']'\" should be \"window.location='/results.php&id=$row['proposalid']'\" Hope that helps! EDIT: another thing, you must escape the single quotes, or concatenate the array entry to the string. \"window.location='/results.php&id=$row[\'proposalid\']'\" or \"window.location='/results.php&id=" . $row['proposalid'] . "'\" -
hmm try a print_r on the $row array and see what you get
-
Need help Placing Multipple lines in...(simple question)
mikesta707 replied to blesseld's topic in PHP Coding Help
you can save the file's HTML as a variable, and use the javascript innerHTML method to put the table inside the DIV. but i'm afraid I don't really understand what you want to do -
Need help Placing Multipple lines in...(simple question)
mikesta707 replied to blesseld's topic in PHP Coding Help
just write a table in there? <? if ( $page_id == "4" ) { ?> <div id="our-services-box"><table><tr><td>I'm a table!</td></tr></table></div> <? } else { ?> <? } ?> -
also, a few things I forgot to say. Whenever you would pass the object to a new variable, you need to re-initialize the object. And remember to include the file with the object's class in every page. so for example this wouldn't work: <?php session_start(); include "class.php"; $object = new Class(); $object->function(); $_SESSION['object']=$object; ?> page2.php <?php session_start(); $object = $_SESSION['object']; $object->function(); ?> this would work: <?php include "class.php"; session_start(); $object = new Class(); $object->function(); $_SESSION['object']=$object; ?> page2.php <?php include "class.php"; session_start(); $object = new Class(); $object = $_SESSION['object']; $object->function(); ?> also remember to include the page before you start the session.
-
how exactly is it not working. the form is submitting to the page cal.php, is that correct?
-
highlighted incorrect responses bases on PHP/MySQL results data
mikesta707 replied to webguync's topic in PHP Coding Help
the mysql_fetch_array and mysql_fetch_assoc functions can get the data from your mySQL resource and turn it into an array fetch array: http://us.php.net/manual/en/function.mysql-fetch-array.php fetch assoc: http://us2.php.net/mysql_fetch_assoc -
assuming that your $row array is 1 dimensional, couldn't you just do $query = mysql_query("SELECT * FROM final WHERE `0` = '0'") or die(mysql_error()); while ($row = mysql_fetch_assoc($query )) { echo key($row).'<br />'; }
-
yep that should be fine. You may want to make sure that you set the session again after you use the object, IE $userinfo = $_SESSION['user']; $userinfo->fname; $userinfo->update(whatever) //other stuff with userinfo $_SESSION['user'] = $userinfo; because variables inside the object may change, and you want to make sure that your session object is up to date. I believe you can also just use the session instead of copying its value to a variable, IE $_SESSION['user']->update();
-
you can just pass the object as a whole
-
highlighted incorrect responses bases on PHP/MySQL results data
mikesta707 replied to webguync's topic in PHP Coding Help
Oh ok sure. $wrong = array(1, 4, 3, 10);//You will get this from your table, but for simplicities sake $answers = array("16", "25", "88", etc. etc.);// again you will get this from your table //im assuming your answers array is numeric foreach($answers as $key => $value){ if (in_array($key, $wrong)){ $class = "wrong"; } else { $class="correct";//or whatever your right answer class is } echo "<td class=\"$class\">$value</a>";//or whatever you want to output. } this is a basic example. obviously yours will be different, but the basic logic is there -
instead of instantiating the object each time (which would make the class kind of worthless in my opinion) you could just make a session to hold the object, and use that whenever you need to do user based actions
-
highlighted incorrect responses bases on PHP/MySQL results data
mikesta707 replied to webguync's topic in PHP Coding Help
ahh ok, So if you have an array of all the answers, you can iterate through that array to display the answers, and then have an array with all the wrong answers, and use the in_array() function to tell whether or not to highlight the text -
oh, I wondered why you had that like at the end
-
you need single quotes around the keys of associate arrays. so this where id='$row[id]' shoule be where id='" . $row['id'] . "' Hope that helps!
-
ok so it is an array. Again, WRAP YOUR CODE IN CODE TAGS. now before you go into any of the foreach statements, write print_r($_POST['shows_Selected']) and see what it says. You are making sure that you have something selected right?
-
[SOLVED] problem with inserting data in mysql database
mikesta707 replied to aldm's topic in PHP Coding Help
try using $_POST[] instead of $HTTP_POST_VARS[] -
none of those errors have anything to do with the print_r function. it is clear that none of the foreach statements have an array as their supplied argument. It appears that the post data is not an array. post the part of the form that shows the checkboxes. if you only have 1 check box.. then it won't be an array.
-
highlighted incorrect responses bases on PHP/MySQL results data
mikesta707 replied to webguync's topic in PHP Coding Help
ahhh ok. so in your database does it just have the answers, or does it have the answers, and which are wrong and which are right? -
there are two sql queries in that code. which one is running the error?
-
there is a function called print_r(). print_r($media_array); what happens when you run that
-
[SOLVED] Use WHERE to use 2 different columns to extract a result
mikesta707 replied to 28rain's topic in PHP Coding Help
instead of && use AND -
highlighted incorrect responses bases on PHP/MySQL results data
mikesta707 replied to webguync's topic in PHP Coding Help
well you would have to have a function called wrong that detects if the answer is wrong or not. However you determine if the answer is wrong you would put in that if statement. How do you determine when an answer is wrong? -
... thats not how you wrap code in code tags but whatever... so line 73 is an empty line? I still don't quite understand. Is like 73 the one below where you indicated? ill assume that line 73 is the foreach two lines below where you indicated. do a print_r on the $media_array variable and see what you get
-
highlighted incorrect responses bases on PHP/MySQL results data
mikesta707 replied to webguync's topic in PHP Coding Help
if (wrong($answer)){ $class = "wrong"; } echo "<td class=\"$class\">"; ?