-
Posts
241 -
Joined
-
Last visited
Never
Everything posted by pneudralics
-
[SOLVED] How do I count mysql rows with specific data
pneudralics replied to pneudralics's topic in PHP Coding Help
Got it. Thanks for the help. I had to take the single quotes from the first ip after WHERE. -
[SOLVED] How do I count mysql rows with specific data
pneudralics replied to pneudralics's topic in PHP Coding Help
I get the same thing with mysql_num_rows Both returns zero. -
[SOLVED] How do I count mysql rows with specific data
pneudralics replied to pneudralics's topic in PHP Coding Help
How would I echo the amount of rows with mysql_num_rows? I know how to echo the field in the while loop but not the number of rows it returns. -
[SOLVED] How do I count mysql rows with specific data
pneudralics replied to pneudralics's topic in PHP Coding Help
The if while result didn't work and I got a 0 for the following: $count = mysql_query("SELECT COUNT(data) AS countdata1 FROM data WHERE 'data' = '$data1'"); $num = mysql_fetch_array($count); echo $num['countdata1']; -
I have a table with 5 rows: data1 data1 data1 data1 data2 I want to count only data1. How can I do that? Tried the below but couldn't get it to work $select = 'SELECT * FROM data WHERE data=data1'; if ($result = mysql_query ($select)) { while ($row = mysql_fetch_array ($result)) { $data1 = $row['data']; echo "$data1"; } }
-
It's a login for admin section so I want to block ips after 5 failed attempts and redirect it to an error page.
-
One of my page records ips into the database. When the ip has been recorded more than 5 times I want to allow it to other pages. I can get the current ip to compare to the database ip, once it finds 5 ips in the database I want it redirect it. $ip = $_SERVER['REMOTE_ADDR']; //Select and Retrieve ip $ipselect = "SELECT * FROM ip"; //Counts ips $ipcountresult = mysql_query($ipselect); // Get number of articles, assign value to variable $ipcount = mysql_num_rows($ipcountresult); if ($ipresult = mysql_query ($ipselect)) { while ($row = mysql_fetch_array ($ipresult)) { //Look for ip in database $ip2 = $row['ip']; } } //CAN'T SEEM TO GET THIS PART TO WORK if ($ip = $ip2 and has more than 5 $ip in database) { do this }
-
I kind of thought something like that. How can I fix the problem if I want random questions with the login? Is there a better approach to this?
-
I'm having issues with my login. I have the user and password plus a random question from a database with 3 rows. So I should have a random question (from 3 questions) and the correct answer for the user to be able to login. When I don't use the RAND() in my login everything logs in fine with the same question. When I use RAND() in my question and answer to get random questions to display I seem to have issues. I've echoed the answer and the answer is in the same row as the question so it should log me in. The problem I'm having is it doesn't let me log in even if I input the correct answer. I'll just keep trying different answer from the database and it'll eventually let me login even if the answer is not correct. I can't seem to figure this one out. My isset I got compares the posted answer with the answer from the database but I can't login with it. I guess it'll randomize the answer when I submit and radomly let me login with one of the answers. <?php include ('../c/connect.php'); ?> <center> <img src="/images/logo.gif" alt="" /> <br /> <br /> <b>Login below to proceed...</b> <br /> <br /> <?php //Select and Retrieve and print question/answer query $qselect = "SELECT * FROM question ORDER BY RAND() LIMIT 1"; if ($qresult = mysql_query ($qselect)) { while ($row = mysql_fetch_array ($qresult)) { $question = $row['question']; $answer = $row['answer']; $answer = mysql_real_escape_string ($answer); echo "$answer"; } } //Select and Retrieve username $uselect = "SELECT * FROM admin"; if ($uresult = mysql_query ($uselect)) { while ($row = mysql_fetch_array ($uresult)) { $username = $row['username']; $username = mysql_real_escape_string ($username); } } //Select and Retrieve password $pselect = "SELECT * FROM admin"; if ($presult = mysql_query ($pselect)) { while ($row = mysql_fetch_array ($presult)) { $password = $row['password']; $password = mysql_real_escape_string ($password); } } //Form submission if (isset ($_POST['submit'])) { if ( (!empty ($_POST['username'])) && (!empty ($_POST['password'])) ) { //Check username and password if ( ($_POST['username'] == "$username") && ($_POST['password'] == "$password") ) { //Check answer if (!empty ($_POST['answer']) ) { if ($_POST['answer'] == "$answer") { //Start session session_start(); $_SESSION['username'] = "$username"; //Redirect to index2.php header ('Location: index2.php'); exit (); } else { echo '<font color="red">Your answer was incorrect.</font><br />'; } } else { echo '<font color="red">You left something blank.</font><br />'; } } else { echo '<font color="red">Wrong username or password.</font><br />'; } } else { echo '<font color="red">You left something blank.</font><br />'; } } ?> <br /> <br /> <form action="index.php" method="post"> Username <input type="text" name="username" size="20" maxlength="20" /> <br /> <br /> Password <input type="password" name="password" size="20" maxlength="20" /> <br /> <br /> <b> <?php echo "$question"; ?> </b> <br /> <br /> Answer <input type="text" name="answer" size="20" maxlength="20" /> <br /> <br /> <input type="submit" name="submit" value="Submit" /> </form> </center>
-
I have a form with 3 question and answers which is in the question table with 3 rows. I can't seem to get mysql to update a specific row. Below is my page. Thanks for the help. <?php //This is the page for updating login info session_start(); if(!isset($_SESSION['username'])){ require ("error.php"); } else { include ('header.php'); ?> <table width="800" align="center"> <tr> <td align="center"> <b> <font color="red"><u>IMPORTANT!</u></font> <br /> <br /> This section updates your username and password login. It also updates your question and answer for your login. You may have to refresh the page to see the current Question, Answer, Username, and Password after you update it. <br /> <br /> The password <font color="red">"is not"</font> encrypted in the database. Anyone that have access to the database or the admin section can see the password. Make sure to update the password after you let someone access to the database or the admin section. <br /> <br /> <font color="red"> THE ANSWER, USERNAME, AND PASSWORD "IS" CASE SENSITIVE. ALPHANUMERIC CHARACTERS ONLY EXCEPT FOR THE "?" FOR THE QUESTION SECTION. SPECIAL CHARACTERS WILL AUTOMATICALLY BE STRIPPED. </font> <br /> <br /> </b> </td> </tr> <tr> <td align="center"> <hr /> <?php //Retrieve username and password $uaselect = "SELECT * FROM admin"; if ($uaresult = mysql_query ($uaselect)) { while ($row = mysql_fetch_array ($uaresult)) { $username = $row['username']; $password = $row['password']; } } //Update username and password if (isset ($_POST['uasubmit'])) { $pusername = ($_POST['username']); $pusername = preg_replace('/[^a-zA-Z0-9\s]/', '', trim($pusername)); $ppassword = ($_POST['password']); $ppassword = preg_replace('/[^a-zA-Z0-9\s]/', '', trim($ppassword)); if ( (!empty ($pusername)) && (!empty ($ppassword)) ) { //Update... $updateua = "UPDATE admin SET username=\"$pusername\", password=\"$ppassword\""; $updateuaresult = mysql_query ($updateua); echo '<font color="red">Username and Password has been successfully updated.<br />You may have to refresh the page to see them.</font><br /><br />'; } else { echo '<font color="red">Username or Password is empty.</font><br /><br />'; } } //Retrieve question and answer $qaselect = "SELECT * FROM question WHERE id = 1"; if ($qaresult = mysql_query ($qaselect)) { while ($row = mysql_fetch_array ($qaresult)) { $question = $row['question']; $answer = $row['answer']; } } //Update question and answer if (isset ($_POST['qasubmit'])) { $pquestion = ($_POST['question']); $pquestion = preg_replace('/[^a-zA-Z0-9\s?]/', '', trim($pquestion)); $panswer = ($_POST['answer']); $panswer = preg_replace('/[^a-zA-Z0-9\s]/', '', trim($panswer)); if ( (!empty ($pquestion)) && (!empty ($panswer)) ) { //Update... $updateqa = "UPDATE question WHERE id = 1 SET question=\"$pquestion\", answer=\"$panswer\" LIMIT 1"; $updateqaresult = mysql_query ($updateqa); echo '<font color="red">Question 1 and Answer 1 has been successfully updated.<br />You may have to refresh the page to see them.</font><br /><br />'; } else { echo '<font color="red">Question 1 or Answer 1 is empty.</font><br /><br />'; } } //Retrieve question2 and answer2 $qa2select = "SELECT * FROM question WHERE id = 2"; if ($qa2result = mysql_query ($qa2select)) { while ($row = mysql_fetch_array ($qa2result)) { $question2 = $row['question']; $answer2 = $row['answer']; } } //Update question2 and answer2 if (isset ($_POST['qa2submit'])) { $pquestion2 = ($_POST['question2']); $pquestion2 = preg_replace('/[^a-zA-Z0-9\s?]/', '', trim($pquestion2)); $panswer2 = ($_POST['answer2']); $panswer2 = preg_replace('/[^a-zA-Z0-9\s]/', '', trim($panswer2)); if ( (!empty ($pquestion2)) && (!empty ($panswer2)) ) { //Update... $updateqa2 = "UPDATE question WHERE id = 2 SET question=\"$pquestion2\", answer=\"$panswer2\" LIMIT 1"; $updateqa2result = mysql_query ($updateqa2); echo '<font color="red">Question 2 and Answer 2 has been successfully updated.<br />You may have to refresh the page to see them.</font><br /><br />'; } else { echo '<font color="red">Question 2 and Answer 2 is empty.</font><br /><br />'; } } //Retrieve question3 and answer3 $qa3select = "SELECT * FROM question WHERE id = 3"; if ($qa3result = mysql_query ($qa3select)) { while ($row = mysql_fetch_array ($qa3result)) { $question3 = $row['question']; $answer3 = $row['answer']; } } //Update question3 and answer3 if (isset ($_POST['qa3submit'])) { $pquestion3 = ($_POST['question3']); $pquestion3 = preg_replace('/[^a-zA-Z0-9\s?]/', '', trim($pquestion3)); $panswer3 = ($_POST['answer3']); $panswer3 = preg_replace('/[^a-zA-Z0-9\s]/', '', trim($panswer3)); if ( (!empty ($pquestion3)) && (!empty ($panswer3)) ) { //Update... $updateqa3 = "UPDATE question WHERE id = 3 SET question=\"$pquestion3\", answer=\"$panswer3\" LIMIT 1"; $updateqa3result = mysql_query ($updateqa3); echo '<font color="red">Question 3 and Answer 3 has been successfully updated.<br />You may have to refresh the page to see them.</font><br /><br />'; } else { echo '<font color="red">Question 3 and Answer 3 is empty.</font><br /><br />'; } } ?> <b>Update the username and password</b> <br /> <font size="2">(20 Max Characters Each Alphanumeric Only)</font> <br /> <br /> <form action="logininfo.php" method="post"> Username <input type="text" name="username" size="20" maxlength="20" value="<?php echo "$username"; ?>" /> <br /> <br /> Password <input type="text" name="password" size="20" maxlength="20" value="<?php echo "$password"; ?>" /> <br /> <br /> <input type="submit" name="uasubmit" value="Submit" /> </form> </td> </tr> <tr> <td align="center"> <hr /> <b>Update the question and answer</b> <br /> <font size="2">(50 Max Characters For Question 20 Max For Answer Alphanumeric Only Except for "?" for Question)</font> <br /> <br /> <form action="logininfo.php" method="post"> Question <input type="text" name="question" size="50" maxlength="50" value="<?php echo "$question"; ?>" /> <br /> <br /> Answer <input type="text" name="answer" size="20" maxlength="20" value="<?php echo "$answer"; ?>" /> <br /> <br /> <input type="submit" name="qasubmit" value="Submit" /> </form> </td> </tr> <tr> <td align="center"> <br /> <form action="logininfo.php" method="post"> Question 2 <input type="text" name="question2" size="50" maxlength="50" value="<?php echo "$question2"; ?>" /> <br /> <br /> Answer 2 <input type="text" name="answer2" size="20" maxlength="20" value="<?php echo "$answer2"; ?>" /> <br /> <br /> <input type="submit" name="qa2submit" value="Submit" /> </form> </td> </tr> <tr> <td align="center"> <br /> <form action="logininfo.php" method="post"> Question 2 <input type="text" name="question3" size="50" maxlength="50" value="<?php echo "$question3"; ?>" /> <br /> <br /> Answer 2 <input type="text" name="answer3" size="20" maxlength="20" value="<?php echo "$answer3"; ?>" /> <br /> <br /> <input type="submit" name="qa3submit" value="Submit" /> </form> </td> </tr> </table> <br /> <br /> <br /> <br /> <br /> <?php }//End session else ?>
-
[SOLVED] Can't get mysql to save <img> tags and other html
pneudralics replied to pneudralics's topic in MySQL Help
Got it. I had to use htmlspecialchars() to save it to mysql. I then decode it to display it. -
When I just use regular text in my form it saves it but when I try to enter the below it doesn't save it. Can't figure why..If I manually enter it in the database it'll save it. blahblabh<br>yayaya<br>testing one two<br><img alt="" src="http://l" align="none"><img alt="mustang" src="http://localhost/gallery/mustang1.jpg" align="none"><br> php page <?php //This is the page for updating the policy section session_start(); if(!isset($_SESSION['username'])){ require ("error.php"); } else { include ('header2.php'); ?> <table width="800" align="center"> <tr> <td align="center"> This section updates the policy section. Clicking on the save button will override the current policy information. </td> </tr> </table> <br /> <table width="800" align="center"> <tr> <td align="center"> <?php //Update policy if (isset ($_POST['submit'])) { $policy = ($_POST['policy']); if ( !empty ($policy) ) { //Update... $updatepolicy = "UPDATE policy SET policy=\"$policy\""; $updatepolicyresult = mysql_query ($updatepolicy); echo '<font color="red">Policy section has been updated.</font><br /><br />'; } else { echo '<font color="red">Policy section is empty.</font><br /><br />'; } } ?> [<a href="../policy.php" target="_blank">View Policy Section</a>] <br /> <br /> <b>Update Policy Section Below</b> <br /> <form method="post" action="policy.php"> <textarea name="policy" cols="40" rows="20"> <?php //Retrieve policy info $policyselect = "SELECT * FROM policy"; if ($policyresult = mysql_query ($policyselect)) { while ($row = mysql_fetch_array ($policyresult)) { $policy = $row['policy']; } } echo "$policy"; ?> </textarea> <br /> <br /> <input type="submit" name="submit" value="Save" /> </form> </td> </tr> </table> <?php }//End session else ?> SS
-
[SOLVED] Need some help with string replacement..
pneudralics replied to pneudralics's topic in PHP Coding Help
Got it to work. Thanks. I was just echoing to see what the string was. echo(pathinfo("mystring",PATHINFO_BASENAME)); -
[SOLVED] Need some help with string replacement..
pneudralics replied to pneudralics's topic in PHP Coding Help
Thanks got it working but it also echoes Array after the image name? -
I have a string that has a value of: http://blahblah.com/folder/image.jpg I want to take everything out except for the image.jpg. The image have different names so I want to start with / and delete everything forward of that. Just need some help on accomplishing this. Thanks.
-
I want to have a delete link to delete some images. How would I make unlink() which can delete the file into an active link?
-
Just need a tip to start.. I'm want to display a folder with all the images. How do I do that?
-
Whenever I add in a session to the script I get the following after being logged in: Fatal error: Call to undefined function PrintThumbs() in C:\wamp\www\a\gallery.php on line 123 123: PrintThumbs(); If I take out the session it goes away. Don't know why. <?php //This is the page for uploading the gallery section session_start(); if(!isset($_SESSION['username'])){ require ("error.php"); } else { include ('header.php'); // -------------------phpSimpleGallery v2.1.1 --------------------------- // // author: Craig Atkins from original code by ricocheting.com // date: 18/03/2004 (18th March 05) // version: 2.1.1 (Branched from Gallery 1.01 by ricocheting.com) // description: gallery script that creates it's own thumbnails if GD or imagemagick is installed // Displays comment under the image where appropriate, and uses 'bordered' resizing if needed (GD Only). // license: freeware // updates at: http://coding.1-fix.com // +++++++++++++++USER UPDATABLE VARIABLES BELOw: // Template path (relative to this script) $config['template'] = "gallery.tpt"; // Image Display Template path (this file is only needed if internalDisplay is true) $config['templateImage'] = "galleryImage.tpt"; // max image width/height $config['size'] = 150; // Make thumbnails universal height/width (GD Only at present) $config['universal'] = true; // If using Universal height - what colour do you want the border? (RGB) $config['borderR'] = 255; $config['borderG'] = 255; // 255,255,255 = White. 0,0,0 = Black $config['borderB'] = 255; // Fix the width of the table columns to what size? $config['columnsize'] = $config['size']; //Defaulted to the same size as the image // Use subdirectories of the Image folder as seperate albums? $config['albums'] = true; // jpeg thumbnail image quality $config['imagequality'] = 70; // rows of images per page $config['rows'] = 3; // columns of images per page $config['cols'] = 3; // max page numbers to show at once $config['maxShow'] = 10; // Show file names under the image? (i.e: image1.jpg) $config['fileName'] = false; // Display images within phpSimpleGallery // Setting true will show images within your template when clicked // Setting false will make the images open in a new window on their own (with no html) $config['internalDisplay'] = true; // default sort order. Values 'nameASC','nameDESC','oldFIRST','newFIRST'. $config['sortOrder'] = "newFIRST"; //Defaulted to show newest images first. // folder where full size images are stored (include trailing slash) $config['fulls']="../gallery/"; // name of subfolder where thumbnails are to be created $config['thumbs'] = $config['fulls']."thumbs"; // delete redundant thumbnails? 0 - No, 1 - Yes, check monthly, 2 - Yes, check every time $config['deleteThumbs'] = 2; // method to create thumbnails. options: gd2, imagemagick $config['imagemethod'] = "gd2"; // (if imagemagick) - Path to Imagemagick "convert" program $config['convert'] = "/usr/bin/convert"; // (if imagemagick) - Path to Imagemagick "identify" program $config['identify'] = "/usr/bin/identify"; // +++++++++++++++ONLY CHANGE HTML CODE BELOW THIS LINE! $config['start'] = 0; $config['max'] = 0; $config['page'] = isset($_GET['page'])?$_GET['page']:"0"; //$config['version'] = "<a href=\"http://coding.1-fix.com/php-scripts.htm\" target=\"_BLANK\">Powered by phpSimpleGallery 2.1.1</a>"; $sortOrd = isset($_GET['sort'])?$_GET['sort']:""; $IMperPage = isset($_GET['perPage'])?$_GET['perPage']:""; $config['album'] = isset($_GET['album'])?$_GET['album']:""; $tpt_position = "0"; $tpt_totalimages = "0"; $tpt_imagetable = ""; $tpt_linknext =""; $tpt_linkprev = ""; $tpt_firstdivide = "-"; $tpt_lastdivide = "-"; $tpt_pages = ""; $tpt_sortorder = ""; $tpt_imgperpage = ""; $imageFolder = ""; if (!file_exists($config['template'])) { oops("Template file for gallery: <b>$config[template]</b> does not exist. Check gallery.php - the value of config[template] is probably incorrect."); die; }else{ $html_out = file_get_contents($config['template']); } ####################################################################### // see if we have been given an image to view. // if so, open it up (if viewing internal) if((isset($_GET['entry'])) && ($config['internalDisplay'] == true)){ GetEntry(); }else{ PrintThumbs(); } ####################################################################### #-############################################# # desc: prints out html for thumbnails of images in directory function PrintThumbs(){ global $config; global $html_out; global $sortOrd; global $IMperPage; global $imageFolder; global $tpt_position, $tpt_totalimages, $tpt_imagetable, $tpt_linknext, $tpt_linkprev, $tpt_firstdivide, $tpt_lastdivide, $tpt_pages, $tpt_sortorder, $tpt_imgperpage; if (!file_exists($config['fulls'])) { oops("directory <b>$config[fulls]</b> does not exist"); die; } //thumb directory if (!file_exists($config['thumbs'])) { if (!mkdir($config['thumbs'], 0755)) { oops("Could not create thumb directory <b>$config[thumbs]</b> - check write permissions"); die; } } // Check if thumbs need deletion ProcessThumbDelete(); if ($config['albums'] == true){ $albumlist = GetAlbumList($config['fulls']); } if (!empty($sortOrd)) { $config['sortOrder'] = $sortOrd; } if (!empty($IMperPage)) { if($IMperPage=="9"){ $config['rows'] = 3; $config['cols'] = 3; }elseif($IMperPage=="15"){ $config['rows'] = 5; $config['cols'] = 3; }elseif($IMperPage=="25"){ $config['rows'] = 5; $config['cols'] = 5; }elseif($IMperPage=="50"){ $config['rows'] = 10; $config['cols'] = 5; } } if($config['albums'] == true){ // If we are working with albums, then get the image list for the selected album if (empty($config['album'])){ $imageFolder = $config['fulls']; }else{ $imageFolder = $config['fulls'].$config['album']."/"; } if ((GetFileCount($imageFolder) == 0) && (empty($config['album'])) && (count($albumlist) > 0)){ $config['album'] = $albumlist[0]; $imageFolder = $config['fulls'].$config['album']."/"; } $imagelist = GetFileList($imageFolder,0); }else{ $imageFolder = $config['fulls']; $imagelist = GetFileList($imageFolder,0); } // echo count($imagelist); //processing for how many images to do on current page $config['start']=($config['page']*$config['cols']*$config['rows']); $config['max']=( ($config['page']*$config['cols']*$config['rows']) + ($config['cols']*$config['rows']) ); if($config['max'] > count($imagelist)){$config['max']=count($imagelist);} #if there is 0 matches, show 0. otherwise show ($start+1) if ($config['max'] == "0"){$tpt_position = "0 - 0"; $tpt_totalimages = "0";} else{$tpt_position = ($config['start']+1)." - $config[max]"; $tpt_totalimages = count($imagelist)."";} $temp=1; //for all the images on the page for($i=$config['start']; $i<$config['max']; $i++){ if (preg_match("/\.(bmp)$/i",$imagelist[$i])) { $thumb_image = $config['thumbs']."/".$config['album'].$imagelist[$i].".jpg"; $thumb_exists = file_exists($thumb_image); }else{ $thumb_image = $config['thumbs']."/".$config['album'].$imagelist[$i]; $thumb_exists = file_exists($thumb_image); } $desc_file = $imageFolder.$imagelist[$i].".txt"; $desc_exists = file_exists($desc_file); // create thumb if not exist if(!$thumb_exists){ // Check for safe mode if( !ini_get('safe_mode') ){ set_time_limit(30); } $thumb_exists = ResizeImage("$imageFolder$imagelist[$i]", $thumb_image, $config['size']); }else{ // If a thumbnail exists then check it's newer than the source.. otherwise, make a new thumb if(strftime(filemtime($thumb_image)) < strftime(filemtime("$imageFolder$imagelist[$i]"))){ // Check for safe mode if( !ini_get('safe_mode') ){ set_time_limit(30); } $thumb_exists = ResizeImage("$imageFolder$imagelist[$i]", $thumb_image, $config['size']); } } $imagelist[$i] = rawurlencode($imagelist[$i]); if (preg_match("/\.(bmp)$/i",$imagelist[$i])) { $thumb_image = $config['thumbs']."/".$config['album'].$imagelist[$i].".jpg"; }else{ $thumb_image = $config['thumbs']."/".$config['album'].$imagelist[$i]; } $tpt_imagetable = $tpt_imagetable . "<td align=\"center\" valign=\"top\" class=\"border\" width=\"$config[columnsize]\"><div align=\"center\">"; if($config['internalDisplay'] == true){ // If we are displaying internally then point the link back to this program $tpt_imagetable = $tpt_imagetable . "<a href=\"".GetBaseURL()."?entry=$imageFolder$imagelist[$i]\">"; }else{ // Otherwise point it to the image file itself $tpt_imagetable = $tpt_imagetable . "<a href=\"$imageFolder$imagelist[$i]\" target=\"_blank\">"; } if ($thumb_exists) { $tpt_imagetable = $tpt_imagetable . "<img src=\"$thumb_image\" border=\"0\" alt=\"$imagelist[$i]\">"; } else { if($config['fileName'] == false){ // We don't want to write out the Image Name if we are showing the filenames // otherwise we will end up with it twice!! $tpt_imagetable = $tpt_imagetable . "$imagelist[$i]"; } } if(!$desc_exists){ // Check if the file has a description txt file, and then display the description if($config['fileName'] == true){ // If we are showing file names then add this under the image $tpt_imagetable = $tpt_imagetable . "<br>$imagelist[$i]</a></div></td>\n"; }else{ $tpt_imagetable = $tpt_imagetable . "</a></div></td>\n"; } }else{ $handle = fopen($desc_file, "r"); if (!feof($handle)) { $desc_text = fgetss($handle, 1024); } fclose($handle); if($config['fileName'] == true){ $tpt_imagetable = $tpt_imagetable . "<br>$imagelist[$i]</a><br>" . $desc_text . "</div></td>\n"; }else{ $tpt_imagetable = $tpt_imagetable . "</a><br>" . $desc_text . "</div></td>\n"; } } //if the max cols is reached, start new col if(($temp == $config['cols']) && ($i+1 != $config['max'])){ $tpt_imagetable = $tpt_imagetable . "</tr><tr><td colspan=\"$config[cols]\" class=\"spacer\"> </td></tr><tr>\n"; $temp=0; } $temp++; }//foreach img //if there are no results if($config['start'] == $config['max']){ $tpt_imagetable = "<td align=\"center\" colspan=\"$config[cols]\" class=\"spacer\">No Entries found</td>\n"; } //if there are empty "boxes" in the row (ie; last page) elseif($temp != $config['cols']+1){ $tpt_imagetable = $tpt_imagetable . "<td align=\"center\" colspan=\"".($config['cols']-$temp+1)."\"> </td>\n"; } $tpt_imagetable = $tpt_imagetable . "</tr>"; $tpt_imgperpage = "<select name=\"perPage\" onChange=\"phpSG_Dropdown();\">\n"; if($IMperPage=="9"){ $tpt_imgperpage = $tpt_imgperpage . "<option value=\"9\" selected>9</option>"; }else{ $tpt_imgperpage = $tpt_imgperpage . "<option value=\"9\">9</option>"; } if($IMperPage=="15"){ $tpt_imgperpage = $tpt_imgperpage . "<option value=\"15\" selected>15</option>"; }else{ $tpt_imgperpage = $tpt_imgperpage . "<option value=\"15\">15</option>"; } if($IMperPage=="25"){ $tpt_imgperpage = $tpt_imgperpage . "<option value=\"25\" selected>25</option>"; }else{ $tpt_imgperpage = $tpt_imgperpage . "<option value=\"25\">25</option>"; } if($IMperPage=="50"){ $tpt_imgperpage = $tpt_imgperpage . "<option value=\"50\" selected>50</option>"; }else{ $tpt_imgperpage = $tpt_imgperpage . "<option value=\"50\">50</option>"; } $tpt_imgperpage = $tpt_imgperpage . "</select>"; $tpt_sortorder = "<select name=\"sortOrd\" onChange=\"phpSG_Dropdown();\">\n"; if($config['sortOrder'] == "nameASC"){ $tpt_sortorder = $tpt_sortorder . "<option value=\"nameASC\" selected>Name Ascending</option>"; }else{ $tpt_sortorder = $tpt_sortorder . "<option value=\"nameASC\">Name Ascending</option>"; } if($config['sortOrder'] == "nameDESC"){ $tpt_sortorder = $tpt_sortorder . "<option value=\"nameDESC\" selected>Name Descending</option>"; }else{ $tpt_sortorder = $tpt_sortorder . "<option value=\"nameDESC\">Name Descending</option>"; } if($config['sortOrder'] == "newFIRST"){ $tpt_sortorder = $tpt_sortorder . "<option value=\"newFIRST\" selected>Newest First</option>"; }else{ $tpt_sortorder = $tpt_sortorder . "<option value=\"newFIRST\">Newest First</option>"; } if($config['sortOrder'] == "oldFIRST"){ $tpt_sortorder = $tpt_sortorder . "<option value=\"oldFIRST\" selected>Oldest First</option>"; }else{ $tpt_sortorder = $tpt_sortorder . "<option value=\"oldFIRST\">Oldest First</option>"; } $tpt_sortorder = $tpt_sortorder . "</select><input type=\"hidden\" name=\"album\" value=\"".$config['album']."\">"; GetPageNumbers(count($imagelist)); // Do our template Replaces $html_out = str_replace("<!--Columns//-->", $config['cols'], $html_out); $html_out = str_replace("<!--Position//-->", $tpt_position, $html_out); $html_out = str_replace("<!--Max//-->", $tpt_totalimages, $html_out); $html_out = str_replace("<!--TotalPages//-->", $config['totalPages'], $html_out); $html_out = str_replace("<!--LinkPrev//-->", $tpt_linkprev, $html_out); $html_out = str_replace("<!--LinkNext//-->", $tpt_linknext, $html_out); $html_out = str_replace("<!--FirstDivide//-->", $tpt_firstdivide, $html_out); $html_out = str_replace("<!--LastDivide//-->", $tpt_lastdivide, $html_out); $html_out = str_replace("<!--Pages//-->", $tpt_pages, $html_out); $html_out = str_replace("<!--ImgPerPage//-->", $tpt_imgperpage, $html_out); $html_out = str_replace("<!--SortOrder//-->", $tpt_sortorder, $html_out); $html_out = str_replace("<!--ImageTable//-->", $tpt_imagetable, $html_out); if ($config['albums'] == true){ $html_out = str_replace("<!--AlbumList//-->", BuildAlbumList($albumlist), $html_out); }else{ $html_out = str_replace("<!--AlbumList//-->", "", $html_out); } $html_out = str_replace("<!--VersionFooter//-->", $config['version'], $html_out); echo $html_out; }#-#PrintThumbs() #-############################################# # desc: ProcessThumbDelete() # param: none # returns: nothing function ProcessThumbDelete(){ global $config; $totalImgCount = 0; $totalThumbCount = 0; if(($config['deleteThumbs'] == 2) || ($config['deleteThumbs'] == 1 && date(j) == 1)){ //Let's count the total thumbnails we have $totalThumbCount = GetFileCount($config['thumbs']); //Now let's count the total images we have in all directories if ($config['albums'] == true){ // Count the files in the root folder $totalImgCount = GetFileCount($config['fulls']); $albumlist = GetAlbumList($config['fulls']); // Loop through the album list counting the images in folders for($i=0; $i<count($albumlist) ; $i++){ $totalImgCount = $totalImgCount + GetFileCount($config['fulls'].$albumlist[$i]."/"); } if($totalThumbCount > $totalImgCount){ $thumbFiles = GetFileList($config['thumbs'],1); for($i=0; $i<count($albumlist) ; $i++){ $imageFiles = GetFileList($config['fulls'].$albumlist[$i]."/",1); for($j=0; $j<count($imageFiles) ; $j++){ if (preg_match("/\.(bmp)$/i",$imageFiles[$j])) { $imgFileName = $albumlist[$i].$imageFiles[$j].".jpg"; }else{ $imgFileName = $albumlist[$i].$imageFiles[$j]; } $key = array_search($imgFileName, $thumbFiles); if($key !== false){ $thumbFiles = array_trim($thumbFiles, $key); } } } // Now loop through our array of remaining items and kill off the files that are misfits for($i=0; $i<count($thumbFiles); $i++){ unlink($config['thumbs']."/".$thumbFiles[$i]); } } }else{ $totalImgCount = GetFileCount($config['fulls']); if($totalThumbCount > $totalImgCount){ $thumbFiles = GetFileList($config['thumbs'],1); $imageFiles = GetFileList($config['fulls'],1); for($i=0; $i<$totalImgCount ; $i++){ if (preg_match("/\.(bmp)$/i",$imageFiles[$i])) { $imgFileName = $imageFiles[$i].".jpg"; }else{ $imgFileName = $imageFiles[$i]; } $key = array_search($imgFileName, $thumbFiles); if($key !== false){ $thumbFiles = array_trim($thumbFiles, $key); } } // Now loop through our array of remaining items and kill off the files that are misfits for($i=0; $i<count($thumbFiles); $i++){ unlink($config['thumbs']."/".$thumbFiles[$i]); } } } } }#-#ProcessThumbDelete() #-############################################# # desc: BuildAlbumList($dirArr) # param: dirArr - Array of folders to look at # returns: html listing of folders function BuildAlbumList($dirArr){ global $config,$sortOrd,$IMperPage; $albumhtml = ""; // If we have a 'root' image directory with files, then show a link back to it if(GetFileCount($config['fulls']) > 0){ if ($config['album'] == ""){ $albumhtml = $albumhtml."<div class=\"currentAlbum\">Gallery Home</div><br>"; }else{ $albumhtml = $albumhtml."<a href=\"".GetBaseURL()."?page=&sort=$sortOrd&perPage=$IMperPage&album=\" class=\"albums\">Gallery Home</a><br><br>"; } } for($i=0; $i<count($dirArr) ; $i++){ if($dirArr[$i] == $config['album']){ $albumhtml = $albumhtml."<div class=\"currentAlbum\">".$dirArr[$i]."</div>"; }else{ $albumhtml = $albumhtml."<a href=\"".GetBaseURL()."?page=&sort=$sortOrd&perPage=$IMperPage&album=".$dirArr[$i]."\" class=\"albums\">".$dirArr[$i]."</a><br>"; } } return $albumhtml; }#-#BuildAlbumList() #-############################################# # desc: Displays image passed from querystring # returns: (bool) worked function GetEntry(){ global $config; if(!file_exists("$_GET[entry]")){ oops("Sorry, the image you have chosen to view does not exist"); return false; } if (!file_exists($config['templateImage'])) { oops("Template file for image display: <b>$config[templateImage]</b> does not exist. Check gallery.php - the value of config[templateImage] is probably incorrect."); die; }else{ $html_out = file_get_contents($config['templateImage']); } $desc_file = $_GET[entry].".txt"; $desc_exists = file_exists($desc_file); if ($desc_exists) { $handle = fopen($desc_file, "r"); if (!feof($handle)) { $desc = fgetss($handle, 1024); } fclose($handle); }else{ $desc = "No Description"; } // Do our template Replaces $html_out = str_replace("<!--LinkBack//-->", "<a href=\"$_SERVER[HTTP_REFERER]\">BACK</a>", $html_out); $html_out = str_replace("<!--Modified//-->", date ("F d Y H:i:s.", filemtime($_GET[entry])), $html_out); $html_out = str_replace("<!--Filename//-->", basename($_GET[entry]), $html_out); $html_out = str_replace("<!--Description//-->", $desc, $html_out); $html_out = str_replace("<!--Image//-->", "<img src=\"$_GET[entry]\">", $html_out); $html_out = str_replace("<!--VersionFooter//-->", $config['version'], $html_out); echo $html_out; }#-#GetEntry() #-############################################# # desc: GetFileCount # param: directory to look through # returns: number of images in folder function GetFileCount($dirname="."){ $filecnt = 0; if ($handle = opendir($dirname)) { while (false !== ($file = readdir($handle))) { if (preg_match("/\.(jpe?g|gif|png|bmp)$/i",$file)) { $filecnt++; } } closedir($handle); } return $filecnt; }#-#GetFileCount() #-############################################# # desc: GetFileList # param: [optional] directory to look through # returns: array with list of images function GetFileList($dirname=".",$nosort=0){ global $config; $list = array(); if ($handle = opendir($dirname)) { while (false !== ($file = readdir($handle))) { if (preg_match("/\.(jpe?g|gif|png|bmp)$/i",$file)) { $list[] = $file; } } closedir($handle); } if($nosort == 0){ if($config['sortOrder'] == "nameASC"){ sort($list); reset($list); }elseif($config['sortOrder'] == "nameDESC"){ rsort($list); reset($list); }elseif($config['sortOrder'] == "oldFIRST"){ usort($list, 'sortOld'); }elseif($config['sortOrder'] == "newFIRST"){ usort($list, 'sortNew'); }else{ sort($list); reset($list); } } return $list; }#-#GetFileList() #-############################################# # desc: GetAlbumList # param: StartFolder - Folder to look through # returns: array with list of albums function GetAlbumList($dirname){ global $config; $oldDir = getcwd(); $list = array(); if ($handle = opendir($dirname)) { chdir($dirname); while (false !== ($file = readdir($handle))) { if ((is_dir($file)) && ($file != ".") && ($file != "..")) { if ($config['fulls'].$file != $config['thumbs']){ $list[] = $file; } } } closedir($handle); chdir($oldDir); } sort($list); reset($list); return $list; }#-#GetAlbumList() #-############################################# # desc: sorts an array of filenames based on file dates - Old to New function sortOld($x, $y) { global $config; global $imageFolder; if (strftime(filemtime($imageFolder.$x)) == strftime(filemtime($imageFolder.$y))) return 0; else if (strftime(filemtime($imageFolder.$x)) < strftime(filemtime($imageFolder.$y))) return -1; else return 1; } #-############################################# # desc: sorts an array of filenames based on file dates - New to Old function sortNew($x, $y) { global $config; global $imageFolder; if (strftime(filemtime($imageFolder.$x)) == strftime(filemtime($imageFolder.$y))) return 0; else if (strftime(filemtime($imageFolder.$x)) > strftime(filemtime($imageFolder.$y))) return -1; else return 1; } #-############################################# # desc: throw an error message # param: [optional] any custom error to display function oops($msg) { ?> <table align=center> <tr><td class=header> Error </td></tr> <tr><td class=entry> <br><?=$msg?> <br><br> <hr size=1 noshade width="80%" class=desc> <center>Please hit the <a href="javaScript:history.back();"><b>back button</b></a> on your browser to try again.</center> </td></tr></table> <?php }#-#oops() #-############################################# # desc: chooses method to resize image to correct ratio # param: ($image) image reference of full size img to use ($newimage) what to save thumbnail as ($size) max width or height to resize to # returns: (bool) if image was created function ResizeImage($image, $newimage, $size) { global $config; switch ($config['imagemethod']) { case "imagemagick": return ResizeImageUsingIM($image, $newimage, $size); break; case "gd1": case "gd2": return ResizeImageUsingGD($image, $newimage, $size); break; default: return false; break; } }#-#ResizeImage() #-############################################# # desc: resizes image if GD was used # param: ($image) image reference of full size img to use ($newimage) what to save thumbnail as ($size) max width or height to resize to # returns: (bool) if image was created function ResizeImageUsingGD($image, $newimage, $size) { global $config; list ($width,$height,$type) = GetImageSize($image); if($im = ReadImageFromFile($image,$type)){ //if image is smaller than the $size, make it actual $size if($height < $size && $width < $size){ $newheight=$height; $newwidth=$width; } //if image height is larger, height=$size, then calc width else if($height > $width){ $newheight=$size; $newwidth=($width / ($height/$size));//cast the resized width as int } //if image width is larger, width=$size, then calc width else{ $newwidth=$size; $newheight=($height / ($width/$size));//cast the resized height as int } if(!$config['universal']){ $im2=ImageCreateTrueColor($newwidth,$newheight); ImageCopyResampled($im2,$im,0,0,0,0,$newwidth,$newheight,$width,$height); }else{ $im2=ImageCreateTrueColor($size,$size); $background = imagecolorallocate($im2, $config['borderR'], $config['borderG'], $config['borderB']); imagefilledrectangle($im2, 0, 0, $size - 1, $size - 1, $background); if($newwidth==$size){ ImageCopyResampled($im2,$im,0,(($size-$newheight)/2),0,0,$newwidth,$newheight,$width,$height); }else if($newheight==$size){ ImageCopyResampled($im2,$im,(($size-$newwidth)/2),0,0,0,$newwidth,$newheight,$width,$height); } } if(WriteImageToFile($im2,$newimage,$type)){ return true; } } return false; }#-#ResizeImageUsingGD() #-############################################# # desc: resizes image using imagemagick # param: ($image) image reference of full size img to use ($newimage) what to save thumbnail as ($size) max width or height to resize to # returns: (bool) if image was created function ResizeImageUsingIM($image, $newimage, $size) { global $config; Exec("$config[identify] -ping -format \"%w %h\" \"$image\"", $sizeinfo); if (! $sizeinfo ) { return false; } $size = explode(" ", $sizeinfo[0]); $width = $size[0]; $height = $size[1]; if (!$width) { return false; } //if image is smaller than the 160 container, make it actual size if($height < $size && $width < $size){ $newheight=$height; $newwidth=$width; } //if image height is larger, height=$size, then calc width else if($height > $width){ $newheight=$size; $newwidth=($width / ($height/$size));//cast the resized width as int } //if image width is larger, width=$size, then calc width else{ $newwidth=$size; $newheight=($height / ($width/$size));//cast the resized height as int } Exec("$config[convert] -geometry \"$newwidth"."x"."$newheight\" -quality \"$config[imagequality]\" \"$image\" \"$newimage\""); return file_exists($newimage); }#-#ResizeImageUsingIM() #-############################################# # desc: resizes image using imagemagick # param: ($filename) filename of image to create ($type) int of type. 1=gif,2=jpeg,3=png # returns: binary img function ReadImageFromFile($filename, $type) { $imagetypes = ImageTypes(); switch ($type) { case 1 : if ($imagetypes & IMG_GIF){ return $im = ImageCreateFromGIF($filename); } break; case 2 : if ($imagetypes & IMG_JPEG){ return ImageCreateFromJPEG($filename); } break; case 3 : if ($imagetypes & IMG_PNG){ return ImageCreateFromPNG($filename); } case 6 : if (!include_once('phpthumbs.bmp.php')) { oops("You do not appear to have phpthumbs.bmp.php installed in the same path as gallery.php. Please add this file, or remove .bmp files from your image directory"); } $phpThumbBMP = new phpthumb_bmp(); return $phpThumbBMP->phpthumb_bmpfile2gd($filename); break; default: return 0; } }#-#ReadImageFromFile() #-############################################# # desc: resizes image using imagemagick # returns: binary img function WriteImageToFile($im, $filename, $type) { global $config; switch ($type) { case 1 : return ImageGIF($im, $filename); case 2 : return ImageJpeg($im, $filename, $config['imagequality']); case 3 : return ImagePNG($im, $filename); case 6: return ImageJpeg($im, $filename, $config['imagequality']); default: return false; } }#-#WriteImageToFile() #-############################################# # sub: GetPageNumbers # desc: gets the pages in the list function GetPageNumbers($entries) { global $config; global $sortOrd, $IMperPage; global $tpt_pages, $tpt_firstdivide, $tpt_lastdivide, $tpt_linknext, $tpt_linkprev; if (!empty($IMperPage)){ $perPage = $IMperPage; }else{ $perPage = ""; } $config['totalPages']=Ceil(($entries)/($config['cols']*$config['rows'])); // echo out PREV if( ($config['page']-1) >= 0){ $tpt_linkprev = " <a href=\"".GetBaseURL()."?page=".($config['page']-1)."&sort=$sortOrd&perPage=$perPage&album=".$config['album']."\" class=\"arrow\"><</a> ";} // else no link else{$tpt_linkprev = " <font class=\"arrow\"><</font> ";} // for each link, echo out page link $start=0; // starting image number $end=$config['totalPages']-1; // ending image number (total / number image on page) // cutoff size < page. or . page != last page (otherwise keep above values) if($config['maxShow'] < $config['page'] || (($config['cols']*$config['rows']*$config['maxShow'])< $entries) ){ // if page >= cutoff size+1 -> start at page - cutoff size if($config['page'] >= ($config['maxShow']+1) && $config['page'] < $end-$config['maxShow']){ $start = $config['page']-$config['maxShow'];} elseif($end < $config['page']+$config['maxShow']+1 && $config['totalPages']-1 >= $config['maxShow']*2+1){$start = $config['totalPages']-1-$config['maxShow']*2;} else{$start=0;} // else start at 0 // if page+cutoff+1 > number of pages total -> end= number of pages total if( $config['page']+$config['maxShow']+1 > $config['totalPages']-1 ){$end = $entries/($config['cols']*$config['rows']);} #&oops("$end,$config['maxShow']"); elseif($start == 0 && $end > $config['maxShow']*2){$end = $config['maxShow']*2;} elseif($start == 0 && $config['totalPages'] <= $config['maxShow']*2){$end = $config['totalPages']-1;} else{$end = ($config['page']+$config['maxShow']);} //end = page+cutoff+1 } // echo out divide marker if($start > 0){$tpt_firstdivide = "...";} else{$tpt_firstdivide = "";} // echo out each of the numbers for($i=$start; $i<=$end ; $i++){ if($config['page']==$i){$tpt_pages = $tpt_pages . "<font class=\"pageon\">".($i+1)."</font> \n";} else{$tpt_pages = $tpt_pages . "<a href=\"".GetBaseURL()."?page=$i&sort=$sortOrd&perPage=$perPage&album=".$config['album']."\" class=\"pageoff\">".($i+1)."</a> \n";} } // echo out divide marker if(Ceil($end) < $config['totalPages']-1){$tpt_lastdivide = "...";} else{$tpt_lastdivide = "";} // echo out NEXT if( ($config['page']+1) <= $config['totalPages']-1){ $tpt_linknext = "<a href=\"".GetBaseURL()."?page=".($config['page']+1)."&sort=$sortOrd&perPage=$perPage&album=".$config['album']."\" class=\"arrow\">></a> ";} // else no link else{$tpt_linknext = " <font class=\"arrow\">></font> ";} }#-#end GetPageNumbers() function GetBaseURL(){ $script_path = pathinfo($_SERVER['SCRIPT_NAME']); return $script_path['basename']; // Returns "test.php" } /* Usage: $array : Array $indey : Integer The value of $array at the index $index will be deleted by the function. */ function array_trim ( $array, $index ) { if ( is_array ( $array ) ) { unset ( $array[$index] ); array_unshift ( $array, array_shift ( $array ) ); return $array; } else { return false; } } }//End session else ?>
-
The form below uploads youtube video link ex: To the database. I want the ease of just copying the link but want to get rid of "http://www.youtube.com/watch?v=" when I upload the link to my database. How would I filter that out. <?php //This is the page for the video section include ('header.php'); //Retrieve video info $videoselect = "SELECT * FROM video"; if ($videoresult = mysql_query ($videoselect)) { while ($row = mysql_fetch_array ($videoresult)) { $url = $row['url']; $description = $row['description']; ?> <table width="800" align="center"> <tr> <td align="center"> <object width="425" height="344"> <param name="movie" value="<?php echo "$url"; ?>&hl=en&fs=1"></param> <param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param> <embed src="<?php echo "$url"; ?>&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed> </object> <br /> <?php echo "$description"; ?> </td> </tr> </table> <?php }//End while loop }//end if while ?>
-
Anyone know of a good simple php picture gallery script?
pneudralics posted a topic in Miscellaneous
I don't need one with admin I just need a simple one that will get the images, create a thumbnail and paginate the images. Thanks. -
I'm testing out my file on wampserver and get the following error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 <?php include('c/connect.php'); include('header.php'); // Paging if(isset($_GET['page'])){ $page=$_GET['page']-1; }else{ $page=0; } $imagepath = WEBSITEURL.'images/gallery/'; $imagethumbnailpath = WEBSITEURL.'images/t/'; ?> <table width="800" bgcolor="#FFFFFF" align="center"><!--Start big table--> <tr> <td width="60%" valign="top" align="center"> <?php // Count All the items >> $q= "SELECT count(id) AS items_count FROM gallery;"; $r= mysql_query($q) or die (mysql_error()); $row = mysql_fetch_array($r,MYSQL_ASSOC); $items_count=$row['items_count']; // Count All the items << $q= "SELECT * FROM gallery ORDER BY id DESC LIMIT ".$page*$page_size.",".$page_size.";"; $r= mysql_query($q) or die (mysql_error()); if(mysql_num_rows($r)>0){ $current_colum=0; ?> <table> <?php while ($row = mysql_fetch_array($r,MYSQL_ASSOC)){ $current_colum++; if($current_colum==1){ ?> <tr> <?php } ?> <td valign="top"> <table bgcolor="#e4ecf0"> <tr> <td valign="top"> <a href="<?php echo $imagepath.$row['image']; ?>"><?php echo '<img src="'.$imagepath.$row['image'].'" width="150" height="150"' ?><?php echo " alt=\"$rowtitle\" /><br />"; ?></a> </td> </tr> </table> </td> <?php if($current_colum==3){ $current_colum=0; ?> </tr> <?php } }//End while if($current_colum!=0){ if($current_colum==1){ ?> <td> </td> <td> </td> <?php } if($current_colum==2){ ?> <td> </td> <?php } ?> </tr> <?php } ?> </table> <?php }// if(mysql_num_rows($r)>0){ // PAGING >> if ($items_count>$page_size) { $content.='<br />'; if ($page>0) { $content.='<a href="'.basename($_SERVER['PHP_SELF']).'?page='.($page).'"><b>Previous</b></a> '; } $content.='<b>'; for($z=0;$z<($items_count/$page_size);$z++) { if (($z>$page-$max_pages_to_show)&&($z<$page+$max_pages_to_show)) { if ($z==$page) { $content.=' '.($z+1).' '; } else { $content.=' <a href="'.basename($_SERVER['PHP_SELF']).'?page='.($z+1).'">'.($z+1).'</a> '; } } } if ($z>$page+1) { $content.='</b> <a href="'.basename($_SERVER['PHP_SELF']).'?page='.($page+2).'"><b>Next</b></a>'; } else { $content.='</b>'; } $content.='<br/><br/>'; echo $content; } // PAGING << ?> </td> <td width="20%" valign="top"> </td> </tr> </table><!--End big table-->
-
I'm trying to learn how to display data results in multiple column. Can't seem to get php to echo <tr> and </tr> after counting certain amount of data. //Retrieve gallery info $galleryselect = "SELECT * FROM gallery ORDER BY id ASC"; //Count results $count_gallery_result = mysql_query($galleryselect); //Get counted results $count_gallery = mysql_num_rows($count_gallery_result); if ($galleryresult = mysql_query ($galleryselect)) { while ($row = mysql_fetch_array ($galleryresult)) { $gallery = $row['image']; ?> <?php if ($count_gallery == 3) { echo '<tr>'; } echo "<td>$gallery</td>"; if ($count_gallery == 0) { echo '</tr>';
-
I can't get nicedit to show in my textareas. I also tried tinymce and couldn't do it either. The below is currently what I have. <?php //This is the page for updating the contactus section session_start(); if(!isset($_SESSION['username'])){ require ("error.php"); } else { include ('header.php'); ?> <script src=”<?php echo 'http://localhost/nicEdit.js'; ?>” type=”text/javascript”></script> <script type=”text/javascript”> bkLib.onDomLoaded(nicEditors.allTextAreas); </script> <table width="800" align="center"> <tr> <td align="center"> This section updates the contactus section. Clicking on the save button will override the current Contact Us information. </td> </tr> </table> <br /> <table width="800" align="center"> <tr> <td align="center"> <?php //Update contactus if (isset ($_POST['submit'])) { $contactus = ($_POST['contactus']); $contactus = trim(htmlentities($contactus)); if ( !empty ($contactus) ) { //Update... $updatecontactus = "UPDATE contactus SET contactus=\"$contactus\""; $updatecontactusresult = mysql_query ($updatecontactus); echo '<font color="red">Contact Us section has been updated.</font><br /><br />'; } else { echo '<font color="red">Contact Us section is empty.</font><br /><br />'; } } ?> [<a href="../contactus.php" target="_blank">View Contact Us Section</a>] <br /> <br /> <b>Update Contact Us Section Below</b> <br /> <form method="post" action="contactus.php"> <textarea name="contactus" cols="40" rows="20"> <?php //Retrieve contactus info $contactusselect = "SELECT * FROM contactus"; if ($contactusresult = mysql_query ($contactusselect)) { while ($row = mysql_fetch_array ($contactusresult)) { $contactus = $row['contactus']; } } echo "$contactus"; ?> </textarea> <br /> <br /> <input type="submit" name="submit" value="Save" /> </form> </td> </tr> </table> <?php }//End session else ?>