PHP - Improving Website
hi everyone, first time in the forum, english is not my first language so i apologize for the spelling...
i manage a website i did some years ago for a car sell place..
in the website i have to upload the new cars and download the ones that have been sold every month...
now that takes a lot of time, i have to send them a list and they tell me wich ones add to the list and wich ones remove, for every car i have a litle box with picture and some data, whenyou clik it it sends you to a small page with some more pictures of that car and some more text.. so every time i have to create a new page for every car and put the pictures on it...
i would like to have some sort of database with the list of all the active cars that i can get with one clik... then... i would like to have some sort of form where i can drag the pictures and it takes one of them with some of the information and creates the small post of the car and the other biger one with the other pictures and the rest of the info...
i dont know if im expressing my self welll
any ideas?
this is the site: www.laradialautomoviles.com
its the first site i ever did about 5 years ago, i never studied webdesign dont have the money to do it... so please dont criticize XD
Similar TutorialsHi, I'm trying to improve my search so that it searches all words that i write in the search box and matches keywords my code right now is Code: [Select] <?php $sub = $_GET['article']; echo "<h2>search results for: $sub</h2><br><br>"; $sub = str_replace(" ", "%", $sub); $alb = mysql_connect("localhost", "", "") or die(mysql_error()); mysql_select_db("articles") or die(mysql_error()); mysql_set_charset('utf8', $alb); $query2 = "SELECT * FROM `blog` WHERE `title` like '%$sub%'"; $result2 = mysql_query($query2) or die(mysql_error()); while ($postede2 = mysql_fetch_assoc($result2)) { $title = "{$postede2['title']}"; $author = "{$postede2['author']}"; $section = "{$postede2['section']}"; $description = "{$postede2['description']}"; $url = "{$postede2['url']}"; echo "<a href='$url'><h3><b>$title</b></h3></a><br>"; echo "By $author, Category: $section<br>"; echo "$description ...<br><br>"; } ?> How do i break down the search even further? I'm trying to figure out how I can reduce as much functionality as possible and still keep it doing what it needs to do. What I mean by functionality is the number of queries being performed or any of the other code for that matter. I do show at the bottom of my post what I have so far, however that doesn't cover all the queries. Code: [Select] <?php if ($access_level_id == 2 || $access_level_id == 3) { $query = "SELECT characters.id FROM characters"; $result = mysqli_query ($dbc,$query); $total_num_characters = mysqli_num_rows($result); $query = "SELECT user_characters.id FROM user_characters INNER JOIN user_accounts ON user_accounts.id = user_characters.user_id"; } else { $query = "SELECT user_characters.id FROM user_characters INNER JOIN user_accounts ON user_accounts.id = user_characters.user_id WHERE user_accounts.id = '".$user_id."'"; } $result = mysqli_query($dbc,$query); echo $num_available_characters = mysqli_num_rows($result); if (($num_available_characters > "1") || (($access_level_id == 2 || $access_level_id == 3) && (isset($total_num_characters)) && ($total_num_characters > "0"))) { ?> <form method="POST" id="change_default_character"> <select class="dropdown" name="new_default_character_id" id="new_default_character_id" title="Select Character"> <?php if ($default_character_id > "0") { print "<option value=".$default_character_id.">".$default_character_name; } else { print "<option value=0>- Select -"; } if ($access_level_id == 2 || $access_level_id == 3) { $query = "SELECT characters.id, characters.character_name FROM characters WHERE characters.id <> '".$default_character_id."' AND characters.status_id = '1' ORDER BY characters.character_name"; } else { $query = "SELECT characters.id, characters.character_name FROM characters INNER JOIN user_characters ON characters.id = user_characters.character_id INNER JOIN user_accounts ON user_accounts.id = user_characters.user_id WHERE user_accounts.id = '".$user_id."' AND user_characters.character_id <> '".$default_character_id."' AND characters.status_id = '1' ORDER BY characters.character_name"; } $result = mysqli_query ($dbc,$query); $num_rows = mysqli_num_rows ($result); if ($num_rows > 0) { if ($access_level_id == 2 || $access_level_id == 3) { print "<optgroup label=\"** Active Characters **\">"; } while ( $row = mysqli_fetch_array ( $result, MYSQL_ASSOC ) ) { print "<option value=\"".$row['id']."\">".$row['character_name']."</option>\r"; } } if ($access_level_id == 2 || $access_level_id == 3) { $query = "SELECT characters.id, characters.character_name FROM characters WHERE characters.id <> '".$default_character_id."' AND characters.status_id = '2' ORDER BY characters.character_name"; } else { $query = "SELECT characters.id, characters.character_name FROM characters LEFT JOIN user_characters ON characters.id = user_characters.character_id LEFT JOIN user_accounts ON user_accounts.id = user_characters.user_id WHERE user_accounts.id = '".$user_id."' AND user_characters.character_id <> '".$default_character_id."' AND characters.status_id = '2' ORDER BY characters.character_name"; } $result = mysqli_query ($dbc,$query); $num_nows = mysqli_num_rows($result); if ($num_rows > "0") { print "<optgroup label=\"** Inactive Characters **\">"; while ( $row = mysqli_fetch_array ( $result, MYSQL_ASSOC ) ) { print "<option value=\"".$row['id']."\">".$row['character_name']."</option>\r"; } } ?> </select> </form> <?php } else { print "<h1>".$default_character_name."</h1>\n"; } ?> Code: [Select] <?php /** * Get roster list * * @return object/NULL */ function getRosterList() { $this->db->from('rosterList'); $query = $this->db->get(); if ($query->num_rows() > 0) { return $query->result(); } return null; } /** * Get list of roster by user ID * * @return object/NULL */ function getRosterByUserID() { $this->db->from('rosterList'); $this->db->where('userID', $userID); $query = $this->db->get(); if ($query->num_rows() > 0) { return $query->result(); } return null; } ?> Hi all! I am currently reprogramming my site with objects etc, making it better. I have some code below and am not sure upon how to make it better. loops, cases, classes, functions etc not sure what to do, currently looks like a jumble, here it is, am looking comments on how I can improve how it looks and maybe split it up more or someting, not su ##### FIND OUT SQL TO SHOW RESULTS ##### // country results sql if( $_GET['country'] != "" ){ $keyword = str_ireplace("_"," ",$_GET['country']); $keyword = langCountryNum($keyword,"COUNTRY",138); $sql = 'SELECT * FROM exchange WHERE `location` = "'.$keyword.'" ORDER BY FROM_UNIXTIME(lastOnline) DESC'; $urlText = "/xxxxx/".( in_array($lang,$_ENV['supportedLanguages']) ? $lang."/" : $nothing).HEADlanguage_exchange."/country/".HEADbefore_lang.constant("COUNTRY" .$keyword).HEADafter_lang; //language results sql }elseif( $_GET['language'] != "" ){ $keyword = str_ireplace("_"," ",$_GET['language']); $keyword = langCountryNum($keyword,"Lang",130); $sql = 'SELECT * FROM exchange WHERE `option` = "'.$keyword.'" ORDER BY FROM_UNIXTIME(lastOnline) DESC'; $urlText = "/xxxx/".( in_array($lang,$_ENV['supportedLanguages']) ? $lang."/" : $nothing).HEADlanguage_exchange."/language/".HEADbefore_lang.constant("Lang" .$keyword).HEADafter_lang; // all members results sql }else{ $sql = "SELECT * FROM exchange ORDER BY id DESC"; $urlText = ( in_array($lang,$_ENV['supportedLanguages']) ? $lang."/" : $nothing).HEADall_penpals; } ##### END FIND OUT SQL TO SHOW RESULTS ##### Hello, My upload script is working for the most part and while I know that I need a couple of little fixes and will need help with those I also wouldn't mind some tips on how I could have written it better in the first place. The 2 problems I am having. 1. If the copy image fails the script doesn't and still creates a database entry. I would like to stop it from doing that but can't seem to work it out. 2. My mate is getting file type errors even though he is trying to upload small .jpg files. I can't seem to recreate the problem. Maybe someone can see something that might be problematic?? Code: [Select] <? $idir = "../rosysartworks/gallery/"; // Path To Images Directory $tdir = "../rosysartworks/gallery/thumbs/"; // Path To Thumbnails Directory $iwidth = "600"; // Maximum Width For Thumbnail Images $iheight = "600"; // Maximum Height For Thumbnail Images $twidth = "233"; // Maximum Width For Thumbnail Images $theight = "178"; // Maximum Height For Thumbnail Images ?> <? // Catching the inputs $title = Trim(stripslashes($_POST['title'])); $paypal = Trim(stripslashes($_POST['paypal'])); // Check if the form has been submitted. if (isset ($_POST['submit'])) { $problems = FALSE; // No problems so far. // Check for each value. if (empty ($title)) { $problem = TRUE; $problems = 'You forgot to enter a title!<br />'; } if (empty ($paypal)) { $problem = TRUE; $problems = 'You forgot to enter a paypal link!<br />'; } if (!$problem) { // If there are no problems... // Uploading/Resizing Script $url = $_FILES['imagefile']['name']; // Set $url To Equal The Filename For Later Use if ($_FILES['imagefile']['type'] == "image/jpg" || $_FILES['imagefile']['type'] == "image/jpeg" || $_FILES['imagefile']['type'] == "image/pjpeg" || $_FILES['imagefile']['type'] == "image/JPG") { $file_ext = strrchr($_FILES['imagefile']['name'], '.'); // Get The File Extention In The Format Of , For Instance, .jpg, .gif or .php $copy = copy($_FILES['imagefile']['tmp_name'], "$idir" . $_FILES['imagefile']['name']); // Move Image From Temporary Location To Permanent Location if ($copy) { // If The Script Was Able To Copy The Image To It's Permanent Location // Resize for preview image. $simg = imagecreatefromjpeg("$idir" . $url); // Make A New Temporary Image To Create The Thumbanil From $currwidth = imagesx($simg); // Current Image Width $currheight = imagesy($simg); // Current Image Height if ($currwidth > $iwidth && $currheight > $iheight) { $newwidth = $iwidth; $newheight = $newwidth * $currheight / $currwidth; if ($newheight > $iheight) { $newheight = $iheight; $newwidth = $newheight * $currwidth / $currheight; } $dimg = imagecreatetruecolor($newwidth, $newheight); // Make New Image For Preview imagetruecolortopalette($simg, false, 256); // Create New Color Pallete $palsize = ImageColorsTotal($simg); for ($i = 0; $i < $palsize; $i++) { // Counting Colors In The Image $colors = ImageColorsForIndex($simg, $i); // Number Of Colors Used ImageColorAllocate($dimg, $colors['red'], $colors['green'], $colors['blue']); // Tell The Server What Colors This Image Will Use } imagecopyresampled($dimg, $simg, 0, 0, 0, 0, $newwidth, $newheight, $currwidth, $currheight); // Copy Resized Image To The New Image (So We Can Save It) $success = imagejpeg($dimg, "$idir" . $url, 100); // Saving The Image imagedestroy($simg); // Destroying The Temporary Image imagedestroy($dimg); // Destroying The Other Temporary Image if ($success) { print 'Preview image '.$url.' width: '.$newwidth.' height: '.$newheight.' created successfully.<br />'; // Resize successful for preview image unset($success); } } else { unset($simg, $currwidth, $currheight); } // Resize for thumbnail $simg = imagecreatefromjpeg("$idir" . $url); // Make A New Temporary Image To Create The Thumbanil From $currwidth = imagesx($simg); // Current Image Width $currheight = imagesy($simg); // Current Image Height $newwidth = $twidth; $newheight = $newwidth * $currheight / $currwidth; if ($newheight > $theight) { $newheight = $theight; $newwidth = $newheight * $currwidth / $currheight; } // maxWidth: mw, maxHeight: mh, oldHeight: oh, oldWidth: ow, newHeight: nh, newWidth: nw. // nw = mw; nh = nw * oh / ow; // if (nh > mh) { nh = mh; nw = nh * ow / oh } $dimg = imagecreatetruecolor($newwidth, $newheight); // Make New Image For Thumbnail imagetruecolortopalette($simg, false, 256); // Create New Color Pallete $palsize = ImageColorsTotal($simg); for ($i = 0; $i < $palsize; $i++) { // Counting Colors In The Image $colors = ImageColorsForIndex($simg, $i); // Number Of Colors Used ImageColorAllocate($dimg, $colors['red'], $colors['green'], $colors['blue']); // Tell The Server What Colors This Image Will Use } imagecopyresampled($dimg, $simg, 0, 0, 0, 0, $newwidth, $newheight, $currwidth, $currheight); // Copy Resized Image To The New Image (So We Can Save It) $success = imagejpeg($dimg, "$tdir" . $url, 100); // Saving The Image imagedestroy($simg); // Destroying The Temporary Image imagedestroy($dimg); // Destroying The Other Temporary Image if ($success) { print 'Image thumbnail '.$url.' width: '.$newwidth.' height: '.$newheight.' created successfully.'; // Thumbnail created successfully } } else { print '<font color="#FF0000">ERROR: Unable to upload image.</font>'; // Error Message If Upload Failed } // End upload at copy failure } else { print 'Failed to copy image to temp location.'; } } else { print '<font color="#FF0000">ERROR: Wrong filetype (has to be a .jpg or .jpeg. Yours is '; // Error Message If Filetype Is Wrong print $file_ext; // Show The Invalid File's Extention print '.</font>'; } // End upload script // Define the query. $add_new_session = $sql = "INSERT INTO `gallery` ( `id` , `title` , `image` , `thumb` , `width` , `height` , `paypal` , `date_entered` ) VALUES ( 0, '".mysql_real_escape_string(($title))."', '".mysql_real_escape_string(($url))."', '".mysql_real_escape_string(($url))."', '".mysql_real_escape_string(($newwidth))."', '".mysql_real_escape_string(($newheight))."', '".mysql_real_escape_string(($paypal))."', NOW() )"; // execute the query. if (@mysql_query ($add_new_session)) { print "<p>The new gallery image $url has been added.</p>"; unset($sessionName, $maxAttendees, $newwidth, $newheight); $hidden = 'hidden'; } else{ print '<a name="formTop"></a>'.'<p class="error">Your session has failed to upload. Please contact website support.</p>'; echo $add_new_session; } } else { // Forgot a field. // print '<p>Please try again!</p>'; $problems .= '<a name="formTop"></a>'.'Please try again!<br />'; if ($problem) { print '<p class="error">' . $problems . '</p>'; } } // End of handle form IF // Display the form print '<h2>Upload New Image</h2>' . '<p>Please only try uploading .jpg images</p>' . '<form method="post" action="index.php" enctype="multipart/form-data">' . '<label>Title:</label>' . '<input type="text" name="title" class="form">' . '<br />' . '<label>Image:</label>' . '<input type="file" name="imagefile" class="form">' . '<br />' . '<label>Paypal Link:</label>' . '<input type="text" name="paypal" class="form" size="50">' . '<br /><br />' . '<input name="submit" type="submit" value="Sumbit" class="form">' . '<input type="reset" value="Clear" class="form">' . '</form>'; ?> I am using this a modal window(jBox) - with a web Form in it, that requires the Form (just Name & Email) to be completed and Submitted in order to close the modal window - allowing access to the main page. The Form uses this corresponding ../submit.php which this: if (empty($_POST['name'])|| empty($_POST['email'])){ $response['success'] = false; } else { $response['success'] = true; } echo json_encode($response); where, upon Form > submit, successfully shows 'error' if the Form fields are not populated, and 'success' when the Form fields are populated/submitted.
I'd like the Form to require a proper/valid email address and avoid spam and header injection Any assistance/guidance is appreciated
I'm trying to make a League of Legends (a video game) community website, both as a personal project and for practice. Now the game has a lot of champions, each of whom have 5 unique abilities. Now, I thought about manually inputting all the details about each champion into a MySQL database, but that would long and tedious, and I don't really have the time for it now. Also, the game patches very oftern (like, once every 2 weeks) which changes many of the stats, etc. of the champion, and it is not possible for me to keep manually updating these every time there is a patch. Fortunately, there is a League of Legends Wiki which has all the data I need in their specific champion pages, which they keep updated per patch. So I was wondering if there was any way to get the data from the divs in the wiki, and have it display on my site. What I want to do in my website is that whenever someone types a champion's name (in a post or whatever), I want it to display a hover-over dialog with some of the champions details. And a lot of other features such as that. In plain English I need a way to : > Tell PHP to go to the wiki's source code on a specific page > Find a specific div container > Get X data from there > Pass X data into a function to display the hover-over I think this way, I would not have to maintain a database as I can leech off the wiki's data. I have not coded anything like this before, so I would like a few pointers as to how to achieve this. Any help will be appreciated! hello My database is in a same server with seperate domain name , then I want to insert from website1 mysql data on website2 mysql data. can anyone help me? I tried searching on google but couldn't find any relevant information, please redirect me to relevant source or help me with the code. I want to pass a domain name in text field which will be scanned and then the script will display entire site map. Not external links or links on a page. Sorry it is not easy for me to explain. Eg. if i pass abc.com Script will display abc.com/12/adn.php abc.com/asd/asd/ etc Whatever their url format is. All the links on that domain. Is it possible to download files from a website to my online websites root directory? reason I'm asking is because I have been downloading large video files to my computer which take about 20 minutes!! Then I use FTP to upload them to my site but it takes about 2-3 hours per video!! I was looking for a faster way! All help would be great! This would be an example of a page I'm referring to: http://www.curse.com...other-downloads
I want to get the file name and compare it to another name (to see if they are the same or not). I have no idea how to access that page from my website. I'm guessing PHP would be best although if you don't think so tell me what you think would be better (I was thinking javascript but don't think that's cross-site compatible). Is there a PHP function to get the value of the href which is in this case (as of this posting) "Railcraft 9.4.0.0".
I used inspect element to see the code of the page but have no idea if this is possible or if I'm even going about this the right way. The code would have to work on this entire website (all pages have the smae layout as this one though! Any help is greatly appreciated!
Hello everybody!
I have been asked by a customer to develop a GTP website (Get To Pay, those websites where people earn money from clicking on ads). I managed to write the backend, signup and login but I am unsure how the ads part, with built-in user-tracking works and fallback link works.
I would really appreciate any kind of help.
Thank you very much!
P.S. For the user tracking I was thinking of sessions with matching ip and user agents together with an anti-proxy online service (e.g. MaxMind, Proxystop, ...)
My code on website is not validate on W3 Validator.
<?xml version="1.0" encoding="ISO-8859-1"?> Hello everyone and thank you for reading this.
My goal: Build a site like sportingnewschicago.com
What it does? It has different sectiions of different teams. Then it displays the tittle of the news and makes them be able to click on to go to the news site. The site some how checks a list of sites and post them on their respected section. But only ones that have not already been listed.
What i want to do? Well i want to try to learn how to do this. Is this something i can make with the help of members here? It would only have index.php and thats it.
Please let me know if anyone would be interested in teaching me as i do it. If not i would understand. Thank you.
I am working on a website and I am at a standstill. I would rather speak to someone one on one but its been very difficult to find someone that could help. I have the scripts that I want but when I add the scripts to the mainpage everything stops working. I really don't want to go to wordpress because I am almost done with this one. Thanks.
Hi, I haven't used any php for a while, but i am making a website, and i need some advice on how to do the following: I want the website to change an image once every 24 hours, the image will revert back to the original image after 2 minutes. Does anyone have an idea how I could start doing this? Hi there Can anyone please help me. I am trying to get my website working but i am struggling big time with the php. The things i need to do are not to complicated however my lack of skill with php is making me struggle. I need help in making the php work on my website. Can anyone help please. (Please note it is not a commercial or business website.) Anyone who can help please contact me. Thanks I was not expecting this but when I managed to connect to a chatroom and close out firefox.... The user stayed in the chatroom. This user should of pinged out by now but it's staying online. How do I end this connection? So far I turned off my internet, and blocked all access to the site. Hi there, This forum has been helpful to me so far. I'd like to thank you for your help. Now the question is, we will be using xe.com services for our shopping cart and prices. Based to the customer's location the currency must change. For example, if the customer is sitting in Europe, the currency for the product and the shopping cart will be displayed in Euros, similarly for the US customers it will be in USD. I would like to know how we can do this using xe.com and what steps are required. Any comments/feedbacks are always welcome! Thank you! Hi, I'm working on a design for a new website of mine, but I'm kind of stuck on how to fit in the php aspect of it. There's going to be a lot of different pages and different things you're able to do on each page. I guess I'm trying to figure out how to take my design for the website and break it up into a template system. I don't know anything about using templates though. The last time I tried to make a template I just winged it and it turned out really bad with a lot of confusing code slapped together with html all around it. Right now all I have is a single page made (front page) and I want to use this as my base template. Could anyone explain to me the proper way to go about this, or perhaps link me to a tutorial covering this. Thanks, Hello I want get content of website and insert it to my website This website have 2000 page and each one have 10 post. I developed some code but I've some problem: Code: [Select] for($i=1;$i<=3;$i++) //$i is website pages { //download main page $maincatst = file_get_contents($catlink.$i); //$catlink select link of category of website //number of post in main page for ($j=1;$j<=10;$j++) { $linkposttmp = TextBetween('before link','after link',$maincatst) ; $link = TextBetween('before link','after link>',$linkposttmp); // download content of each link $main_post_str = file_get_contents($link); My problem is when run this file only download first link of each mainpage. anyone can help me? |