
coolphpdude
Members-
Posts
214 -
Joined
-
Last visited
Never
Everything posted by coolphpdude
-
hey people could somebody tell me what is the best way to query multiple tables. For example I am doing a website based on an estate agents for my course. A Property will have numerous features. I'll have a table in the following format ID - feature_id - feature 1 - f1 - Double garage 2 - f2 - double glazing 3 - f3 - front garden 4 - f4 - back garden something along those lines anyway! well basically what i want to do is add a property to a table then add features of that particular property. so maybe a link table between the 2, i.e: (property 1 has double glazing) property - feature p1 - f2 I'll have a couple of different tables that are relevant to things that the property includes. what i want to know is the best way to query that database so that i can out from all tables anything that is relevant to property 1. hope this makes sense cos ive actually confused myself tryin to explain this!! Cheers
-
hi, I was told to use $_request instead of $_post or $_get. can somebody explain in plain english what $-request does and is it better/more efficient, etc... than the others. Thanks Pete
-
Hi guys, I am outputting pictures into a gallery page using a while loop. // thumbnail table echo "<table width='100%' border='0' cellspacing='0' cellpadding='10'>"; //set number of columns and initial column number $numcols = 3; // how many columns to display $numcolsprinted = 0; // no of columns so far // get the results to be displayed $query = "SELECT * FROM pics WHERE pic_id='$id'"; $mysql_result = mysql_query($query) or die (mysql_error()); // get each row while($myrow = mysql_fetch_array($mysql_result)) { //get data $pic = $myrow[0]; if ($numcolsprinted == $numcols) { print "</tr>\n<tr height ='500'>\n"; $numcolsprinted = 0; } $pic_name = $myrow["vp_thumb"]; $pic_id = $myrow["vp_id"]; // output row from database echo "<td width='300' height='500' align='center' valign='top'><img src='$pic_name' border='0'></td>\n"; // bump up row counter $numcolsprinted++; } // end while loop $colstobalance = $numcols - $numcolsprinted; for ($i=1; $i<=$colstobalance; $i++) { } print "<TD height ='500'></TD>"; echo"</table>"; The while loop works great. it outputs all of my thumbnails into a 3 column table. the problem i am having is when it outputs the next row of pictures. The next row is actually directly under the first row (i.e not a single pixel between the picture in the first row and the second row. Any idea's why it is doing this?? as you can see i've tried adding height='500' to both the <td> tags and the <tr> tag>. Cheers
-
sorted!! cheers guys!
-
right, i get you now!! I was messing about trying different things for hours yesterday! do you know where php.ini will be located on my hosting??
-
so does that mean theres a max file size set in the php.ini file thats effecting this even though i have set different perameters in the code??
-
POST:Array ( [max_file_size] => 100000000 ) FILES:Array ( [uploadedfile] => Array ( [name] => DSCN0026.JPG [type] => [tmp_name] => [error] => 1 => 0 ) )
-
Hi people! I've got this image upload script which im having a few problems with (please find the code below) Form: echo "<form enctype='multipart/form-data' method='post' action=uploadpicture.php'>"; echo "<input type='hidden' name='max_file_size' value='10000000' />"; echo "<input name='uploadedfile' type='file'>"; echo "<br>"; echo "<br>"; echo "<input type='submit' value='Upload Picture' >"; echo "</form>"; Now this should mean that the max file size of the picture that is to be uploaded should be no larger than 10mb. Code: $uploadedfile=$_POST["uploadedfile"]; function resampleimage($maxsize, $sourcefile, $destination, $imgcomp=0){ // SET THE IMAGE COMPRESSION $g_imgcomp=100-$imgcomp; // CHECK TO SEE IF THE IMAGE EXISTS FIRST if(file_exists($sourcefile)){ // FIRST WE GET THE CURRENT IMAGE SIZE $g_is=getimagesize($sourcefile); /********* CALCULATE THE WIDTH AND THE HEIGHT ***************/ // CHECK TO SEE IF THE WIDTH AND HEIGHT ARE ALREADY SMALLER THAN THE MAX SIZE if($g_is[0] <= $maxsize && $g_is[1] <= $maxsize){ // LEAVE WIDTH AND HEIGHT ALONE IF IMAGE IS SMALLER THAN MAXSIZE $new_width=$g_is[0]; $new_height=$g_is[1]; } else { // GET VALUE TO CALCULATE WIDTH AND HEIGHT $w_adjust = ($maxsize / $g_is[0]); $h_adjust = ($maxsize / $g_is[1]); // CHECK TO WHICH DIMENSION REQUIRES THE SMALLER ADJUSTMENT if($w_adjust <= $h_adjust){ // CALCULATE WIDTH AND HEIGHT IF THE WIDTH VALUE IS SMALLER $new_width=($g_is[0]*$w_adjust); $new_height=($g_is[1]*$w_adjust); } else { // CALCULATE WIDTH AND HEIGHT IF THE HEIGHT VALUE IS SMALLER $new_width=($g_is[0]*$h_adjust); $new_height=($g_is[1]*$h_adjust); } } //SEARCHES IMAGE NAME STRING TO SELECT EXTENSION (EVERYTHING AFTER THE LAST "." ) $image_type = strrchr($sourcefile, "."); //changes the file extension from uppercase to lowercase $lower = strtolower($image_type); //SWITCHES THE IMAGE CREATE FUNCTION BASED ON FILE EXTENSION switch($lower) { case '.jpg': $img_src = imagecreatefromjpeg($sourcefile); break; case '.jpeg': $img_src = imagecreatefromjpeg($sourcefile); break; case '.png': $img_src = imagecreatefrompng($sourcefile); break; case '.gif': $img_src = imagecreatefromgif($sourcefile); break; default: echo("Error Invalid Image Type"); die; break; } // CREATE THE TRUE COLOR IMAGE WITH NE WIDTH AND HEIGHT $img_dst=imagecreatetruecolor($new_width,$new_height); // RESAMPLE THE IMAGE TO NEW WIDTH AND HEIGHT imagecopyresampled($img_dst, $img_src, 0, 0, 0, 0, $new_width, $new_height, $g_is[0], $g_is[1]); // OUTPUT THE IMAGE AS A JPEG. // THIS CAN BE CHANGED IF YOU WANT TRANSPARENCY OR PREFER ANOTHER FORMAT. MAKE SURE YOU CHANGE HEADER ABOVE. imagejpeg($img_dst, $destination, 100); // DESTROY THE NEW IMAGE imagedestroy($img_dst); return true; } else { return false; } } // INSERT PICTURE CODE - START if ((($_FILES["uploadedfile"]["type"] == "image/pjpeg") || ($_FILES["uploadedfile"]["type"] == "image/jpeg") || ($_FILES["uploadedfile"]["type"] == "image/JPEG") || ($_FILES["uploadedfile"]["type"] == "image/png") || ($_FILES["uploadedfile"]["type"] == "image/bmp")) && ($_FILES["uploadedfile"]["size"] < 10000000)) { echo "file uploaded"; } else { echo "file not uploaded"; } to me this all looks fine and i should be able to upload any picture with most image file types but they must be under 10Mb!! well for some reason im tryin to upload a .jpg thats 2.5mb and it won't work. Any ideas??? Cheers
-
ahh my bad i typed that in by accident. Right im gonna give up for the night but i'll check out the server config tomorrow and post again! cheers for your help lads!
-
sounds like what i'm after. So does an include statement just pull in code that i've written on a seperate page and then execute that before continueing through the rest of the code on my page??? I tried to google in but only came back with 2 results which wern't relative Cheers for replying
-
Hi people, im tryin to remind myself how to do php so i've knocked together a basic page as follows... <?php echo "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>"; echo "<html xmlns='http://www.w3.org/1999/xhtml'>"; echo "<head>"; echo "<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />"; echo "</head>"; // *** Connection - START *** // connect to database $db = @mysql_connect("localhost","xxxxxx","xxxxxx"); if (!$db) { do_error("Could not connect to the server"); } // Check connection - if it does not exist then go to the error function @mysql_select_db("xxxxx",$db)or do_error("Could not connect to the database"); // *** Connection - END *** echo "<html>"; // *********************** No Results ************************** function do_error($error) { echo "User not found. Please enter your login details on the right."; } echo "</html>"; ?> and it brings up the following message when i try to load that page... Error in my_thread_global_end(): 1 threads didn't exit Failed loading C:\WINDOWS\system32\inetsrv\ioncube\ioncube_loader_win_5.2.dll Is there something I have forgot to do??? Also one last thing, is there any way to write a section of code for example a query checking your username and password that you are going to use accross multiple pages and then call that. rather than having to type out that same query on each and every php page that uses it? Thanks
-
FREE php availability/reservations calendar
coolphpdude replied to coolphpdude's topic in PHP Coding Help
cheers, well if anyone comes accross or has used 1 similar to this http://www.rentcalendars.com/try.htm please let me know. im still looking in the meantime. Cheers -
Hey people, I am after a free online availability/reservations calendar. Basically all it needs to do from the back end is allow an admin to log in and mark dates as unavailable. and from the front end allow users to view all of the months in a year view on screen and see which dates are available and unavailable. Quite simple but im struggling to find a free one. i've looked and looked and the only one that came close decided to try and charge me when i went to download it. Does any one know of a good one that i can get?? Cheers
-
You are an absolute legend!!!!!!!!!!!!! Thanks, i really appreciate this that works a treat!!!
-
bump - just need to know why its counting 0 records as 1?
-
It's getting there... really appreciate this guys!! would never have figured this out on my own. Theres only 1 last problem with this, where there is a subject that no students have selected as their preferred subject it is displaying (1) next to it instead of (0)... any ideas? It should be outputting the following maths (3) english (1) french (0) physics (0) history (0) PE (9) but its actually displaying maths (3) english (1) french (1) physics (1) history (1) PE (9) Thanks
-
Hey, I previously marked this topic as solved but after trying it today i'm a bit stuck so i'm back for a bit more guidance! I now have my tables set up so that i have a table of subjects (ID, subject) and i have a students table with a field called preferred_subject. preferred_subject contains the ID relevant to a particular subject from the subjects table. *** As the post above *** Im using the query off the previous post... $sql = 'SELECT s.subject as preferred_subject, COUNT(s.subject) as total_subject FROM subjects s, students st WHERE s.id = st.prefered_subject GROUP BY s.subject'; $result = mysql_query($sql); while($row = mysql_fetch_assoc($result)) { echo $row['preferred_subject'] . '(' . $row['subject_total'] . ')<br />'; } but i think i must be writing the select query wrong because it is only counting the the subjects the students have selected. I need it to list all subjects from the subjects table and include the number of students that have chosen that subject as their preferred choice, i.e... maths (3) english (1) french (0) physics (0) history (0) PE (9) Can any1 tell me what is wrong with my select statement and advise me what i can do so that ALL subjects are listed regardless of whether a student has chosen it as their preferred subject? Thanks
-
bump
-
ooh that luks gud!!! it looks like exactly what i need. could you give me some further advice... if i use the method on that page id have something along the following Id Cat Parent 1 ford 0 2 vauxhall 0 3 vauxwagon 0 4 focus 1 5 fiesta 1 6 mondeo 1 7 astra 2 8 corsa 2 9 vectra 2 10 golf 3 11 polo 3 12 passatt 3 13 st 4 14 tdi 4 15 tdci 4 is that right?? so basically i am saying that id 13,14 and 15 (st, tdi, tdci) belong to id 4 (focus)? So would you recommend this way of doing things or do you think each category should have its own table?
-
hi there, Im creating a school database system and i will use a number of categories, sub categories and sub sub categories. wot i am wondering is, what is the best way to do this? Should i have a table of main gategories then a table for each sub category like the following... i'll use a car database as an example... [b]Main_cat_table[/b] Ford Vauxhall Vauxwagon etc... [b]ford_sub_cat_table[/b] Focus Mondeo Fiesta etc... [b]vauxhall_sub_cat_table[/b] astra corsa vectra etc... [b]vauxwagon_sub_cat_table[/b] golf polo passatt etc... [b]golf_sub_cat_table[/b] tdi gt tdi gti Is this the best way to do it or am i making things difficult for me by making loads of tables???
-
Thanks i appreciate that!!! its just selecting data to be honest, doesnt need to modify the SQL tables. i'l take a look at this though. if anyone else wants to drop a few lines of their own thoughts on this feel free!