-
Posts
1,008 -
Joined
-
Last visited
Everything posted by spiderwell
-
set an extra column in the db called approved, and have it default to 0 in db structure, then as later admin you can set to 1 to approve it. when user submits, use the same code, as approved wont need entering to the row, its will set to 0 by default. then via phpmyadmin, or build a page for an admin to login to set approved to 1 **disclaimer** this is how i would do it, there might be a better way
-
mysql accepts dates as yyyy-mm-dd try $date ="$_POST['year']-$_POST['month']-$_POST['day']" this assumes your values are numbers not words, e.g. month is 12 not december
-
try $_GET['id'] not $_GET[id] ? not good practice to put raw data into an sql statement, pass the value to a local variable first and validate its what you expect it to be. echoing out the sql statement will show you what is being passed to the database, handy when things arent working
-
<?php echo "<h1>$title</h1>" ?> //This is line 12
-
change the action of the form to the name of the php file you are posting to, i.e. sendinfo.php, if you dont give action a value it will post to itself the radio buttons are nearly there, you dont really need the id in this instance, change the values to be the same as the label text: <label> <input type="radio" name="stockinfo" value="aviation" id="stockinfo_0"> Aviation and Aerospace</label> as you have it they all contain the value of 'radio' in the php page have this: echo $_POST['stockinfo']; when you POST a form all the input elements are put into the $_POST[] array, then use the name of the element you want to retrieve the value from into that array so for the radio button elements you have i use $_POST['stockinfo'] if you had a text input in the form aswell with asking for the user to enter there name that looks like this: <label><input type="text" name="myname"> Enter name</label> you would get the value by echo $_POST['myname']; dont worry the php will get easier, especially if you hand code it, dreamweaver is great but it doesnt actually teach you php, its more a designers tool than a developers (in my opinion), notepad++ is what I use personally.
-
happy to help now its your turn, how do you mark a post as solved?
-
oh boy, erm how much php have you done? read this id is like a name but unique, rather than name can be multiple (radio buttons have the same name) of the form element, value is whats stored in that form element <input name="username" value="stepo"> this will give text input with a prefilled value of stepo retrieve it from form by trying echo $_POST['username']
-
hot_job and nurse_vet are column names, never put quotes around them as quotes represent values, use backticks or omit altogether `hot_job`='blah', nurse_vet = 'stripper' I'm going for a smoke, you better have it working by the time i get back
-
create the new page called info.html make a select dropdown box or a radio button (checkboxes allow multiple sections and it states one select 1 type) add options like banks,oil,gold,frozen oj,pork bellies, etc the sendinfo.php will then get the value selected lets say it was oil, and returns information about oil stocks. in this case the assignment states open a text file thats relevant, so i would suggest you make a correlation of: filenames = values from the form. user selects oil, open file oil.txt and read contents into webpage. user selects banks, it opens banks.txt read a text file link
-
its because of your insistence of using several variables with different names for the same value $hot is filled , but then you put $hot_job in the sql.
-
5 key stages in the assignment, and no indication to which part you are struggling with, I expect I speak for many members when I say 'jog on' this is a help forum, not a 'hand your assignment over to a stranger to do' forum. You post indicates no thought processes towards your assigned work, none of us are mind readers, give us something, we are likely to give something back.
-
if ($userlevel = 3){ ?> spot the error in here also
-
you are still muddling editid and id variables, and now you are asking for an editid via $_GET inside a $_POST so it wont work change this bit if ($_POST) { $editid = $_GET['editid']; to if ($_POST) { $editid = $_POST['id']; showing exactly why you should stick to 1 variable through a process, in your script you have $delid,$editid $id and they all carry the same value (ID from the database table) I cannot urge you enough to stop doing this you are using action to decide what $action to take, not $id, its so not needed and only proving to make things more complicated for you unnesscessarily TIP: a very good way to check the sql is to echo out the sql statement into the page whilst you develop $query2 = "UPDATE jobs SET job_title='$job_title',job_description='$job_description',job_type='$job_type',job_area='$job_area','hot_job'='$hot_job','nurse_vet'='$nurse_vet' WHERE id=$editid"; echo $query2;
-
whats with </tc> and </td> endings on cells? I never heard of </tc>
-
How to color code certain words of PHP database output?
spiderwell replied to vbcoach's topic in PHP Coding Help
this is no longer a php issue, lol the red should only effect the spanned text. can you post all the relevant code -
How to color code certain words of PHP database output?
spiderwell replied to vbcoach's topic in PHP Coding Help
echo "<span class='something'>(locked)<span>"; echo "<span style='color:red;'>(locked)<span>"; -
I am sorry i got that wrong, it worked perfectly. I thought I could just have one class to cover all red text in various different lists, but i guess i need the red class defined inside each id specified too. good to learn though, i am so guilty of not learning css properly as this thread proved
-
thats because when you post its still executing the prepopulation part too. also you are using 2 variables for the same value $editid and $id are the same thing, chose one and stick to that throughout if(action=="edit") { if ($_POST) { //do the updating stuff } else { //show prepopulated form } }
-
ah nice link there, basically the id has a higher specificity so it over rules the applied class. sunfighter, your idea would be fine if it was all <li> to have red font, but I only want 1 of them too. I guess I hadn't made it clear enough.
-
did you not pass the ID as a hidden field too? or do you mean when prepopulating?
-
so having divs that toggle from hidden and visible could affect your SE rankings? only i have made many pages in the past where i have a list of items than when clicked 'show' the div containing the relevant info, and hide all the others (all divs positioned in same place)
-
i have a UL within a DIV that has an ID, i then use that to set up styling for the list and its elements. .red {color:#ff0000; font-weight:bold;} #sectionlist { list-style: none; width:800px;margin-left:0; } #sectionlist ul{ list-style: none; margin:0px; padding:0px;} #sectionlist li { position: relative; margin: 2 0 0 0; width: 800px;-moz-border-radius: 5px; -webkit-border-radius: 5px; font-size:14px; border:#000000;text-decoration: none; padding: 1px; margin-right: 3px; border: 1px solid #778; color: #2d2b2b; background-color: #ddddff; height:22px; margin-top:2px; text-align:left; font-size:12px; } now i want to make one of the <li> elements have red text, i add a class called red so it looks like this <li class="red"> but it never shows up red, i have to end up adding a span or div inside the <li> to get the class of red to work. is this normal behaviour or am I missing something?
-
since the form still has an action of edit, try the if ($_POST) method. if form is posted, update data, if not prefill the form.
-
try echoing put the $row[] data before you pass to variables, just to be sure that it is pulling out the data from the database? also your hidden field is borked, its got a name that probably (im not 100'%) got illegal characters, and no value. does teh form itself display? if it does it means something is found in the database as its echoed inside the while loop
-
it looks like your edit mode only pre fills the form, and doesnt actually update the database on submission. perhaps add a hidden field in the edit form called update and set it to true, or =1 ,whatever really then under the ($action=='edit') part you can either update the submitted data (because update is true), or show the prefilled form with the data (because update isnt true) you could also do it by checking if $_POST is true instead of $_GET.