Psycho
Moderators-
Posts
12,157 -
Joined
-
Last visited
-
Days Won
129
Everything posted by Psycho
-
[SOLVED] Drop down list and displaying the selection and retaining it
Psycho replied to CG_dude's topic in PHP Coding Help
The line I posted is corrected below. As for how/where you are saving it, I guess I'm confused as to what the pupose it. If you are not using the value for anything then what is the point of saving the value? You need to save the value somewhere. If you want it saved for when you come back to the site, then sessions will not work. Does the value need to be saved for "everyone" or will the saved value be different for different people. A second solution would be to use a cookie, but that value would be different for each user/pc that accesses the page. Otherwise you would need to save to a database or to a flat file. But, since the value isn't used for anything I don't see the point. $selected = ($_SESSION['mylist']==$value)?' selected="selected"' : ''; -
[SOLVED] Drop down list and displaying the selection and retaining it
Psycho replied to CG_dude's topic in PHP Coding Help
Well, what do you mean by "until I come back and change it"? What are you doing with the value when you submit the page? You should be using/saving it somewhere. Based upon where you are saving that valule the solutino would be slightly different. Here's an example assuming the value is saved to a session value: $options = array('Made SLA', 'Missed SLA'); echo "<select name=\"mylist\" onchange=\"disp_text();\">"; foreach($options as $value) { $selected = ($_SESSION['mylist']==$value)?' selected="selected" : ''; echo " <option value=\"$value\"{$selected}>{$value}</option>\n"; } echo "</select>\n"; -
Here's a generic function that you could use for multiple things: <html> <head> <script> function moveSelectOpt(selID, step) { var selObj = document.getElementById(selID); var newID = (selObj.selectedIndex + step); if (newID>=1 && newID<=(selObj.options.length-1)) { selObj.selectedIndex = newID; } else { selObj.selectedIndex = (newID<=1) ? (selObj.options.length-1): 1 ; } return; } </script> </head> <body> <select name="time" id="time" style="width:150px"> <option>Select Time</option> <option value="9:00">Morning</option> <option value="12:00">Afternoon</option> <option value="16:00">Evening</option> <option value="22:00">Late</option> </select><br> <a href="#" onclick="moveSelectOpt('time', 1);">Next Time</a> <a href="#" onclick="moveSelectOpt('time', -1);">Previous Time</a> </body> </html>
-
Yes, you can stack images on top of each other, you would use layers in CSS, but why? If the images aren't transparent so you can see through them, then you can only see the top image (or at worst you would see edges of the lower images sticking out from the top). It would be simpler to just swap out the image on the top. If it is an issue of a time delay to display the changed image, then just load all the images and change the display properties. Can you give a little more explanation as to what you are trying to acheive and the problem with the code you posted above?
-
The function "changeModel()" represents your onchange function for the select list. Edit accordingly for your setup: <html> <head> <script type="text/javascript"> var models = new Array(); models['Chrysler'] = ['Pacifica', 'PT Cruiser', 'Sebring']; models['Ford'] = ['Ranger', 'Taurus', 'Mustang']; models['GMC'] = ['Acadia', 'Sierra', 'Yukon']; function changeMake(make) { var modelList = models[make]; changeSelect('model', modelList, modelList); document.getElementById('model').disabled = false; document.getElementById('model').onchange(); } function changeModel(modelValue) { document.getElementById('output').innerHTML = modelValue; return; } function changeSelect(fieldID, newValues, newOptions) { selectField = document.getElementById(fieldID); selectField.options.length = 0; if (newValues && newOptions) { for (i=0; i<newValues.length; i++) { selectField.options[selectField.length] = new Option(newOptions[i], newValues[i]); } } } </script> </head> <body> Make:<br> <input type="radio" name="make" value="Chrysler" onclick="changeMake(this.value);"> Chrysler<br /> <input type="radio" name="make" value="Ford" onclick="changeMake(this.value);"> Ford<br /> <input type="radio" name="make" value="GMC" onclick="changeMake(this.value);"> GMC<br /> <br> Model: <select name="model" id="model" onchange="changeModel(this.value);" disabled="disabled"> <option> -- Select a Make -- </option> </select> <br><br> Output: <span id="output"></span> </body> </html>
-
[SOLVED] accessing the array value witout putting it in another variable
Psycho replied to asmith's topic in PHP Coding Help
You could use Regular Expression. But, I think what you might gain in compact code you would lose in "efficiency" of the code. -
[SOLVED] Complicated Project. Need Advice on How to Start
Psycho replied to Fluoresce's topic in PHP Coding Help
I made a last minute change in some variable names and didn't get them all correct. Change the last loop as follows: $output = ""; for($idx=0; $idx<13; $idx++) { $output .= "<tr>\n"; $output .= $td[$idx]; $output .= $td[$idx+13]; $output .= "</tr>\n"; } Still not tested, so there may be more minor errors. As for the error messages, the line numbers refer to the PHP file NOT the HTML output. -
[SOLVED] Complicated Project. Need Advice on How to Start
Psycho replied to Fluoresce's topic in PHP Coding Help
And, where did you ask for that? I do like helping people, but there's nothing more frustrating than taking the time to help someone only to have them ask for something different once you provide what they originally asked for. The code below should get you what you want (not tested). <?php $conn = mysql_connect('localhost','hidden', 'hidden') or trigger_error("SQL", E_USER_ERROR); $db = mysql_select_db('hidden', $conn) or trigger_error("SQL", E_USER_ERROR); //Query ALL the records ordered by make $query = "SELECT tblmake.make, tblmake.url, COUNT(tblmodel.modelid) AS model_count FROM tblmake LEFT JOIN tblmodel ON tblmake.makid = tblmodel.makeid GROUP BY tblmake.makid ORDER BY tblmake.make ASC"; $result = mysql_query($query, $conn) or trigger_error("SQL", E_USER_ERROR); $total_records = mysql_num_rows($result); if($total_records > 0) { //There were results, let's display them $letters = array ('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'); $row = mysql_fetch_assoc($result); foreach($letters as $idx => $letter) { $no_makes_in_letter = true; $td[$idx] .= "<td><h1><a name=\"$letter\">$letter</a></h1><br />\n"; while (substr($row['make'], 0, 1) == $letter) { $no_makes_in_letter = false; $td[$idx] .= "<a href=\"{$row['url']}\">{$row['make']}</a> ({$row['model_count']})<br />\n"; if (!$row = mysql_fetch_assoc($result)) { break; } } if($no_makes_in_letter) { $td[$idx] .= "None<br />\n"; } $td[$idx] .= "</td>\n"; } $output = ""; for($i=0; $idx<13; $i++) { $output .= "<tr>\n"; $output .= $td[$idx]; $output .= $td[$idx+13]; $output .= "</tr>\n"; } } // end if else { echo "No results"; } ?> <table class="center" style="text-align:center" width="400px" border="1" cellpadding="5" cellspacing="5"> <tr> <td colspan="2"> <a href="#A">A</a> <a href="#B">B</a> <a href="#C">C</a> <a href="#D">D</a> <a href="#E">E</a> <a href="#F">F</a> <a href="#G">G</a> <a href="#H">H</a> <a href="#I">I</a> <a href="#J">J</a> <a href="#K">K</a> <a href="#L">L</a> <a href="#M">M</a> </td> </tr> <tr> <td colspan="2"> <a href="#N">N</a> <a href="#O">O</a> <a href="#P">P</a> <a href="#Q">Q</a> <a href="#R">R</a> <a href="#S">S</a> <a href="#T">T</a> <a href="#U">U</a> <a href="#V">V</a> <a href="#W">W</a> <a href="#X">X</a> <a href="#Y">Y</a> <a href="#Z">Z</a> </td> </tr> <?php echo $output; ?> </table> -
[SOLVED] Complicated Project. Need Advice on How to Start
Psycho replied to Fluoresce's topic in PHP Coding Help
Wow, someone actual read that! I will try to test code if it doesn't mean I have to put a lot of work into it. If a database is involved I usually won't. -
[SOLVED] Complicated Project. Need Advice on How to Start
Psycho replied to Fluoresce's topic in PHP Coding Help
Well, you could just as easily create the links at the top to only include the letters for which there are results! What you are asking is easy enough, but one possible issue is that the lists on each side might not be uniform. For example, if there are a lot of records in the A-M range, the left side of the list could be much longer than the list on the right. <?php $conn = mysql_connect('localhost','hidden', 'hidden') or trigger_error("SQL", E_USER_ERROR); $db = mysql_select_db('hidden', $conn) or trigger_error("SQL", E_USER_ERROR); //Query ALL the records ordered by make $query = "SELECT tblmake.make, tblmake.url, COUNT(tblmodel.modelid) AS model_count FROM tblmake LEFT JOIN tblmodel ON tblmake.makid = tblmodel.makeid GROUP BY tblmake.makid ORDER BY tblmake.make ASC"; $result = mysql_query($query, $conn) or trigger_error("SQL", E_USER_ERROR); $total_records = mysql_num_rows($result); if($total_records > 0) { //There were results, let's display them $letters = array ('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'); $row = mysql_fetch_assoc($result) foreach($letters as $letter) { $letter_idx = array_search($letter, $letters); $side = ($letter_idx < 13)?'left':'right'; $td[$side] .= "<br /><h1><a name=\"$letter\">$letter</a></h1>\n"; while (substr($row['make'], 0, 1) == $letter) { $td[$side] .= "<a href=\"{$row['url']}\">{$row['make']}</a> ({$row['model_count']})<br />\n"; if (!$row = mysql_fetch_assoc($result)) { break; } } } } // end if else { echo "No results"; } ?> <table class="center" style="text-align:center" width="400px" border="1" cellpadding="5" cellspacing="5"> <tr> <td colspan="2"> <a href="#A">A</a> <a href="#B">B</a> <a href="#C">C</a> <a href="#D">D</a> <a href="#E">E</a> <a href="#F">F</a> <a href="#G">G</a> <a href="#H">H</a> <a href="#I">I</a> <a href="#J">J</a> <a href="#K">K</a> <a href="#L">L</a> <a href="#M">M</a> </td> </tr> <tr> <td colspan="2"> <a href="#N">N</a> <a href="#O">O</a> <a href="#P">P</a> <a href="#Q">Q</a> <a href="#R">R</a> <a href="#S">S</a> <a href="#T">T</a> <a href="#U">U</a> <a href="#V">V</a> <a href="#W">W</a> <a href="#X">X</a> <a href="#Y">Y</a> <a href="#Z">Z</a> </td> </tr> <tr> <td valign="top"><?php echo $td['left']; ?></td> <td valign="top"><?php echo $td['right']; ?></td> </tr> </table> -
[SOLVED] Complicated Project. Need Advice on How to Start
Psycho replied to Fluoresce's topic in PHP Coding Help
Um, not sure what you are asking for is what you really want. There will be many letters without any results. Do you want letters without results listed (e.g. 'Z')? And how do you want the letters displayed? Like this A B C D E f ... Or like this A N B O C P ... Edit: Also, post the code that you have working for any changes to be made. -
[SOLVED] Complicated Project. Need Advice on How to Start
Psycho replied to Fluoresce's topic in PHP Coding Help
The query you posted above is not the one I posted for you in a different thread. There is no GROUP BY clause - which is probably the problem. <?php $conn = mysql_connect('localhost','deleted', 'deleted') or trigger_error("SQL", E_USER_ERROR); $db = mysql_select_db('databasename', $conn) or trigger_error("SQL", E_USER_ERROR); //Query ALL the records ordered by make $query = "SELECT tblmake.make, tblmake.url, COUNT(tblmodel.modelid) AS model_count FROM tblmake LEFT JOIN models ON tblmake.makeid = tblmodel.makeid GROUP BY tblmodel.modelid ORDER BY tblmake.make ASC"; $result = mysql_query($query, $conn) or trigger_error("SQL", E_USER_ERROR); if(mysql_num_rows($result) >= 1) { //There were results, let's display them $current_letter = false; while($row = mysql_fetch_assoc($result)) { //Detected a new letter. Insert header anchor if($current_letter != substr($row['make'], 0, 1)) { $current_letter = substr($row['make'], 0, 1); echo "<br /><h1><a name=\"$current_letter\">$current_letter</a></h1><br />"; } //Display the current make with count echo "<a href=\"{$row['url']}\">{$row['make']} ({$row['model_count']})</a><br />"; } // end while } // end if else { echo "None"; } ?> -
[SOLVED] Complicated Project. Need Advice on How to Start
Psycho replied to Fluoresce's topic in PHP Coding Help
You apparently are only posting part of the code from your page, because that code only has 38 lines and the error is occuring on line 126. When you have a line number to work with it is much easier to find the problem. In this case though, I was able to spot the problem (as well as another one): In this section, I 1) forgot to change the "!=" to just "=" in the line after the IF condition and 2) forgot to include a semi-colon at the end of the same line //Detected a new letter. Insert header anchor if($current_letter != substr($row['make'], 0, 1)) { $current_letter = substr($row['make'], 0, 1); echo "<br /><h1><a name=\"$current_letter\">$current_letter</a></h1><br />"; } NOTE: I only post my code as a guide on a methodology that should work. I typically do not test it - especially when it involves a database that I do not have access to and do not want to try and replicate. I figure syntax errors should be easily solved by the person receiving the code. -
Some code showing your current structure would have been helpful <html> <head> <script type="text/javascript"> function changeImages(imgName, imageSrc) { var imageList = document.images; for (var imgIdx=0; imgIdx<imageList.length; imgIdx++) { if(imageList[imgIdx].name==imgName) { imageList[imgIdx].src = imageSrc; } } return; } </script> </head> <body> <img name="test1" src="image1.jpg"> <img name="test1" src="image1.jpg"><br><br> <img name="test2" src="image2.jpg"> <img name="test2" src="image2.jpg"><br><br> <button onclick="changeImages('test1', 'image1.jpg');">Change Test 1 to Image 1</button> <button onclick="changeImages('test1', 'image2.jpg');">Change Test 1 to Image 2</button> <button onclick="changeImages('test2', 'image1.jpg');">Change Test 2 to Image 1</button> <button onclick="changeImages('test2', 'image2.jpg');">Change Test 2 to Image 2</button> </body> </html>
-
[SOLVED] Collapsing a div with a radio button
Psycho replied to Darkmatter5's topic in Javascript Help
<html> <head> <script type="text/javascript"> function togglesec(radioOption) { var radioGroup = radioOption.parentNode.childNodes; for(var opt=0; opt<radioGroup.length; opt++) { if (radioGroup[opt].type=='radio') { var divObj = document.getElementById(radioGroup[opt].value); divObj.style.display = (radioGroup[opt].checked) ? 'block':'none'; } } return; } </script> </head> <body> <form> <div id="sections" style="float: left; width: 100px;"> <input type="radio" name="togglesecs" value="buildings" onclick="togglesec(this);" />Buildings<br> <input type="radio" name="togglesecs" value="units" onclick="togglesec(this);" />Units<br> <input type="radio" name="togglesecs" value="units1" onclick="togglesec(this);" />Units1<br> <input type="radio" name="togglesecs" value="units2" onclick="togglesec(this);" />Units2 </div> <div id="buildings" style="float: left; width: 150px; border-left: 1px gray dashed; display:none;"> <input type="radio" name="toggledivs" value="bldlvl1" onclick="togglesec(this);" />Level 1 buildings<br> <input type="radio" name="toggledivs" value="bldlvl2" onclick="togglesec(this);" />Level 2 buildings<br> <input type="radio" name="toggledivs" value="bldlvl3" onclick="togglesec(this);" />Level 3 buildings<br> <input type="radio" name="toggledivs" value="bldlvl4" onclick="togglesec(this);" />Level 4 buildings<br> <input type="radio" name="toggledivs" value="bldlvl5" onclick="togglesec(this);" />Level 5 buildings<br> <input type="radio" name="toggledivs" value="bldlvl6" onclick="togglesec(this);" />Level 6 buildings<br> <input type="radio" name="toggledivs" value="bldlvl7" onclick="togglesec(this);" />Level 7 buildings<br> <input type="radio" name="toggledivs" value="bldlvl8" onclick="togglesec(this);" />Level 8 buildings<br> <input type="radio" name="toggledivs" value="bldlvl9" onclick="togglesec(this);" />Level 9 buildings<br> <input type="radio" name="toggledivs" value="bldlvl10" onclick="togglesec(this);" />Level 10 buildings </div> <div id="units" style="float: left; width: 150px; border-left: 1px gray dashed; display:none;">Units</div> <div id="units1" style="float: left; width: 150px; border-left: 1px gray dashed; display:none;">Units1</div> <div id="units2" style="float: left; width: 150px; border-left: 1px gray dashed; display:none;">Units2</div> </form> </body> </html> -
[SOLVED] Maximum Commands Per Page. Is 52 Too Many?
Psycho replied to Fluoresce's topic in PHP Coding Help
No offense Permiso, but doing queries within loops is bad form in my opinion. It can lead to severe performance issues. Note: you will need to modify the table and field names in the JOIN part of the query as appropriate for your database. //Query ALL the records ordered by make $query = "SELECT tmake.make, tmake.url, COUNT(models.model) as model_count FROM tmake JOIN models ON models.makeid = tmake.makeid ORDER BY tmake.make GROUP BY models.model"; $result = mysql_query($query, $conn) or trigger_error("SQL", E_USER_ERROR); if(mysql_num_rows($result) >= 1) { //There were results, let's display them $current_letter = false; while($row = mysql_fetch_assoc($result)) { //Detected a new letter. Insert header anchor if($current_letter != substr($row['make'], 0, 1)) { $current_letter != substr($row['make'], 0, 1) echo "<br /><h1><a name=\"$current_letter\">$current_letter</a></h1><br />"; } //Display the current make with count echo "<a href=\"{$row['url']}\">{$row['make']} ({$row['model_count']})</a><br />"; } // end while } // end if else { //There were no results echo "None"; } -
[SOLVED] Collapsing a div with a radio button
Psycho replied to Darkmatter5's topic in Javascript Help
You will need to put the INPUT tags within FORM tags for this to work: <html> <head> <script type="text/javascript"> function togglesec(radioOption) { var radioGroup = radioOption.parentNode; for(var opt=0; opt<radioGroup.length; opt++) { var divObj = document.getElementById(radioGroup[opt].value); divObj.style.display = (radioGroup[opt].checked) ? 'block':'none'; } return; } </script> </head> <body> <form> <input type="radio" name="togglesecs" value="buildings" onclick="togglesec(this);" />Buildings<br> <input type="radio" name="togglesecs" value="units" onclick="togglesec(this);" />Units <div id="buildings" style="display:none;">test1</div> <div id="units" style="display:none;">test2</div> </form> </body> </html> -
It depends upon the process flow you are trying to achieve. I typically have my forms pages post to the same page that creates the form. That way I can validate the user's data and, if there are errors, easily redisplay the form with the input they had entered. In this situation, I don't have clue what the problem is. You don't show what is in the pubdelete.php file. Also, the snippet you posted above has the exact same problem I explained before. It would delete the record before the user ever had a chance to confirm.
-
This should be posted as a new topic
-
[SOLVED] innerHTML doesn't work in IE after refresh...
Psycho replied to atomicrabbit's topic in Javascript Help
My pleasure. Please make topic as solved! -
You don't want to multiply the $tolimit variable. The two varialbes for limit are the start index and the count. Using that logic page 1 would return the first 10 records, page two would return the next 20 records, page three would return the next 30 records, etc. Leave the $tolimit at 10 (or whatever count you want displayed on a page. In fact, it would be better to use a variable to determine the number of records per page so you can change it easily with one value: $records_per_page = 10; $page = (int) $_GET['page']; //Convert to an int //Determine total pages available $query = "SELECT COUNT(*) FROM table"; $result = mysql_query($query); $record = mysql_fetch_row($result); $total_pages = ceil($record[0] / $records_per_page); if ($page < 1 || $page > $total_pages) { $page = 1 } $limit_offset = ($page * $records_per_page) - $records_per_page; $query = "SELECT * FROM table ORDER BY somefield LIMIT $offset, $records_per_page";
-
[SOLVED] innerHTML doesn't work in IE after refresh...
Psycho replied to atomicrabbit's topic in Javascript Help
I took the code you posted above and made a test page. Works fine in IE7. Must be something else that is causing the problem. <html> <head> <script type="text/javascript"> window.onload = function () { alert(document.getElementById('showcase1').innerHTML); } </script> </head> <body> <table><tr> <td align="center" valign="middle" id="showcase1" style="width:150px;height:150px;"><img src="collection_lib/spacer.gif" id="showcase1_img" alt="" width="150" height="150" border="0" /></td> </tr></table> </body> </html> -
To get the results to populate the date/times in the proper order add the date to the ORDER clause in the query: $query="SELECT movies.id, movies.name, movies.age_limit, movies.length_time, movies.filmweb, movies.picture, date.id AS date_id, date, time.id AS time_id, time FROM movies JOIN date ON movies.id = date.movie_id JOIN time ON date.id = time.date_id ORDER BY movies.name, date"; For the date issue, I left off a couple lines. Replace the WHILE loop with this code while($movie = mysql_fetch_assoc($result)) { //Check for new movie if ($current_film_name != $movie['name']) { //New movie if($current_film_name != "") { //If not the first record, display the last movie displayMovie($m_name, $m_image, $m_age_limit, $m_length, $m_web, $m_dates, $m_times); } $current_film_name = $movie['name']; $m_name = $movie['name']; $m_image = $movie['picture']; $m_age_limit = $movie['age_limit']; $m_length = $movie['length_time']; $m_web = $movie['filmweb']; $m_dates = ""; $m_times = ""; $current_film_date = ""; } //Date/time data if ($current_film_date != $movie['date']) { //Different date from last record, show it $current_film_date = $movie['date']; $m_dates .= "{$movie['date']}<br>"; } else { //Same date as last, line break $m_dates .= "<br>"; } //Time date $m_times .= "{$movie['time']}<br>"; } That should take care of it
-
O, I have it working, but you are going to need to clean up the "look" of the page. I had to make some adjustments. Note: I hard coded the path to the images so they would show up in my environment. <!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> <title>Vinstra Kino - Oversikt</title> <style type="text/css"> <!-- body { color:white; background-color: #000000; } .style1 {color: #FFFFFF} .style2 { color: #FFFFFF; font-size: 19px; } a:link { color: #FFFFFF; text-decoration: none; } a:visited { text-decoration: none; color: #FFFFFF; } a:hover { text-decoration: none; color: #B10202; } a:active { text-decoration: none; color: #AE0202; } --> </style> <meta Name="generator" content="PHPEd Version 3.1.2 (Build 3165)"> </head> <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> <table width="965" border="0" align="" cellpadding="0" cellspacing="10" background="http://www.vinstrakino.co.cc/test/bilder/bakgrudnn_oversikt.png" style="background-repeat:no-repeat"> <tr> <td colspan="2" height="100" align="left" valign="top">Header</td> </tr> <tr> <td width="160" valign="top"> <br><br> <p class="style2"><a href="index.html">Hjemmeside</a></p> <hr size="1" color="#000000" /> <p class="style2"><a href="oversikt.html">Billettbestilling/<br />Kinoprogram</a></p> <hr size="1" color="#000000" /> <p class="style2"><a href="om.html">Om Vinstra Kino</a></p> <hr size="1" color="#000000" /> <p class="style2"><a href="kontakt.html">Kontakt oss</a></p> <hr size="1" color="#000000" /> <p class="style1"> </p> </td> <td width="400" background="http://www.vinstrakino.co.cc/test/bilder/Vindu_oversikt.png" style="background-repeat:repeat-y;"> <?php function displayMovie($name, $image, $age, $length, $web, $dates, $times) { echo " <table width=\"764\" height=\"300\" border=\"0\" borderColor=\"\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\"> <tr> <td height=\"29\" colspan=\"7\" valign=\"bottom\"> $name </td> </tr> <tr> <td width=\"204\" rowspan=\"3\" align=\"right\" valign=\"top\"><img border=\"2px\" src=\"$image\" alt=\"$name\" width=\"190\" height=\"235\" /></td> <td width=\"116\" align=\"center\" valign=\"top\" bordercolor=\"#F0F0F0\"><span class=\"style12\">Aldersgrense:</span></td> <td width=\"82\" height=\"6\" valign=\"top\"><span class=\"style12\">Spilltid:</span></td> <td width=\"64\" height=\"6\" valign=\"top\"><span class=\"style12\">Filmweb:</span></td> <td width=\"74\" height=\"6\" valign=\"top\"><span class=\"style12\" nowrap>Dato:</span></td> <td width=\"84\" height=\"6\" align=\"center\" valign=\"top\"><span class=\"style12\">Klokkeslett:</span></td> <td width=\"138\" align=\"center\" valign=\"top\">Ledige billetter:</td> </tr> <tr> <td height=\"160\" align=\"center\" valign=\"top\">$age år</td> <td valign=\"top\" nowrap>$length</td> <td valign=\"top\" nowrap><a href=\"$web\">Link</a></td> <td valign=\"top\" nowrap>$dates</td> <td align=\"center\" valign=\"top\" nowrap>$times</td> <td align=\"center\" valign=\"top\" nowrap></td> </tr> <tr> <td height=\"90\" align=\"center\" colspan=\"6\" valign=\"middle\"><a href=\"bestill.html\"><img src=\"http://www.vinstrakino.co.cc/bestill.png\" alt=\"bestill\" width=\"70\" height=\"21\" border=\"0\" /></a></td> </tr> </table>"; } require 'php/tilkobling.php'; $query="SELECT movies.id, movies.name, movies.age_limit, movies.length_time, movies.filmweb, movies.picture, date.id AS date_id, date, time.id AS time_id, time FROM movies JOIN date ON movies.id = date.movie_id JOIN time ON date.id = time.date_id ORDER BY movies.name"; $result=mysql_query($query); $current_film_name = ""; $current_film_date = ""; while($movie = mysql_fetch_assoc($result)) { //Check for new movie if ($current_film_name != $movie['name']) { //New movie if($current_film_name != "") { //If not the first record, display the last movie displayMovie($m_name, $m_image, $m_age_limit, $m_length, $m_web, $m_dates, $m_times); } $current_film_name = $movie['name']; $m_name = $movie['name']; $m_image = $movie['picture']; $m_age_limit = $movie['age_limit']; $m_length = $movie['length_time']; $m_web = $movie['filmweb']; $m_dates = $movie['date']; $m_times = $movie['time']; } else { if ($current_film_date != $movie['date']) { //Different date from last record, show it $m_dates .= "<br>{$movie['date']}"; } else { //Same date as last, line break $m_dates .= "<br>"; } $m_times .= "<br>{$movie['time']}"; } } //Display the last movie displayMovie($m_name, $m_image, $m_age_limit, $m_length, $m_web, $m_dates, $m_times); ?> </td> </tr> </table> <table width="1017" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="" height="63" align="right" valign="top"> </td> <td width="" valign="top"><img src="http://www.vinstrakino.co.cc/test/bilder/bonn.png" width="799" height="63" alt="bånn" /></td> </tr> </table> <p> </p> <hr size="1" color="#000000" /> </body> </html>
-
That line would not produce a login error - at least I can't see how it could. In any event you definitely need it. You must be especially careful when using ANY user input in a query. That command will escape the value of $_POST['idpub'] so that it is safe for a database query. Not using it will open you up to SQL injection which could allow a malicious user to access or destroy your database.