PHP - Simple Script To Show Written Text On Different Page
Hi there, Im working on my little project and I would appreciate your help. I have only basic knowledge of php, mostly I just copy some scripts that could be useful for me. Im trying to find some simple script that allows me to see the written text on web page no. 1 on webpage no. 2.. Something like send the form to email, except I dont want to send it on email, but different webpage. Something like different way of eshop, where you get your order shipped to email, but I wanna send this information to webpage. Is there such a script like Im describing? Probably is but I dont know how to search for this..
Thank You
Edited by Radim, 21 October 2014 - 07:15 AM. Similar TutorialsHello everyone, I'm exporting some mysql data to a text file. The data can be selected by checkboxes from a table. I want to format the text that will be in text file. How do I do that? This is my code: Code: [Select] <?php if ($_POST['exporttxt']) { for($i=0;$i<count($_POST['checkbox']);$i++){ $export_id = $checkbox[$i]; $text = mysql_query("SELECT code FROM tickets WHERE id='$export_id'"); $text = mysql_fetch_assoc($text); $text = $text["code"]; $filename = "export"; $filedate = date("Y-m-d"); $fileext = ".txt"; $fileall = $filename.$filedate.$fileext; ob_end_clean(); header("Content-Type: application/octet-stream"); header("Content-disposition: attachment;filename=\"$fileall\""); header("Content-Type: application/force-download"); header("Content-Type: application/download"); header("Content-Description: File Transfer"); header("Content-Length: ".strlen($output).";\n"); echo($text); } } exit(); ?> The data that will be exported are numbers containing of 16 digits. After every number I want to have a line-break. Also if possible I would like to have a space after 4 digits for every number, example: Number non-formatted: 1234567891234567 Number formatted: 1234 5678 9123 4567 How can I do that? Hello People. Please can someone point me to where I can learn to program the following all one one page? Here is a screenshot of what I'm after. Idea being that you put hours and minutes into the top row. Then hours and minutes into the next row. Click the button and get the answer at the bottom. The answer to 1 hour 40 minutes added to 1 hour 40 minutes should obviously be 3 hours 20 minutes. Here's how I would approach it in another language, but am brand new to php hence the help required. Make the following variables. Hour1 Hour2 Minute1 Minute2 Total_Hours Total_Minutes Combined_Time I would then write something like Total_minutes = minute1 + Minute2 Total_hours = Hour1 + hour2 combined time = Total_hours * 60 + (Total_Minutes) // reset the total hours Total_hours = 0 Loop here.... while combined_time >60 Total_hours = Total_hours + 1 combined_time = combined time -60 re-do the loop Now in the boxes at the bottom put bottom hour box = total hours bottom minute box = combined_time (remaining minutes) here's the code I have so far. Code: [Select] <!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>Untitled Document</title> </head> <body> <table width="527" border="0" cellspacing="5" cellpadding="5" bgcolor="#c0c5c9"> <p>Time Calculator</p> <p>Put your hours and minutes in the top boxes. Click the add time button<br /> to get the answer </p> <table width="401" border="1" cellspacing="5" cellpadding="5"> <tr> <td width="109"><input type="int" name="hour01" size="10" maxlength="10" /> Hrs</td> <td width="251"><input type="int" name="min01" size="10" maxlength="10" /> Mins</td> </tr> <tr> <td><input type="int" name="hour02" size="10" maxlength="10" /> Hrs</td> <td><input type="int" name="min02" size="10" maxlength="10" /> Mins</td> </tr> <tr> <td><input type="submit" name="submit" value="Add Time" /></td> <td><input name="hour_answer" type="int" size="10" maxlength="10" /> Hrs <input type="int" name="minute_answer" size="10" maxlength="10" /> Mins</td> </tr> </table> <tr></tr> </body> </html> I have an application that was written back in PHP4 days and has ceased development ever since. PHP 4 is basically gone, i can't get it to install on any of my machines now and what i use on my windows boxes (XAMPP) doesn't include PHP4 anymore. When i set everything up, i get ~50 of these: Deprecated: Assigning the return value of new by reference is deprecated in.... and on every line it looks like: $var =& _____ or $var = &something... yada-yada and removing the & symbol removes the error message. Using editplus i removed all the "=&" and "= &" and just replaced the & with space, i had read on google PHP5 doesn't need it anymore so that should've worked. But as my luck would have it, the server errors out with 500 code until i replace all the &'s back, and then the errors show up yet again. Is there anyway to force php5 to run this program despite having php4 things in it? I have a page that shows entries in a guestbook I'm making, and below the entries there is supposed to be a form to write an entry. Except, none of the HTML after the script to show the entries shows up on the page. I have no clue what's wrong. Here is the script to show the entries. $n is name, $d is date, $s is site (optional), and $m is message. $file = fopen("posts.txt", 'rb'); flock($file, LOCK_SH); while(!feof($file)){ $entry = fgetcsv($file, 0, '|'); if(empty($entry)){exit;} $d = $entry[1]; $n = $entry[2]; $s = $entry[3]; $m = $entry[4]; echo ' <table style="border: #3399AA 1px solid;"><tr style="background: #3399AA; font: bold 10px verdana,sans-serif; color: #FFFFFF;"> <td width="170">'.$n.'</td> <td align="right" width="170">'.$d.'</td> </tr> '; if($s != 'none'){ echo ' <tr><td colspan="2" style="font: 10px verdana,sans-serif; color: #3399AA;"> <b>Site: </b><a href="'.$s.'">'.$s.'</a> <center><div style="width: 250; height: 1px; background: #3399AA; margin: 10px;"></div></center></td></tr> '; } echo ' <tr> <td colspan="2" style="font: 10px verdana,sans-serif; color: #3399AA;">'.$m.'</td> </tr></table><br> '; } flock($file, LOCK_UN); fclose($file); The file it is reading looks like this: Code: [Select] |11:51 am, 3rd Nov 2010|Memoria|none|Hello. :) |11:51 am, 3rd Nov 2010|Memoria|http://sitehere|Hello again. |11:51 am, 3rd Nov 2010|Memoria|none|How are you doing? Thanks! Hi guys, Should be a simple 1. If i have the following at the top of the page: $page_views = $row['page_views'] + 1; mysql_query("UPDATE table SET page_views='$page_views'"); and then the following at the bottom of the page: echo $row['page_views']; Should I see the page views as 1 the first time the page is visited, 2 the second time the page is visited, and so on......? At the moment im seeing 0 on the first page visit, 1 on the second page visit, 2 on the third..... I had this problem before on another page i was working, and i simply solved it by displaying the mysql query above the echo similar to the code above. However now it does not seem to be working. Am i missing something really simple? lol Thanks Hi, I want to show part of the text from a page containing my article on my main page. The article resides in a database in mysql. How do I limit the amount of text that is shown without setting up a separate excerpt box for the article. I want to then provide a link so the user can go to another page that displays the entire article. Thanks for any suggestions. Hi Guys, I wonder if you can help me before I go crazy? I have the task of updating a site by adding text to every page, at the moment there are three pages on the live website that show both images and text, I am to update the remaining 6 with text to go with the images.... I thought this was all fine and dandy, added the text in, checked the code, uploaded to the FTP site and nothing, only 1 page worked. I am stuck as I have used the same method to add text to all the pages yet those elusive pages refuse to show text! This is driving me crazy and i am hoping that one of you guys has come across this before and will be able to highlight a missing piece of code or have a solution? I do appreciate your time and any suggestions that you have. I have attached the page below. Thanks guys! Hi,
In reference to my first attached image, I have a form which displays two SELECT/drop-down fields (labeled "Store Name" and "Item Description".....and both of which pull-in values from two separate lookup/master tables, in addition to providing an additional option each for "NEW STORE" and "NEW ITEM").
Now, when first-run, and/or if "NEW STORE" and "NEW ITEM" are not selected from the drop-down's then the two fields in green ("New Store Name" and "New Item Name" are hidden, by means of the following code:
<div class="new-store-container" id="new-store-container" name="new-store-container" style="display:none;"> <div class="control-group"> <div class="other-store" id="new_store_name"> <?php echo standardInputField('New Store Name', 'new_store_name', '', $errors); ?> </div> </div> </div>Conversely, if "NEW STORE" and/or "NEW ITEM" are selected from the two drop-down's then one (or both) of the "New Name" fields are unhidden by means of the following two pieces of code, one PHP and the second JS: <select class="store-name" name="store_id" id="store_id" onclick="toggle_visibility('store_id','new-store-container')"> <?php echo $store_options; ?> <?php if($values['store_id'] == "OTH") { echo "<option value='OTH' selected> <<<--- NEW STORE --->>> </option>"; } else { echo '<OPTION VALUE="OTH"> <<<--- NEW STORE --->>> </OPTION>'; } ?> </select> function toggle_visibility(fieldName, containerName) { var e = document.getElementById(fieldName); var g = document.getElementById(containerName); if (e.value == 'OTH') { if(g.style.display == 'none') g.style.display = 'block'; else g.style.display = 'none'; } }All of that is working just fine. The problem I'm having is that when I click the "Create" button, after having left any one of the form fields blank, the two "New Name" fields are hidden again, which I don't want to happen i.e. I want them to remain visible (since the values of "store_id" and/or "item_id" are "OTH"), so that the user can enter values into one or both of them, without havng to click on the drop-down a second time in order to execute the "on-click" code. The second attached image shows how the fields are hidden, after clicking "Create". How can I achieve that? It would be greate if someone could cobble-up the required code and provide it to me, since I'm relatively new to this. Thanks much. Snap1.png 26.14KB 0 downloads Snap2.png 149.47KB 0 downloads Quesion: Show each movie in the database on its own page, and give the user links in a "page 1, Page 2, Page 3" - type navigation system. Hint: Use LIMIT to control which movie is on which page. I have provided 3 files: 1st: configure DB, 2nd: insert data, 3rd: my code for the question. I would appreciate the help. I am a noob by the way. First set up everything for DB: <?php //connect to MySQL $db = mysql_connect('localhost', 'root', '000') or die ('Unable to connect. Check your connection parameters.'); //create the main database if it doesn't already exist $query = 'CREATE DATABASE IF NOT EXISTS moviesite'; mysql_query($query, $db) or die(mysql_error($db)); //make sure our recently created database is the active one mysql_select_db('moviesite', $db) or die(mysql_error($db)); //create the movie table $query = 'CREATE TABLE movie ( movie_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, movie_name VARCHAR(255) NOT NULL, movie_type TINYINT NOT NULL DEFAULT 0, movie_year SMALLINT UNSIGNED NOT NULL DEFAULT 0, movie_leadactor INTEGER UNSIGNED NOT NULL DEFAULT 0, movie_director INTEGER UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (movie_id), KEY movie_type (movie_type, movie_year) ) ENGINE=MyISAM'; mysql_query($query, $db) or die (mysql_error($db)); //create the movietype table $query = 'CREATE TABLE movietype ( movietype_id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT, movietype_label VARCHAR(100) NOT NULL, PRIMARY KEY (movietype_id) ) ENGINE=MyISAM'; mysql_query($query, $db) or die(mysql_error($db)); //create the people table $query = 'CREATE TABLE people ( people_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, people_fullname VARCHAR(255) NOT NULL, people_isactor TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, people_isdirector TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (people_id) ) ENGINE=MyISAM'; mysql_query($query, $db) or die(mysql_error($db)); echo 'Movie database successfully created!'; ?> ******************************************************************** *********************************************************************** second file to load info into DB: <?php // connect to MySQL $db = mysql_connect('localhost', 'root', '000') or die ('Unable to connect. Check your connection parameters.'); //make sure you're using the correct database mysql_select_db('moviesite', $db) or die(mysql_error($db)); // insert data into the movie table $query = 'INSERT INTO movie (movie_id, movie_name, movie_type, movie_year, movie_leadactor, movie_director) VALUES (1, "Bruce Almighty", 5, 2003, 1, 2), (2, "Office Space", 5, 1999, 5, 6), (3, "Grand Canyon", 2, 1991, 4, 3)'; mysql_query($query, $db) or die(mysql_error($db)); // insert data into the movietype table $query = 'INSERT INTO movietype (movietype_id, movietype_label) VALUES (1,"Sci Fi"), (2, "Drama"), (3, "Adventure"), (4, "War"), (5, "Comedy"), (6, "Horror"), (7, "Action"), (8, "Kids")'; mysql_query($query, $db) or die(mysql_error($db)); // insert data into the people table $query = 'INSERT INTO people (people_id, people_fullname, people_isactor, people_isdirector) VALUES (1, "Jim Carrey", 1, 0), (2, "Tom Shadyac", 0, 1), (3, "Lawrence Kasdan", 0, 1), (4, "Kevin Kline", 1, 0), (5, "Ron Livingston", 1, 0), (6, "Mike Judge", 0, 1)'; mysql_query($query, $db) or die(mysql_error($db)); echo 'Data inserted successfully!'; ?> ************************************************************** **************************************************************** MY CODE FOR THE QUESTION: <?php $db = mysql_connect('localhost', 'root', '000') or die ('Unable to connect. Check your connection parameters.'); mysql_select_db('moviesite', $db) or die(mysql_error($db)); //get our starting point for the query from the URL if (isset($_GET['offset'])) { $offset = $_GET['offset']; } else { $offset = 0; } //get the movie $query = 'SELECT movie_name, movie_year FROM movie ORDER BY movie_name LIMIT ' . $offset . ' , 1'; $result = mysql_query($query, $db) or die(mysql_error($db)); $row = mysql_fetch_assoc($result); ?> <html> <head> <title><?php echo $row['movie_name']; ?></title> </head> <body> <table border = "1"> <tr> <th>Movie Name</th> <th>Year</th> </tr><tr> <td><?php echo $row['movie_name']; ?></td> <td><?php echo $row['movie_year']; ?></td> </tr> </table> <p> <a href="page.php?offset=0">Page 1</a>, <a href="page.php?offset=1">Page 2</a>, <a href="page.php?offset=2">Page 3</a> </p> </body> </html> I want to show a cookie of a referral's username on a sign up page. The link is like this, www.mysite.com/signup?ref=johnsmith. The cookie doesn't show if I go to that url page. But it does show up once I reload the page. So I'm wondering if it's possible to show the cookie the first time around, instead of reloading the page? Here is my code. // This is in the header $url_ref_name = (!empty($_GET['ref']) ? $_GET['ref'] : null); if(!empty($url_ref_name)) { $number_of_days = 365; $date_of_expiry = time() + 60 * 60 * 24 * $number_of_days; setcookie( "ref", $url_ref_name, $date_of_expiry,"/"); } else if(empty($url_ref_name)) { if(isset($_COOKIE['ref'])) { $user_cookie = $_COOKIE['ref']; } } else {} // This is for the sign up form if(isset($_COOKIE['ref'])) { $user_cookie = $_COOKIE['ref']; ?> <fieldset> <label>Referred By</label> <div id="ref-one"><span><?php if(!empty($user_cookie)){echo $user_cookie;} ?></span></div> <input type="hidden" name="ref" value="<?php if(!empty($user_cookie)){echo $user_cookie;} ?>" maxlength="20" placeholder="Referrer's username" readonly onfocus="this.removeAttribute('readonly');" /> </fieldset> <?php }
Hello, im very green to php and I am having trouble creating a simple log in script. Not sure why this is not working, maybe a mysql_query mistake? I am not receiving any errors but nothing gets updated in the members table and my error message to the user displays. any help is appreciated! here is my php: <?php session_start(); $errorMsg = ''; $email = ''; $pass = ''; if (isset($_POST['email'])) { $email = ($_POST['email']); $pass = ($_POST['password']); $email = stripslashes($email); $pass = stripslashes($pass); $email = strip_tags($email); $pass = strip_tags($pass); if ((!$email) || (!$pass)) { $errorMsg = '<font color="#FF0000">Please fill in both fields</font>'; }else { include 'scripts/connect_db.php'; $email = mysql_real_escape_string ($email); $pass = md5($pass); $sql = mysql_query("SELECT * FROM members WHERE email='$email' AND password='$pass'"); $log_check = mysql_num_rows($sql); if ($log_check > 0) { while($row = mysql_fetch_array($sql)) { $id = $row["id"]; $_SESSION['id']; $email = $row["email"]; $_SESSION['email']; $username = $row["username"]; $_session['username']; mysql_query("UPDATE members SET last_logged=now() WHERE id='$id' LIMIT 1"); }//Close while loop echo "You are logged in"; exit(); } else { $errorMsg = '<font color="#FF0000">Incorrect login data, please try again</font>'; } } } ?> and the form: <?php echo $errorMsg; ?> <form action="log_in.php" method="post"> Email:<br /> <input name="email" type="text" /><br /><br /> Password:<br /> <input name="password" type="password" /><br /><br /> <input name="myBtn" type="submit" value="Log In" /> </form> Hi, I would like to do the following but not sure how. If the you/user is on index.php of http://www.domain.com/ show one page If not show another How would I do this? Thanks ok, I am hoping the code is self explanatory... but if not, I'm creating a script which I will be using for something else. Basically it says if OS and browser show code under... I am looking for two things. 1. Is there a way to make it so that it can pull from a list and show that if HTTP_USER_AGENT comes back with a specific output, to say you are using X OS with Y browser? 2. The last bit, it is meant to say, if not any of the options show the info below. For some reason it's not doing that... can someone please tell me why? Thanks. Code: [Select] <?php //Operating Systems function xp(){return(eregi("Windows NT 5.1", $_SERVER['HTTP_USER_AGENT']));} function vista(){return(eregi("Windows NT 6.0", $_SERVER['HTTP_USER_AGENT']));} function win7(){return(eregi("Windows NT 6.1", $_SERVER['HTTP_USER_AGENT']));} function ubuntu(){return(eregi("Ubuntu/", $_SERVER['HTTP_USER_AGENT']));} //Web Browsers function chrome(){ return(eregi("Chrome/", $_SERVER['HTTP_USER_AGENT']));} function safari(){ return(eregi("Safari/", $_SERVER['HTTP_USER_AGENT']));} function firefox(){ return(eregi("Firefox/", $_SERVER['HTTP_USER_AGENT']));} function ie9(){ return(eregi("MSIE 9.0", $_SERVER['HTTP_USER_AGENT']));} function ie8(){ return(eregi("MSIE 8.0", $_SERVER['HTTP_USER_AGENT']));} // do something if XP and Chrome if(xp() && chrome()){echo 'You are using Windows XP with a Chrome web Browser';} // do something if XP and IE8 if(xp() && ie8()){echo 'You are using Windows XP with a Internet Explorer 8 web Browser';} // do something if Windows 7 and IE9 if(win7() && ie9()){echo 'You are using Windows 7 with a Internet Explorer 9 web Browser';} // do something if Windows Vista and IE9 if(vista() && ie9()){echo 'You are using Windows Vista with a Internet Explorer 9 web Browser';} // do something if Windows Vista and IE8 if(vista() && ie8()){echo 'You are using Windows Vista with a Internet Explorer 8 web Browser';} // do something if Ubuntu and Firefox if(ubuntu() && firefox()){echo 'You are using Ubuntu with a Firefox web Browser';} if(!ubuntu() || !xp() || !vista() || !win7() || !firefox() || !chrome() || !safari() || !ie9() || !ie8()){ echo'<strong>'; echo '<br />' . $_SERVER['HTTP_USER_AGENT'] . '<br /><br />Administrator someone in your work force is using an unsupported browser/OS combination, please email the information above to the developer of the NCMR software you are using. It will allow your browser/OS combination to be used correctly. Sorry for the inconvenience.</strong> <br /><br />Please copy and paste the text above and send it to your web administrator. It will explain everything he/she needs to do.';} ?> Hi can someone pls help, im tryin a tutorial but keep getting errors, this is the first one i get after registering. You Are Registered And Can Now Login Warning: Cannot modify header information - headers already sent by (output started at /home/aretheyh/public_html/nealeweb.com/regcheck.php:43) in /home/aretheyh/public_html/nealeweb.com/regcheck.php on line 46 Hi, In my application I have not used any folders to define the hierarchy. All file s are in a single folder. What is the easy way of creating the Breadcrumb. I am rewriting the URL from www.mysite.com/main.php/page=pagename&id=10 to www.mysite.com/main/pagename/id/10 Is it possible to use the re-written URL to create the breadcrumb? If yes I can define hierarchy in the URL and use the same to create breadcrumb. I can't get images to show up in my script. They show up as broken images and I can figure it out. I think it's a problem with (') or this (").
Any help would be appreciated.
$query = 'SELECT * FROM images'; $stmt = $dbh->prepare($query); $stmt->execute(); $counter = 0; $numberperrow = 3; while($row = $stmt->fetch()) { if($counter < $numberperrow) { echo '<img src='.$row['image_th'].' width=200>'; /**$counter = $counter + 1;**/ echo ' '; $counter = $counter + 1; }else{ echo '<br>'; $counter = '1'; echo '<img src='.$row['image_th'].' width=200>'; echo ' '; } } } catch(PDOException $e) { echo $e->getMessage(); } Hi guys. I have a problem in my web based examanation system written in php. Here's the scenario: when a user takes an exam. 1 question is displayed 1 at a time. my problem is if he/she is at the 2nd question then he/she pressed the back button he/she is redirected back to the 1st question and my system just go crazy. How can i prevent the user from pressing the back button or returning to the previous questions? Please I really need help on this. Can anyone give me suggestion for possible solutions on my problem? Thanks in advance by the way here's my code, you can also download it from attachment. ------------------------------------------process_exam.php------------------------------------------------------------ <?php //start session session_start(); //declare variables //iCorrect= variable for score $_SESSION['iCorrect']=0; //a=variable for iteration kang index kang mga array or serves as an current item number $_SESSION['a']=1; //connect to database include('mysql_connect.php'); $result = mysql_query("select * from questions where exam_id ='$_SESSION[exam_id]'"); //count the number of found questions $_SESSION['num_of_questions']=mysql_num_rows($result); //declare the iterator $i=1; //get the options for the question1,question2 and so on and so on. depende kung ilang questions ang mafetch nya sa dbase.so pde kht ilang questions lagay ng user while ($row = mysql_fetch_assoc($result)) { $questions[$i] = $row['question']; $op1[$i] = $row['op1']; $op2[$i] = $row['op2']; $op3[$i] = $row['op3']; $op4[$i] = $row['op4']; $answers[$i]=$row['answer']; $i++; } //view the data's in the array for debugging purposes echo 'answers: '; print_r($questions); echo '<br>'; print_r($op1); echo '<br>'; print_r($op2); echo '<br>'; print_r($op3); echo '<br>'; print_r($op4); echo '<br>'; print_r($answers); echo '<br>'; echo '<br>'; //pass the arrays to session arrays to be used in other php pages $_SESSION['question']=$questions; $_SESSION['op1']=$op1; $_SESSION['op2']=$op2; $_SESSION['op3']=$op3; $_SESSION['op4']=$op4; $_SESSION['answers']=$answers; //print the arrays. debugging purposes //1 is the starting index of the array because the $i is equal to 1 print_r($_SESSION['question']); echo '<br>'; print_r($_SESSION['op1']); echo '<br>'; print_r($_SESSION['op2']); echo '<br>'; print_r($_SESSION['op3']); echo '<br>'; print_r($_SESSION['op4']); echo '<br>'; print_r($_SESSION['answers']); header("location:exam.php"); ?> </body> </html> ----------------------------------------------------------exam.php-------------------------------------------------------------------- <?php //start session session_start(); echo '<br>'; echo '<br>'; echo '<tr>'; echo '<b>'; echo 'Question: '; echo '<td align = center>'.$_SESSION['question'][$_SESSION['a']].'</td>'; echo '</tr>'; echo '<form method = "post" action= "nxt_question.php">'; echo '<table border = "0">'; echo '<tr>'; //echo '<td>'; echo "<td><Input type =\"Radio\" Name =\"choice\" value='".$_SESSION['op1'][$_SESSION['a']]."'>"; echo '<td>'.$_SESSION['op1'][$_SESSION['a']].'</td>'; echo '</tr>'; echo '<tr>'; echo "<td><Input type =\"Radio\" Name =\"choice\" value='".$_SESSION['op2'][$_SESSION['a']]."'>"; echo '<td>'.$_SESSION['op2'][$_SESSION['a']].'</td>'; echo '</td>'; echo '</tr>'; echo "<td><Input type =\"Radio\" Name =\"choice\" value='".$_SESSION['op3'][$_SESSION['a']]."'>"; echo '<td>'.$_SESSION['op3'][$_SESSION['a']].'</td>'; echo '</tr>'; echo "<td><Input type =\"Radio\" Name =\"choice\" value='".$_SESSION['op4'][$_SESSION['a']]."'>"; echo '<td>'.$_SESSION['op4'][$_SESSION['a']].'</td>'; echo '</tr>'; echo '</table>'; echo '<tr> <td> <input type = "submit" value="Next Question"> </td> </tr>'; echo '</form>'; ?> ----------------------------------------------nxt_question.php------------------------------------- <?php //start session session_start(); //Checking of answers kada mag pindot next question button if(isset($_POST['choice'])) { $ans_of_user=$_POST['choice']; $_SESSION['answers'][$_SESSION['a']]; if (strcmp($ans_of_user,$_SESSION['answers'][$_SESSION['a']])==0) { $_SESSION["iCorrect"]++; } } //add 1 to the session a. session a is the iterator. serves as indexes of the arrays that stores the questions,answers etc... $_SESSION['a']++; //ridirect to exam.php if there are still number of items remaining. while($_SESSION['a']<=$_SESSION['num_of_questions']) { header("location:exam.php"); exit(); //kill the script } echo 'exam finished!'; echo '<br>'; echo 'Your score is: '; echo $_SESSION["iCorrect"]; //unset the session variables needed to be reset unset($_SESSION["iCorrect"]); unset($_SESSION["exam_id"]); unset($_SESSION["invitation_code"]); unset($_SESSION["a"]); unset($_SESSION["num_of_questions"]); unset($_SESSION["question"]); unset($_SESSION["op1"]); unset($_SESSION["op2"]); unset($_SESSION["op3"]); unset($_SESSION["op4"]); unset($_SESSION["answers"]); ?> I'm trying to figure out how to create a temporary table of a query join, so I can paginate the results. I kind of made half of this up as i was going along - which is dangerous for a beginner like me. I'm getting this error, and no results on the page: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource on line 179 also, is there a way to combine the two queries (create temp and insert from/into) Code: [Select] $sql2 = "CREATE TEMPORARY TABLE temp_search (plant_id INT PRIMARY KEY AUTO_INCREMENT, scientific_name VARCHAR(75), common_name VARCHAR(75), leaf_shape VARCHAR(75))"; $sqlx = "SELECT descriptors.leaf_shape ,plantae.scientific_name, plantae.common_name FROM descriptors INNER JOIN plantae ON (descriptors.plant_id = plantae.plant_name) WHERE descriptors.leaf_shape LIKE 'auriculate' AND descriptors.leaf_venation LIKE '%$select3%' AND descriptors.leaf_margin LIKE '%$select4%' INTO temp_search (leaf_shape, scientific_name, common_name)"; $sql = "SELECT * FROM temp_search ORDER BY scientific_name ASC LIMIT $start, $limit"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)) { echo $row['scientific_name'] . $row['common_name'] . $row['leaf_shape'] ; } |