
Fallen_angel
Members-
Posts
88 -
Joined
-
Last visited
Never
Everything posted by Fallen_angel
-
Help with the linking in a dynamic menu
Fallen_angel replied to Fallen_angel's topic in PHP Coding Help
thankyou so much for your help I tried it as Print "<a href="./sort_breeder.php?id=".$info['b_name'].""> but that ofcourse gave the errors without the extra parts you added in for me , thankyou ever so much I knew it was goign to be somehtign simple liek that :) works a dream now ;) -
I am getting a bit oif a strange thing happening and I am not sure why so I am hopign some people can help What this script does is that it maintains a dynamic menu list of the all the authors names, when they click the name they get a list of the books or white papers available, the list park works great as does the finding function once the ID variable is set right , which is where i am having an issue When I pull information from my database to just be echo'ed onto a normal page the output comes out as expected ( if there are two words it comes out with two ect) On the other hand though as you can see from the bellow script I am trying to use one of my variables in a url $info['name'] when I do this however only the first word of the database field is echoed the seccond is ignored so instead of my page being linked to ?id=Image1 Name (?id=Image1%20Name) it is just getting to the space and then dying so all I get is ?id=Image1 which isn't goign to find what I need it to when somone clicks on the link If somone could please have a look at my bellow script and tell me where i am goign wrong or what i'm missing I would really apreciate it [code]<?php //Connect To database include "connect.php"; $id = $_GET['id']; //collects Data $data=mysql_query("SELECT b_id,b_name FROM database ORDER by 'b_name'") or die(mysql_error()); $name=$info['b_name']; Print "<table class='print_list_alpha' >" ; while ($info= mysql_fetch_array($data) ) { Print "<a href=./sort.php?id=".$info['b_name'].">".$info['b_name']."</a> <br>" ; } ?>[/code]
-
seems to be workign fine now even though I changed nothing lol just typed it out manually again so guess there was a problem in my syntax somewhere
-
Hi I am hoping someone here can help me I need to have 6 fields on my from as manditory , I have been able to add one more field so make it so two fields are checked , however once I try and do more than 2 it simply ignores me for some reason this is what I started with [code] function validate_required(field,alerttxt) { with (field) { if (value==null||value=="") {alert(alerttxt);return false} else {return true} } } function validate_form(thisform) { with (thisform) { if (validate_required(field,"Report Title must be filled out!")==false) {report_title.focus();return false} if (validate_required(field2,"Report Title must be filled out!")==false) {r_submitter.focus();return false} } } [/code] and as part of my form tag I have onsubmit="return validate_form(this)" which makes it run when the form is submitted . So far so good with one field then I went and added a seccond required field like bellow [code] function validate_required(field,alerttxt) { with (field) { if (value==null||value=="") {alert(alerttxt);return false} else {return true} } } function validate_form(thisform) { with (thisform) { if (validate_required(field,"Report Title must be filled out!")==false) {report_title.focus();return false} else if (validate_required(field2,"Report Title must be filled out!")==false) {r_submitter.focus();return false} } } [/code] Still all worked and I was pretty happy , but then I went to add the rest of my required fields and thats when it just stopped listening to me , what I tried was [code] function validate_required(field,alerttxt) { with (field) { if (value==null||value=="") {alert(alerttxt);return false} else {return true} } } function validate_form(thisform) { with (thisform) { if (validate_required(field1,"Report Title must be filled out!")==false) {field1.focus();return false} else if (validate_required(field2"Report Title must be filled out!")==false) {field2.focus();return false} else if (validate_required(field3"Report Title must be filled out!")==false) {field3.focus();return false} } }[/code] What am I doing wrong ? is it where I am using else if ? should I be doing this a different way ?
-
He he I feel silly but I got it workign now for any one that wants to see the script it is now as follows [code]<?php //Connect To database include "connect.php"; $id = $_GET['id']; //collects Data $data=mysql_query("SELECT s_id,name,rating,img,description FROM strains where name LIKE '$id%'ORDER by 's_name'") or die(mysql_error()); Print "<table class='print_list_alpha' border=0px style=border-bottom:1px;>" ; while ($info= mysql_fetch_array($data) ) { Print "<tr style=background-color:#E9F3EA;><td><img src=./uploads/mini_thumbs/".$info['img']."></td><td background-color=#E9F3EA><table><tr><td><a href=../strainguide/page.php?id=".$info['s_id']."><b>".$info['name']."</b></a></td><tr><td> " ; Print substr($info['description'],0,250); Print "</td></tr></table>"; } Print "</table>" ; ?> [/code] thankyou very much for your assistance :)
-
Ok well i think I have it semi working I think however I may be calling it incorrectly , would I still use ".$info['fieldname']." to call the contained info ? or does it change because I used a substring , atm All I get is no summary at all , no errors and everything else loads ok so I'm guessing it's the way I am calling in on the page I have also replaced the * with the specific fields that I need thankyou very much for that extra tip :) here is what my code looks like now [code] <?php //Connect To database include "connect.php"; $id = $_GET['id']; //collects Data $data=mysql_query("SELECT SUBSTRING(description,0,250) s_id,name,rating,img FROM DB where name LIKE '$id%'ORDER by 'name'") or die(mysql_error()); Print "<table class='print_list_alpha' border=0px style=border-bottom:1px;>" ; while ($info= mysql_fetch_array($data) ) { Print "<tr style=background-color:#E9F3EA;><td><img src=./uploads/mini_thumbs/".$info['img']."></td><td background-color=#E9F3EA><table><tr><td><a href=../strainguide/page.php?id=".$info['s_id']."><b>".$info['name']."</b></a></td><tr><td> ".$info['notes'] ."</td></tr></table>"; } Print "</table>" ; ?> [/code] thanx in advance for any help people can give :)
-
Hi I need a bit of help with a script I have I what I basicly want to do is have a short summary pulled from one of my database fields the database field itself can have 10,000 charictors in it , however I only want to return 250 charictors to be returned so that it can be used as a description in the bellow search script I have looked around but I can't find a way that I can simply just limit the number of charictors the results return . I know it can be done because I have seen it done but just don't know how to do it bellow is my code so far , anyone that can help I would really apreciate it [code] <?php //Connect To database include "connect.php"; $id = $_GET['id']; //collects Data $data=mysql_query(" SELECT * FROM DB where s_id='$id' ") or die(mysql_error()); Print "<table class='print_list_alpha' border=0px style=border-bottom:1px;>" ; while ($info= mysql_fetch_array($data) ) { Print "<tr><td><img src=./uploads/mini_thumbs/".$info['img']."></td><td><table><tr><td><a href=../guide/report.php?id=".$info['s_id']."><b>".$info['name']."</b></a></td><tr><td> ".$info[notes'] ."</td></tr></table>"; } Print "</table>" ; ?>[/code] Thanx to anyone that can help
-
Hi I need a bit of help with a script I have I what I basicly want to do is have a short decription pulled from one of my database fields the database field itself can have 10,000 charictors in it , however I only want to return 250 charictors so that it can be used as a description in the bellow search script [code] <?php //Connect To database include "connect.php"; $id = $_GET['id']; //collects Data $data=mysql_query(" SELECT * FROM strains where s_breeder='$id' ") or die(mysql_error()); Print "<table class='print_list_alpha' border=0px style=border-bottom:1px;>" ; while ($info= mysql_fetch_array($data) ) { Print "<tr><td><img src=./uploads/mini_thumbs/".$info['img']."></td><td><table><tr><td><a href=../guide/report.php?id=".$info['s_id']."><b>".$info['s_name']."</b></a></td><tr><td> ".$info['s_notes'] ."</td></tr></table>"; } Print "</table>" ; ?>[/code] Thanx to anyone that can help
-
Sorry I think there may be some confusion in what I was sugesting , my first post gave you the answer to your first question my seccond post was answering how you could make a link there to take you to another page besides back , I assumed that you would not need a link from a page in a form to another page ,because I would image you already defined that in the form tag itself , so all you need is a standard submit button. from the sounds of your explination you just need the back button and your standard submit buttons so please ignore my seccond post and just use whats in the first sorry I misunderstood your seccond post
-
I was bored so I edited your code a bit with formatting , hopefull that shows you enough so that you can style it a bit easier , [code] <html> <body> <table style="width:asyouwant%; align:asyoulike; font-size:11px;"> <form action="signup.php" method="post"> <tr><td>Username:</td><td><input type="text" name="user" /></td></tr> <tr><td>Password:</td><td><input type="text" name="pw" /></td></tr> <tr><td>Submit :</td><td><input type="submit" value="Submit" /></td></tr> </form> </body> </html> [/code] basicly what you will need to do is eigther manually hard code the styling by using things like width="100%" or you can use a style= " " tag which is hard coded css as apose to normal html formatting just remember that after the item ( eg width ) you need to put a : and after the value ( eg 100%) you need to put a ; also with any custom css classes you will need to put them as .classname , not just classname in the css file , you can use a class="" tag to referance the info in your css file however if your still grasping basic html formatting you may want to hold off on that at first
-
yeah I spent a good 2 hours the other week slappin myself tryign to figure out where I was goign wrong , hehe haven't used SMF before , am more of an ipb person myself however it doesn't seem to bad at all for a free alternative one day I want to write my own forums , but I have allot to learn first hehe
-
How to make a script to upload the webpage onto the server
Fallen_angel replied to Klam's topic in PHP Coding Help
Yeah thats the idea , the basic thing to remember is that your php files will request the same info each time , however the variables you pass in the url will decide what is displayed to you , eg the php for http://www.phpfreaks.com/forums/index.php?action=post;topic=116927 & http://www.phpfreaks.com/forums/index.php?action=post;topic=116 are the exact same , the only difference is that the url is telling the script to access topic_id *** which would be a field in the database , you pull the relivant info by doign somethign like he following example url :Example Url : http://www.anypage.com/index.php?id=*** ( the ** can be any anythign to match entries in a database alpha or numeric 'numberic is advised') [code]$id = $_GET['id']; <-- tells it to get the id variable from the url mysql_connect("SERVERNAME", "USERNAME", "USERPASSWORD") or die(mysql_error()); mysql_select_db("DATABASENAME") or die(mysql_error()); $data=mysql_query(" SELECT * FROM TABLENAME where FIELDNAME='$id' ") or die(mysql_error()); $info= mysql_fetch_array($data) ; [/code] What the above code does is that it looks in the url to see what id equals , lets say for examples sake it's 88 so our full url is http://www.anypage.com/index.php?id=88. Then we have the relivant info inorder to connect to the database needed. from there It takes the value of $ID (number 88 ) and it searches for that number inside of the field that you have specified (where it says FIELDNAME) This row is then pulled from the database , and you are able to pull out information from each field with the following format [code] . $info['field1'] . . $info['field2'] . . $info['field3'] .[/code] ect ect ... Obiously you are goign to want to be carefull in deciding what fields to make value's in the url so make sure your searching for something that is going to not have any duplicates ( such as topic id ) Hope that gives you a bit more understanding , and glad I was on the right track with what you wanted -
by any chance where you using a script tag ? if so thats why it didn't let it post , I had the same issue a few weeks ago , if you replace the javascript tags though you will be fine and it will post the message
-
would you mind explaing why I should never do that besided my memory mabey forgettign the variable ? because it's not very difficult to search for $box1 and find the place it is defined at the top of the page Ofcourse there is no reason you HAVE to do it , however I can't see where the problem with doign it is I got into the habbit because it makes things neater for me when inserting items into my database and have never had any issues however IF there is something actually wrong with doign it this way and not just ease of following the script ( as I find my way easier when coding ) could you please explain it to me so that I can fix the error in my habits :) to the poster of the thread : If you skip that first step ( which is needless it's jsut habbit and tidyness on my part ) then the value's of your form can be found in $_POST['box3'] $_POST['box1'] $_POST['box2'] and same principle applies you can put em anywhere
-
just to present another alternative using a standard hyperlink will do what you have asked the seccond time , the reason you need javascript for the first is because you actually need to make a query on the clients end , if however your actually telling the link to go to a specific spot on your server then you can just use somethign like bellow [code]<a href="./index2.html">text you want for link </a>[/code] personaly I use things like javascript and other client side scripting languages as little as possible . peopel have had problems with things like malware through enabling client side scripting over the years , and 80% of doccuments that tell people how to get a bit more security from their browser advise the imediate disabling of things like javascript. ( although the trend of people enabling it due to security improvements has increased it's still not to a level you can count on ) Something thats good practice to keep in mind at all times when developing for the web is usability across various platforms , settings , browsers and ofcourse the loading times . So if you can use a simple thing like a hyperlink then there is no need to be using javascript for it if however your just practicing and learnign allogn the way it's alwasy good experiance to use it as much as possible
-
yeah javascript is the best option for a back button [code]<a href="javascript:history.back()"><< Go Back</a>[/code] will do it
-
How to make a script to upload the webpage onto the server
Fallen_angel replied to Klam's topic in PHP Coding Help
I am not quite sure what you are trying to ask but I will try and explain the process of what happens when a post is made which should help you a little better , first thing to do I guess is to strip away all the crap from teh url and break down what it means When a post is made on a forum or anything like this it creates and entry in a database , that entry is referanced by a specific field which is completely customisable by you , In the case of me replying to you there is first the php page that everythign gets it's info from ( index.php ) , the next part is telling you what action your doing , in this case it's "action=post " which tells index.php to pull any required info from it to be able to do this , next it goes to the database and finds your topic "116927 " and pulls down all the information from the needed fields ( such as your post info , the data created , number of replies ect ect ) what the file searches for and what those items mean in the url , are all defined in index.php or an include page within index.php using the $get function In summary , When a post is made there is no php file created , it is all index.php doing the work , each url is created from the code in index.php , and the information pulled from the database by index.php ( or any other file ) So effectivly one row in the database , is a thread ( same goes for posts or anythign else) Now sorry to keep it short and breif however I don't want to waste your time reading it if this isn't the info you need . I am hapy to explain it a bit further if it is , -
If you only have two options for each somethign allogn the lines of the bellow will work [code]<input type="radio" name="box1" value="0"> <input type="radio" name="box1" value="1"> <input type="radio" name="box2" value="0"> <input type="radio" name="box2" value="1"> <input type="radio" name="box3" value="0"> <input type="radio" name="box3" value="1">[/code] [code] $box1=$_POST['box1']; $box2=$_POST['box2'] ; $box3=$_POST['box3']; echo $box1 $box2 $box3 [/code] basicly what your left with here are $box1 $box2 $box3 which hold the value's for each box you can then place those anywhere you want , whether thats an echo or putting into a database KIS ( keep it simple )
-
Somethign else to be aware of is that you should hard code all of your colors and any formatting you want because if this is intended to go to people using things like gmail and hotmail you cant use css to style it as it will strip away any style tags before delivery this also makes using divs a bit of a pain in the ass but meeh not like they are gonna change it any time soon
-
Hi , I have an upload script that uploads images to my file server , resizes them and then inserts the value's into a database for referancing later on , I am hoping somone can help me with an if statement that I just don't seem to be getting right , basicly to give you a bit of background my information is passed by a form , using an aray for the uploads , the arrays I need to work with are $return[$i]['name'] $return[$i]['size'] & $return[$i]['type'] which are refered to individually by calling a digit inside the [] ( for exampel for the name of the seccond uplaod it would be ) $return[2]['name '] now the script itself works pretty fine if the user uploads two images they get no errors , however if they only upload one image , or if they upload an invalid file type it will spit out a series of errors on teh processing page which is obiously tellign me it couldn't do it because image 2 wasn't uploaded and therefore doesn't exist to work with, the actual uploading part of my script I have already managed to make it so it won't try to execute if there isn't a seccond file , however because I do my resizing as two seperate functions ( one for each ) one is always goign to fail untill I work out an if statement or unless I can work out how to do the rezising usign the aray instead of using the filenames themselfs anyways enough blabbering here is the resize seciton of my script , I really hope somone can assist [code]$img1_name=$return[1]['name']; $img1_type=$return[1]['type']; $img2_name=$return[2]['name']; $img2_type=$return[2]['type']; $strain_id=$_POST['strain_id'] ; $submitter=$_POST['submitter']; $comments=$_POST['comments']; /* resize script1 */ $im_file_name = './uploads/'.$img1_name.$img1_type; $image_attribs = getimagesize($im_file_name); $im_old = imageCreateFromJpeg($im_file_name); $th_max_width = 144; $th_max_height = 144; $ratio = ($width > $height) ? $th_max_width/$image_attribs[0] : $th_max_height/$image_attribs[1]; $th_width = $image_attribs[0] * $ratio; $th_height = $image_attribs[1] * $ratio; $im_new = imagecreatetruecolor($th_width,$th_height); imageAntiAlias($im_new,true); $th_file_name = './uploads/thumbs/' . $img1_name.$img1_type; imageCopyResampled($im_new,$im_old,0,0,0,0,$th_width,$th_height, $image_attribs[0], $image_attribs[1]); imageJpeg($im_new,$th_file_name,100); /* resize script part2 */ $im_file_name2 = './uploads/'.$img2_name.$img2_type; $image_attribs2 = getimagesize($im_file_name2); $im_old2 = imageCreateFromJpeg($im_file_name2); $ratio = ($width > $height) ? $th_max_width/$image_attribs2[0] : $th_max_height/$image_attribs2[1]; $th_width2 = $image_attribs2[0] * $ratio; $th_height2 = $image_attribs2[1] * $ratio; $im_new2 = imagecreatetruecolor($th_width2,$th_height2); imageAntiAlias($im_new2,true); $th_file_name2 = './uploads/thumbs/' . $img2_name.$img2_type; imageCopyResampled($im_new2,$im_old2,0,0,0,0,$th_width2,$th_height2, $image_attribs2[0], $image_attribs2[1]); imageJpeg($im_new2,$th_file_name2,100); [/code] so in short basicly what i need to do is now have the part under resize script part 2 run UNLESS there is a seccond file uploaded thanx in advance
-
I need to make a rating system for my website and need some help with the way i want to display it basicly I have an idea of what i need to do but don't know how to go abotu doing it , the perfect script would be able to use X ( database value) as the number of images to show in the row that way say if the person had a rating of 4 , then 4 images would apear my other option ofcourse is to have it as seperate files wich is what i have in place at the moment but i figured if I was doign all i can to learn then I want to use php as much as possible :)
-
how can I limit the number of selected boxes to 2 in a form like the one bellow [code]<form> <tr><td><INPUT TYPE=CHECKBOX NAME="taste_type[]" onclick="boxchk(this,3)" VALUE="Berry">Berry</td> <td><INPUT TYPE=CHECKBOX NAME="taste_type[]" VALUE="Bubblegum">Bubblegum</td> <td><INPUT TYPE=CHECKBOX NAME="taste_type[]"VALUE="Chemical">Chemical</td> <td><INPUT TYPE=CHECKBOX NAME="taste_type[]" VALUE="Citrus">Citrus</td> <td><INPUT TYPE=CHECKBOX NAME="taste_type[]" VALUE="Chocolate" >Chocolate</td></tr> </form>[/code]
-
Sorry to bother you all about this script again , but i was hoping to add one more functional feature to it I wanted to make it so that only 2 of the check boxes can be selected would my best option for this be to use javascript ? or is there a way I can do it with php ? I have been trying to do it with a javascript but I am not sure that I am doign it right or if it will work because I am using the [] at the end of the name and have to keep them all the same for scripts like the one found at http://webmaster.lycos.co.uk/tips/987521434/