Jump to content

Lisa23

Members
  • Posts

    221
  • Joined

  • Last visited

Everything posted by Lisa23

  1. this is the form script where new date is entered <?php // query to get records $news_id = $_GET['news_id'] ; // create query to delete record $query = "SELECT news_id, news_date, subject, news_artical, DATE_FORMAT(news_date, '%d/%m/%Y') as new_date FROM news WHERE news_id = '$news_id' "; //Run the query $result = mysql_query($query); //see if any rows were returned if (mysql_num_rows($result) > 0) { // yes - Display Form $row = mysql_fetch_array($result); //Fetch the row //Display the form with original values ?> [/php and this is the update action part of the form [code=php:0]<?php //Get the key field to be amended $news_id = $_GET['news_id']; $news_date = date('Y-m-d', strtotime($_GET['new_date'])); $subject = $_GET['subject']; $news_artical = $_GET['news_artical']; // check if there were any errors // check if there were any errors $query = "SELECT news_id, news_date, subject, news_artical, DATE_FORMAT(news_date, '%d/%m/%Y') as new_date FROM news WHERE news_id = '$news_id' "; //$news_date = STR_TO_DATE('$news_date','%Y/%m/%d'); $query = "UPDATE news SET news_date = '$new_date', subject='$subject', news_artical='$news_artical' WHERE news_id = '$news_id'"; mysql_query($query) or die(mysql_error());
  2. ohh yeah new date is this line u'll notice i have news_date as new dare which comes from the form the other part is the action script of the this form $query = "SELECT news_id, news_date, subject, news_artical, DATE_FORMAT(news_date, '%d/%m/%Y') as new_date FROM news WHERE news_id = '$news_id' ";
  3. well i thought that strot would allow me to set the date in a format of how i wish cz before i couldnt display how i wanted but now that strot and this line allow me to display the date in any format i want the problem is when update it sets back to 01-01-1927 $query = "UPDATE news SET news_date = '$news_date', subject='$subject', news_artical='$news_artical' WHERE news_id = '$news_id'";
  4. i dnt think so why do u think that do u think thats whats causing the problem?? i tried to change to $_GET['news_date'] but still doesnt solve the problem??
  5. Hi i have a form which display the date in the format that i want which is m/d/yyyy but then when i try update it sets the date back to 01/01/1970 help please this how the update script looks like <?php //Get the key field to be amended$news_id = $_GET['news_id']; $news_date = date('Y-m-d', strtotime($_GET['new_date']));$subject = $_GET['subject'];$news_artical = $_GET['news_artical'];// check if there were any errors// check if there were any errors//$news_date = STR_TO_DATE('$news_date','%Y/%m/%d');$query = "UPDATE news SET news_date = '$news_date', subject='$subject', news_artical='$news_artical' WHERE news_id = '$news_id'";mysql_query($query) or die(mysql_error()); // execute query print "<p>The following records has been updated: </p>";$result = mysql_query($query) ;//if there was a problem - get the error message and go back if (!$result) { echo "There were errors :<br>". mysql_error(); } else //OK, then the insertion was successful { //Create a new query to display the new row in a table $query = "SELECT news_id, news_date, subject, news_artical, DATE_FORMAT(news_date, '%d/%m/%Y') as new_date FROM news WHERE news_id = '$news_id' "; $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); echo "<table cellpadding=10 border=1>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>".$row["news_id"]."</td>"; echo "<td><strong>" .$row["new_date"]."</strong></td>"; echo "<td><strong>".$row["subject"]."</strong></td>"; echo "<td width='55%'>".$row["news_artical"]."</td>"; echo "</tr>"; } //End while echo "</table>"; } //End Else insertion successful//End else successful Amendment ?>
  6. thanks put next to it one last question how can i resize???
  7. do u mean replace this $path1= "images/posters/".$_FILES['ufile']['name'][0]; $path2= "images/posters/".$_FILES['ufile']['name'][1]; $path3= "images/posters/".$_FILES['ufile']['name'][2]; with what u sent me or put that next to it??
  8. Hi i have a simple triple upload file script that upload files with its own name it works fine but what i want is to be able to specify the name of the image like file 1 give name (blue) file 2 name (tree) file 3 name (sky) <?php //set where you want to store files //in this example we keep file in folder upload //$HTTP_POST_FILES['ufile']['name']; = upload file name //for example upload file name cartoon.gif . $path will be upload/cartoon.gif $path1= "images/posters/".$_FILES['ufile']['name'][0]; $path2= "images/posters/".$_FILES['ufile']['name'][1]; $path3= "images/posters/".$_FILES['ufile']['name'][2]; //copy file to where you want to store file copy($_FILES['ufile']['tmp_name'][0], $path1); copy($_FILES['ufile']['tmp_name'][1], $path2); copy($_FILES['ufile']['tmp_name'][2], $path3); //$HTTP_POST_FILES['ufile']['name'] = file name //$HTTP_POST_FILES['ufile']['size'] = file size //$HTTP_POST_FILES['ufile']['type'] = type of file echo "File Name :".$_FILES['ufile']['name'][0]."<BR/>"; echo "File Size :".$_FILES['ufile']['size'][0]."<BR/>"; echo "File Type :".$_FILES['ufile']['type'][0]."<BR/>"; echo "<img src=\"$path1\" width=\"150\" height=\"150\">"; echo "<P>"; echo "File Name :".$_FILES['ufile']['name'][1]."<BR/>"; echo "File Size :".$_FILES['ufile']['size'][1]."<BR/>"; echo "File Type :".$_FILES['ufile']['type'][1]."<BR/>"; echo "<img src=\"$path2\" width=\"150\" height=\"150\">"; echo "<P>"; echo "File Name :".$_FILES['ufile']['name'][2]."<BR/>"; echo "File Size :".$_FILES['ufile']['size'][2]."<BR/>"; echo "File Type :".$_FILES['ufile']['type'][2]."<BR/>"; echo "<img src=\"$path3\" width=\"150\" height=\"150\">"; /////////////////////////////////////////////////////// // Use this code to display the error or success. $filesize1=$_FILES['ufile']['size'][0]; $filesize2=$_FILES['ufile']['size'][1]; $filesize3=$_FILES['ufile']['size'][2]; if($filesize1 && $filesize2 && $filesize3 != 0) { echo "We have recieved your files"; } else { echo "ERROR....."; } ////////////////////////////////////////////// // What files that have a problem? (if found) if($filesize1==0) { echo "There're something error in your first file"; echo "<BR />"; } if($filesize2==0) { echo "There're something error in your second file"; echo "<BR />"; } if($filesize3==0) { echo "There're something error in your third file"; echo "<BR />"; } ?>
  9. THANK YOU PAUL if anyday i became i expert in php dnt hesitate to ask 4 help... lol thank u ...
  10. yep sorry for the trouble i didnt had the display on the mysql Select its wrking now THANK YOU VERY MUCH :-*
  11. i think i realised where on the mysql select i didnt had the display i think it should work now trying
  12. Array ( [0] => 254 [id] => 254 [1] => novo [name] => novo [2] => machester [location] => machester [3] => 0000-00-00 [date_of_birth] => 0000-00-00 [4] => renault [car_number] => renault [5] => monaco [favourite_track] => monaco [6] => least [least_favourite_track] => least [7] => Achievements [achievements] => Achievements [8] => Sponsors [sponsors] => Sponsors [9] => [email protected]. => [email protected]. [10] => [image] => ) this what the database looks like display varchar(30) latin1_swedish_ci No None this what the whole form looks like <?php define('ROOT_DIR', './'); define('THIS_SCRIPT', 'news'); define('PROPER', TRUE); /** * include common files */ include_once(ROOT_DIR. 'includes/common.inc.php'); ?> <?php // query to get records $id = $_GET['id'] ; // create query to delete record $query = "SELECT id, name, location, date_of_birth, car_number, favourite_track, least_favourite_track, achievements, sponsors, email, image FROM driversnew WHERE id = '$id' "; //Run the query $result = mysql_query($query); //see if any rows were returned if (mysql_num_rows($result) > 0) { // yes - Display Form $row = mysql_fetch_array($result); //Fetch the row //Display the form with original values ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>My xhtml page styled with CSS</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link href="style/style.css" rel="stylesheet" type="text/css" /> <style type="text/css"> <!-- body { background-color: #FFFFFF; } .style1 {font-size: 12px} --> </style> <h1 align="center"><a href="driverslist.php">Back</a> Admin Center <a href="index.php">Home</a></h1> <p align="center"><font face="Verdana" size="5"><strong>Edit driver form </strong></font></p> <p align="center"><font face="Verdana" size="2"><b><i>This page allow's you to modify drivers details</font></p> <p align="center"> </p> <body marginheight="0" marginwidth="0" leftmargin="0" topmargin="0"> <center> <form action = 'modifydriveraction.php?drivers=<?php echo $row['id']; ?>' method="POST" enctype="multipart/form-data"> <table cellspacing='16' cellpadding='0' border='0' > <tr> <p class="style1">ID field 'readonly' as cannot amend key field</p> <td class="form_field" valign='top' align='right'>ID: </td><td width='10' align='right' valign='top'> </td> <td class="form_text"> <input type="text" readonly="yes" name="id" class='text_box' value=<?php print $row["id"] ?>> </td> </tr> <tr> <td class="form_field" valign='top' align='right'>Name: </td><td width='10' align='right' valign='top'> </td> <td class="form_text"> <input type="text" name="name" class='text_box' value=<?php print $row["name"] ?>> </td> </tr> <tr> <td class="form_field" valign='top' align='right'>Location: </td><td width='10' align='right' valign='top'> </td> <td class="form_text"> <input type="text" name="location" class='text_box' value=<?php print $row["location"] ?>> </td> </tr> <tr> <td class="form_field" valign='top' align='right'>Date of Birth: </td><td width='10' align='right' valign='top'></td> <td class="form_text"> <?php $getDate = $row['date_of_birth']; $splitDate = explode('-',$getDate); $thisMonth = $splitDate[1]; $thisDay = $splitDate[2]; $thisYear = $splitDate[0]; $months = array('','January','February','March','April','May','June','July','August','September','October','November','December'); echo '<select name="month_of_birth">',"\n"; for ($i=1;$i<13;++$i) { if($i == $thisMonth) { $s = ' selected'; } else { $s=''; } echo '<option value="' ,$i, '"',$s,'>' ,$months[$i], '</option>',"\n"; } echo '</select>',"\n"; echo '<select name="day_of_birth">',"\n"; for ($i=1;$i<32;++$i) { if($i == $thisDay) { $s = ' selected'; } else { $s=''; } echo '<option value="' ,$i, '"',$s,'>' ,$i, '</option>',"\n"; } echo '</select>',"\n"; echo '<select name="year_of_birth">',"\n"; $year = date("Y"); for ($i = $year;$i > $year-50;$i--) { if($i == $thisYear) { $s = ' selected'; } else { $s=''; } echo '<option value="' ,$i, '"',$s,'>' ,$i, '</option>',"\n"; } echo '</select>',"\n"; ?> </td> </tr> <tr> <td class="form_field" valign='top' align='right'>Car Number: </td><td width='10' align='right' valign='top'> </td> <td class="form_text"> <input type="text" name="car_number" class='text_box' value=<?php print $row["car_number"] ?>> </td> </tr> <tr> <td class="form_field" valign='top' align='right'>Favourite Track: </td><td width='10' align='right' valign='top'></td> <td class="form_text"> <input type="text" name="favourite_track" class='text_box' value=<?php print $row["favourite_track"] ?>> </td> </tr> <tr> <td class="form_field" valign='top' align='right'>Least Favourite Track: </td><td width='10' align='right' valign='top'></td> <td class="form_text"> <input type="text" name="least_favourite_track" class='text_box' value=<?php print $row["least_favourite_track"] ?>> </td> </tr> <tr> <td class="form_field" valign='top' align='right'>Achievements: </td><td width='10' align='right' valign='top'></td> <td class="form_text"> <textarea name="achievements" rows=4 cols=25 ><?php print $row["achievements"] ?> </textarea> </td> </tr> <tr> <td class="form_field" valign='top' align='right'>Sponsors: </td><td width='10' align='right' valign='top'></td> <td class="form_text"> <textarea name="sponsors" rows=4 cols=25 ><?php print $row["sponsors"] ?> </textarea> </td> </tr> <tr> <td class="form_field" valign='top' align='right'>Email Address: </td><td width='10' align='right' valign='top'></td> <td class="form_text"> <input type="text" name="email" class='text_box' value=<?php print $row["email"] ?>> </td> </tr> <tr> <td class="form_field" valign='top' align='right'>Image: </td><td width='10' align='right' valign='top'></td> <td class="form_text"> <input type="file" name="image" value="" class='text_box'> <?php echo '<td><img class="picture" src="images/' . $row['image'] . ' " width="120" height="120 " /></td> '; ?> </td> </tr> <tr> <td class="form_field" valign='top' align='right'></td><td width='10' align='right' valign='top'></td> <td class="form_text"> <?php echo '<pre>'; print_r($row); echo '</pre>'; ?> </td> </tr> <tr><td colspan=3 align='center'><input type="submit" value="Submit" name="Submit" ></td></tr> </table> </form> <?php } //End if rows returned //No rows returned else print "No records were found"; ?> </center> </body> </html>
  13. still nothing thats weird i even tried to change the name of the column but nothing if i try echo a diffrent row it works bt that particular one doesnt wrk?? i changed the name of the column which it shouldnt show on a different page but it does on a different page
  14. nothing happen no display thats strange why??? but the update always worked
  15. i think something wrong with the statment becasue i made simple echo but it walays echo NO so the if statment seem to have no first part of the if statment doesnt weem to be working is the sintax wrong?? <?php if($row['display'] == 'yes') { echo "working"; } else { echo "NO"; } ?>
  16. i had the database has int changed to var chars and value yes and no but still nothing it seems like its only picking up the else statment
  17. ohh no it does update but it doesnt do the effect like if == 1 selected 1 else selected 2 doesnt work it always keeping 0 as selected no matter what avlue on the database <?php if($row['display'] == '1') { echo "<select name='display'>\n", "<option value='1' selected>1</option>\n", "<option value='0'>0</option>\n", "</select>\n"; } else { echo "<select name='display'>\n", "<option value='1'>1</option>\n", "<option value='0' selected>0</option>\n", "</select>\n"; } ?>
  18. yeah like the one u said here earlier yeah For example if $row['display'] equals 1 you want <select name="display"> <optionvalue ="1" selected>1</option> <option value ="0">0</option> </select> else <select name="display"> <optionvalue ="1">1</option> <option value ="0" selected>0</option> </select>
  19. <select name="display"> <option value="1">1</option> <option value="0" selected>0</option> </select> i want the selected option to depend on the value already stored on the database i tried like this but sintax error <?php echo '<select name="display">'; if($row['display'] == '1') { echo '<option selected value='1'>1</option>'; }else{ echo "<option selected value="0">0</option>"; } echo '</select>'; ?>
  20. ok this what i have thats a simple form that enter the values in the database using the insert works fine but lest say you have a edit form and u want to edit it on the form i want to display the option of the value that is on the database had so if u have stored 0 on the database when u edit the form the firts option that will appear will be will be 0 yes u can change to 1 from the drop down list which when submited will update to 0 and if u edit the form again the first iption that will appear will be 0 basicaly show the option depending on the row display is that any clear??? <select name="display"> <option value="1">1</option> <option value="0">0</option> </select>
  21. i tried like this but no sucess <?php if if($row['display'] == '1') { echo "<option value="1">1</option>"; }else{ echo "<option value="0">0</option>"; } ?>
  22. is there a way to do if row 1 display the option 1 else display the option 0 to wrk on the options
  23. nope it always display the option 1 even if the value on the database is the 0.... it updates.... bt doesnt show when u edit it always display option value 1
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.