PHP - Multi Line Update Button
i have a form per row with an update button
my problem is to update each row at a time so i created a unique update button per row, not working Code: [Select] <table cellspacing="0" cellpadding="0" border="1"> <col width="75" span="5" /> <tr> <td width="75">Proposal</td> <td width="75"> </td> <td width="75">Supplier</td> <td width="75">Downpayment</td> <td width="75">Payment Method</td> <td width="75">Status</td> <td width="75"> </td> </tr> <?php do { ?> <tr><form id="form1" name="form1" method="post" action=""> <td><?php echo $row_RsDownPayment['RequestID']; ?>-<?php echo $row_RsDownPayment['ProposalID']; ?></td> <td><?php echo $row_RsDownPayment['CustomerLastName']; ?></td> <td><?php echo $row_RsSupplier['SupplierName']; ?></td> <td><?php echo $row_RsDownPayment['PREPAYMENT2SUPPLIER']; ?></td> <td><select name="PaymentMethod" id="PaymentMethod"> <option value="0">Choose</option> <option value="Bank Transfer">Bank Transfer</option> <option value="CreditCard">CreditCard</option> <option value="Cash">Cash</option> <option value="PayPal">PayPal</option> </select></td> <td><?php echo $row_RsStatus['StatusLabel']; ?></td> <td><input name="<?php echo $U='Update'.$row_RsDownPayment['ProposalID'];?>" type="submit" value="Update" /> </td></form> </tr> <?php $con = mysql_connect("host","db","db"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_query("SET NAMES 'utf8'"); mysql_select_db("db", $con); if (isset($_POST['Update121'])) { $query=mysql_query("UPDATE proposals SET StatusID='$_POST[StatusID]' WHERE ProposalID = '$row_RsDownPayment[ProposalID]'"); exit; } ?> <?php } while ($row_RsDownPayment = mysql_fetch_assoc($RsDownPayment)); ?> </table> Similar TutorialsHello everebody, i have code to updare many rows at once using "for". when i click submit button nothing happens, where is the error in my code? thank you very much for your help <?php $hoster="db.mkq.de"; $username="dbxxxxxx"; $password="xxxxxx"; $db_name="xxxxxx"; mysql_connect("$hoster", "$username", "$password") or die("cannot connect"); mysql_select_db("$db_name") or die("cannot select DB"); $sql="SELECT * FROM gbook"; $result=mysql_query($sql); $count=mysql_num_rows($result); ?> <table width="500" border="0" cellspacing="1" cellpadding="0"> <form name="form1" method="post" action=""> <tr> <td> <table width="500" border="0" cellspacing="1" cellpadding="0"> <tr> <td align="center"><strong>Id</strong></td> <td align="center"><strong>www</strong></td> <td align="center"><strong>email</strong></td> <td align="center"><strong>pwd</strong></td> </tr> <?php while($rows=mysql_fetch_array($result)){ ?> <tr> <td align="center"> <input name="id[]" type="text" id="id" value="<? echo $rows['id']; ?>"> </td> <td align="center"> <input name="www[]" type="text" id="www" value="<? echo $rows['www']; ?>"> </td> <td align="center"> <input name="email[]" type="text" id="email" value="<? echo $rows['email']; ?>"> </td> <td align="center"> <input name="pwd[]" type="text" id="pwd" value="<? echo $rows['pwd']; ?>"> </td> </tr> <?php } ?> <tr> <td colspan="4" align="center"><input type="submit" name="submit" id="submit" value="update"></td> </tr> </table> </td> </tr> </form> </table> <?php if($submit) { for($i=0;$i<$count;$i++) { $sql1="UPDATE gbook SET www='$www[$i]', email='$email[$i]', pwd='$pwd[$i]' WHERE id='$id[$i]'"; $result1=mysql_query($sql1); } } if($result1) { header("location:editmulti3.php"); } mysql_close(); ?> Hi all, I have a data base with the following table: ---member_data--- id ^ mid ^fieldname^ fieldvalue 1 - 2 - applicant - Seth Smith 2 - 4 - firstname - Chris 3 - 4 - lastname - Cooper 4 - 7 - full_name - Joey Jones 5 - 7 - occupation - Programmer 6 - 7 - phone - 800-555-1212 And below is a snippet that I use to display the selected members data for editing ------------------------------- <table> <tr> <td>Name:</td> <td>Value:</td> </tr> <?php $query = "SELECT * FROM member_data WHERE mid='$mid'"; $result= mysql_query($query); while($row = mysql_fetch_array($result)) { $fieldname = $row["fieldname"]; $fieldvalue = $row["fieldvalue"]; ?> <tr> <td><input type="text" name="<?php echo $fieldname;?>" value="<?php echo $fieldname;?>"></td> <td><input type="text" name="<?php echo $fieldvalue;?>" value="<?php echo $fieldvalue;?>"></td> <?php } ?> </tr> </table> ------------------------------- My question is: - using the Db example above: - lets say Ive selected mid#7 (member id 7) to edit which is displayed using the snippet code from above. - once displayed how do I edit mid#7 given the fact that mid#7 is located on 3 seperate rows from the same table? Thank you, Dave *ALSO - I tried the snippet below which did Not work. foreach($_POST as $key => $val) { $sql = "UPDATE member_data SET fieldname='$key', fieldvalue='$val' WHERE mid='$mid'"; $result = mysql_query($sql); } Hi there, hope have some help. I have a form where a user select time and days of the week (monday, tuesday..) that he is available. The insert script works fine, it insert and the days of week he checked in the table, the only problme is when i try to update each of them.
I used this code above, but is not working, instead of updating/inserting days that is selected is inserting multi-records with the same day of the week value.
here it is:
foreach($weekDay as $DaysofWeek){ $sql_days = "UPDATE available SET day_time = '$day_time', week_day = '$DaysofWeek' WHERE user_id = '$id_user'"; $update_availability = mysql_query($sql_days); } hi all i have a problem here, Iv got a form that uploads images to a folder and updates the db with the name of that image, that work ok but if one of the upload field are left blank then the script updates the db with empty values how can i get it to only update the db with only submitted form field data???? here is the form Code: [Select] <?php if (isset($_GET['id'])) { $id = $_GET['id']; } ?> <form action="ud_image.php?id=<? echo "$id"?>" method="post" enctype="multipart/form-data" name="form1" id="form1"> <table class="udp"> <tr> <th>Thumbnail:</th> <td><input type="hidden" name="MAX_FILE_SIZE" value="1029120" /> <input name="ufile[]" type="file" id="ufile[]" size="50" /></td> </tr> <tr> <th>Image 1:</th> <td><input type="hidden" name="MAX_FILE_SIZE" value="1029120" /> <input name="ufile[]" type="file" id="ufile[]" size="50" /></td> </tr> <tr> <th>Image 2:</th> <td><input type="hidden" name="MAX_FILE_SIZE" value="1029120" /> <input name="ufile[]" type="file" id="ufile[]" size="50" /></td> </tr> <tr> <th>Image 3:</th> <td><input type="hidden" name="MAX_FILE_SIZE" value="1029120" /> <input name="ufile[]" type="file" id="ufile[]" size="50" /></td> </tr> <tr> <th>Image 4:</th> <td><input type="hidden" name="MAX_FILE_SIZE" value="1029120" /> <input name="ufile[]" type="file" id="ufile[]" size="50" /><input type="submit" name="Submit" value="Upload" /></td> </tr> </table> </form> and here is the processing page <?php include("protect/password_protect.php"); error_reporting(E_ALL); include ("../includes/db_config.php"); $con = mysql_connect($db_hostname,$db_username,$db_password); @mysql_select_db($db_database) or die( "Unable to select database"); $path1= "../thumbnails/".$_FILES['ufile']['name'][0]; $path2= "../images/".$_FILES['ufile']['name'][1]; $path3= "../images/".$_FILES['ufile']['name'][2]; $path4= "../images/".$_FILES['ufile']['name'][3]; $path5= "../images/".$_FILES['ufile']['name'][4]; //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); copy($_FILES['ufile']['tmp_name'][3], $path4); copy($_FILES['ufile']['tmp_name'][4], $path5); ?> <html> <head> <title>Update Project Images</title> <link rel="stylesheet" type="text/css" href="../../project/backend/style.css" /> </head> <body> <table class="udip"> <tr> <th><? echo "<img src=\"$path1\" width=\"150\" height=\"150\">";?></th> <th><? echo "<img src=\"$path2\" width=\"150\" height=\"150\">";?></th> <th><? echo "<img src=\"$path3\" width=\"150\" height=\"150\">";?></th> <th><? echo "<img src=\"$path4\" width=\"150\" height=\"150\">";?></th> <th><? echo "<img src=\"$path5\" width=\"150\" height=\"150\">";?></th> </tr> <tr> <td><? echo "File Name :".$_FILES['ufile']['name'][0]."<BR/>";?></td> <td><? echo "File Name :".$_FILES['ufile']['name'][1]."<BR/>";?></td> <td><? echo "File Name :".$_FILES['ufile']['name'][2]."<BR/>";?></td> <td><? echo "File Name :".$_FILES['ufile']['name'][3]."<BR/>";?></td> <td><? echo "File Name :".$_FILES['ufile']['name'][4]."<BR/>";?></td> </tr> <tr> <td><?echo "File Size :".$_FILES['ufile']['size'][0]."<BR/>";?></td> <td><?echo "File Size :".$_FILES['ufile']['size'][1]."<BR/>";?></td> <td><?echo "File Size :".$_FILES['ufile']['size'][2]."<BR/>";?></td> <td><?echo "File Size :".$_FILES['ufile']['size'][3]."<BR/>";?></td> <td><?echo "File Size :".$_FILES['ufile']['size'][4]."<BR/>";?></td> </tr> <tr> <td><? echo "File Type :".$_FILES['ufile']['type'][0]."<BR/>";?></td> <td><? echo "File Type :".$_FILES['ufile']['type'][1]."<BR/>";?></td> <td><? echo "File Type :".$_FILES['ufile']['type'][2]."<BR/>";?></td> <td><? echo "File Type :".$_FILES['ufile']['type'][3]."<BR/>";?></td> <td><? echo "File Type :".$_FILES['ufile']['type'][4]."<BR/>";?></td> </tr> </table> </body> </html> <? $filesize1=$_FILES['ufile']['size'][0]; $filesize2=$_FILES['ufile']['size'][1]; $filesize3=$_FILES['ufile']['size'][2]; $filesize4=$_FILES['ufile']['size'][3]; $filesize5=$_FILES['ufile']['size'][4]; if($filesize1 && $filesize2 && $filesize3 && $filesize4 && $filesize5 != 0) { echo "We have recieved your files<p>"; } else { echo "Error in you images check and try again Database has been updated to blank images so no images will be shown on details page."; } $query = "UPDATE $db_table SET thumbnail = '".$_FILES['ufile']['name'][0]."', image1 = '".$_FILES['ufile']['name'][1]."', image2 = '".$_FILES['ufile']['name'][2]."', image3 = '".$_FILES['ufile']['name'][3]."', image4 = '".$_FILES['ufile']['name'][4]."' WHERE id = '".$_GET['id']."'"; if (!mysql_query($query,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; mysql_close($con) ?> Hello, I have the following function function make_agent_drop($dropname,$parent=''){ $agents = mysql_query("SELECT * FROM ad_category WHERE cat_status='1' AND parent_id='".(is_numeric($parent)?$parent:"0")."'") or die(mysql_error()); $anum = mysql_num_rows($agents); if($anum>0){ $agentdrop='<select style="width:150px; height:20px; margin-left:100px; font-size:11px;" name="'.$dropname.'" id="'.$dropname.'" class="text" '.(is_numeric($parent)?'':'onchange="update_subcatdrop($(this).val());').'"> <option value="0">Select a Category</option>'; while($row= mysql_fetch_array($agents)){ $agentdrop.='<option value="'.$row['cat_id'].'">'.$row['cat_name'].'</option>'; } $agentdrop.='</select>'; }else{ $agentdrop= 'No '.(is_numeric($parent)?'Sub':'').'Categories Found.'; } return $agentdrop; ; } I creates a drop down from database cats and sub cats.. I am trying to figure out how to add a submit button to dynamically appear when it displays the sub category... Thanks! Dan Hello I am trying to do a simple button that will change a single field in database depending on its already existing value eg: if value is 0 then button should read 0 and on click change value in field to 1, and then button should read 1. Basically an "ON/OFF" button. Any examples to do this in a simple way? Good Day, I juz like to know if there any other alternative way for the code below, coz i can't update my form when i use this method for radio the button. It's not passing the value. Code: [Select] Edit.php <tr> <td height="36" align="center" valign="middle" bgcolor="#990000"><div align="left" class="style4">Destroy :</div></td> <td align="center" valign="middle" bgcolor="#990000"><div align="left"> <label> <input type=radio name=destroyR value="Yes" <?php echo ($rows['destroy']=='Yes') ?'checked="checked"':''; ?> />Yes</label> <label> <input type=radio name=destroyR value="No" <?php echo ($rows['destroy']=='No') ?'checked="checked"':''; ?> />No</span></label> </div></td> </tr> I need to create several buttons that when clicked it updates a field in a table and then passes params to another page (action). I cant seem to figure a logical way of doing this without making things messy, any one have any ideas When I display the data in my database I have included a radio button in each row. When the button is clicked, the intention is to delete all the information in that row. But it won't delete anything... Here's the form: Code: [Select] <FORM Method = "POST" action ="update_tee_times.php"> <?php include("opendatabase.php"); $dateID = $_POST[teetimedate]; $result = mysql_query(" SELECT Date, Player1,Player2,Player3,Player4,Player5,Time, IF( TIME(Time) BETWEEN '17:30:00' AND '19:30:00','FFFF66','FFFFFF') AS color FROM Daysheets WHERE Date ='$dateID'"); echo "<h1>"; echo date("l, F d, Y", strtotime($dateID)); echo "</h1>"; echo "<table align=center width=700 border=1>\n"; echo "<th>Clear</th><th>Time</th><th>Player 1</th><th>Player 2</th><th>Player 3</th><th>Player 4</th><th>Player 5</th> <th>M</th><th>W</th><th>G</th>"; $i=0; while($row = mysql_fetch_array( $result )) { $dateID = $row['Date']; $timeID = $row['Time']; echo "<tr>"; echo "<td>"; echo "<input type='radio' name='time1[$i]' value='$timeID'>"; //HERE'S THE RADIO BUTTON echo "</td><td>"; echo date("g:i ", strtotime($row[Time])); echo "</td><td>"; echo "<input type='text' size='17' value= '$row[Player1]' name='player1[$i]' style ='background-color:#{$row['color']};'>"; echo "</td><td>"; echo "<input type='text' size='17' value= '$row[Player2]' name='player2[$i]' style ='background-color:#{$row['color']};'>"; echo "</td><td>"; echo "<input type='text' size='17' value= '$row[Player3]' name='player3[$i]' style ='background-color:#{$row['color']};'>"; echo "</td><td>"; echo "<input type='text' size='17' value= '$row[Player4]' name='player4[$i]' style ='background-color:#{$row['color']};'>"; echo "</td><td>"; echo "<input type='text' size='17' value= '$row[Player5]' name='player5[$i]' style ='background-color:#{$row['color']};'>"; echo "</td><td>"; echo "<input type='text' size='2' value= '$row[Men]' name='women' style ='background-color:#{$row['color']};'>"; echo "</td><td>"; echo "<input type='text' size='2' value= '$row[Women]' name='women' style ='background-color:#{$row['color']};'>"; echo "</td><td>"; echo "<input type='text' size='2' value= '$row[Guest]' name='guests' style ='background-color:#{$row['color']};'>"; echo "<input type='hidden' name='date[$i]' value='$dateID'>"; echo "<input type='hidden' name='time2[$i]' value='$timeID'>"; echo "</td></tr>"; $i++; } echo "</table>"; mysql_close($con); ?> <br /><br /> <input type="Submit" name="Submit" value="Update Tee Times"> </FORM> And here's the form action: Code: [Select] <?php header("Location: /teetimes/preteetimesadmin.php"); include("opendatabase.php"); $size = count($_POST['player1']); $timeID1 = $_POST['time1'][$i]; //HERE'S WHERE I'M TRYING TO DELETE THE DATA. mysql_query(" UPDATE Daysheets SET Player1='', Player2='', Player3='', Player4='', Player5='' WHERE Time ='$timeID1' "); //HERE'S THE UPDATE, WHICH WORKS FINE. $i=0; while ($i < $size) { $dateID = $_POST['date'][$i]; $timeID2 = $_POST['time2'][$i]; $player1 = ($_POST['player1'][$i]); $player2 = ($_POST['player2'][$i]); $player3 = ($_POST['player3'][$i]); $player4 = ($_POST['player4'][$i]); $player5 = ($_POST['player5'][$i]); mysql_query(" UPDATE Daysheets SET Player1='$player1', Player2='$player2', Player3='$player3', Player4='$player4', Player5='$player5' WHERE Date ='$dateID' AND Time ='$timeID2' "); $i++; } mysql_close($con) ?>When I add or update any information it works fine. It just won't delete anything where the radio button is clicked. Any help appreciated! Thanks. Hi there. I have this course registering website whereby i will need to : 1. pull out all course info and display (done that) 2. when user choose the course they are interested in using radio button and click submit , it will display you're registered and update the database to decrease the head count by 1. i m stuck on the radio button part... after i click submit nothing happens... Please advice... thanks a lot Code: [Select] <html> <head> <title>TimeTable</title> </head> <body> <h1> Here is the timetable</h1> <?php @ $db = new mysqli('localhost', 'root', '', 'mylifestyle'); if (mysqli_connect_errno()) { echo 'Error: Could not connect to database. Please try again later.'; exit; } $query = "SELECT course.CourseName , course.Instructor , course.ClassSize , courseschedule.Date ,courseschedule.Time , courseschedule.Location FROM course INNER JOIN courseschedule ON course.CourseID = courseschedule.CourseID"; $result = $db->query($query); $num_results = $result->num_rows; echo "<table border='1'> <tr> <th>Course Name</th> <th>Instructor</th> <th>Class size</th> <th>Date</th> <th>Time</th> <th>Location</th> <th>Register</th> </tr>"; ?> <?php for ($i=0; $i <$num_results; $i++) { $row = $result->fetch_assoc();?> <tr> <form action = "" method = "post"> <td><? echo $row['CourseName']; ?></td> <td><? echo $row['Instructor']; ?></td> <td><? echo $row['ClassSize']; ?></td> <td><? echo $row['Date']; ?></td> <td><? echo $row['Time']; ?></td> <td><? echo $row['Location']; ?></td> <td align="center"><input name="radio" type="radio" id="radio[]" value="<? echo $row['ClassSize']; ?>"></td> </tr> <?php } ?> <td colspan="5" align="center" bgcolor="#FFFFFF"><input name="submit" type="submit" id="submit" value="submit"></td> <?php if($submit){ for($i=0;$i<$num_results;$i++){ $del_id = $radio[$i]; $query = "UPDATE course SET ClassSize = ClassSize -1 Where id='$del_id'"; $result = mysql_query($query); } // if successful redirect to delete_multiple.php if($result){ echo "$CourseName was deleted from database - myliftstyle!!<br />"; // Compute the item costs and total cost } } ?> </div> </body> </html> [attachment deleted by admin] Hello, I am new to php, and what I need to know and learn is a part of an assignment I normally wouldn't ask for help on the net for an assignment but my teacher is not very helpful and other students are struggling too! I have searched the net inside and out and have tried many things. My problem is that I am trying to remove a line from an array by clicking a delete button. The outpur I need is: a line of text that comes from my text file after it is exploded into an array | With a delete button here next line of text that comes from my text file after it is exploded into an array | With a delete button here etc I have managed to write this much myself - Code: [Select] <?php $file = fopen('fav/fav.txt', 'r'); $file = file_get_contents('fav/fav.txt'); $file_array = explode("\n",$file); array_pop($file_array); foreach($file_array as $line) { echo "<form method='post' action=''>".$line. "<input type='submit' name='post' value='delete'><br>"; $fh = fopen("fav/fav.txt",'w'); foreach ($file_array as $line) { fwrite($fh,$line."\n"); } fclose($fh); } ?> The array_pop deletes from the bottom instead of the line the button is next too, I realise I will need to use and if statement but this is the closest I have gotten. Thanks in advance!!! Which languages do I need to make this happen? And I am unsure of how to incorporate PHP within a javascript query and what jQuery functions I will need. Hi, I have a table row that has a dropdown and two textboxes in it. I would like to use a button that allows me to add another row beneath the existing row. It cannot be added to the bottom of the table as there is further content beneath. The content of the dropdown comes from a database query. The dropdown on the new row should have the selection in the first row greyed out. I expect this will need to be a js function but i dont really know where to start with it being dynamic content. This is the table as it stands if this provides clarity of my intentions - picture below echo "<form method='post' id='staffOrderForm'>"; $stmt->close(); echo "<table id='staffOrderTable' class='table table-striped table-bordered mt-3 text-center'>"; foreach($daterange as $date){ echo" <tr> <th class='table-dark' colspan='3'>".$date->format("l - jS F Y")."</th> </tr> <tr> <th class='' colspan='3'>Management </th> </tr> <tr> <th class='col-4'>Name</th> <th class='col-4'>Start Time</th> <th class='col-4'>End Time</th> </tr> <tr> <td> <select class='custom-select managerSelect'>"; $managerRoleId = 1; $stmt = $conn->prepare(" SELECT user_firstname, user_lastname, user_id FROM ssm_user WHERE user_role_id = ? "); $stmt->bind_param("i", $managerRoleId); $stmt->execute(); $stmt->store_result(); $stmt->bind_result($ufn, $uln, $uid); while($stmt->fetch()){echo "<option>".$ufn." ".$uln."</option>";}; echo"</select> </td> <td><input class='form-control' type='' name=''></td> <td><input class='form-control' type='' name=''></td> </tr> <tr> <th colspan='3'>Chefs</th> <tr/> <tr> <th class='col-4'>Name</th> <th class='col-4'>Start Time</th> <th class='col-4'>End Time</th> </tr> <tr> <td> <select class='custom-select chefSelect'>"; $chefRoleId = 2; $stmt = $conn->prepare(" SELECT user_firstname, user_lastname, user_id FROM ssm_user WHERE user_role_id = ? "); $stmt->bind_param("i", $chefRoleId); $stmt->execute(); $stmt->store_result(); $stmt->bind_result($ufn, $uln, $uid); while($stmt->fetch()){echo "<option>".$ufn." ".$uln."</option>";}; echo"</select> </td> <td><input class='form-control' type='' name=''></td> <td><input class='form-control' type='' name=''></td> </tr>"; } echo "</table></form>"; I appreciate that i will likely have to add a button with an onclick but from there i am pretty lost. As always i appreciate the help provided. Can anyone post a generic update function to update mysql table. The manual approach: update $tablename set $column1='a', $column2='b' where $id=$value; Hi i have this simple update form and scrip but somehow it doesnt seem to be update the field on the database can someone help out please. The html form is the second form bellow where the action send to status_update.php HTML FORM Code: [Select] <?php include("../header.html"); ?> <?php include("header_news.html"); extract($_REQUEST,EXTR_SKIP); ?><?php /* print("sfilm_refnum = $sfilm_refnum<BR>"); print("sfilm_addr01 = $sfilm_addr01<BR>"); print("sfilm_postcode = $sfilm_postcode<BR>"); print("Film Client = $fclient<BR>"); */ ?> <form id="search" action="list.php" method="post" name="search"> <table width="780" border="0" cellspacing="0" cellpadding="4" bgcolor="#eeeeee"> <tr> <td align="right" width="140"></td> <td width="320"><span class="hofblack10"> </span> </td> <td align="center" width="100"><input type="hidden" name="lstart" value="<?php print("$lstart"); ?>" /><input type="hidden" name="lend" value="<?php print("$lend"); ?>" /><input type="hidden" name="lamount" value="<?php print("$lamount"); ?>" /></td> <td align="center" width="100"></td> <td align="right"></td> </tr> </table> </form> <table width="780" border="0" cellspacing="0" cellpadding="4" bgcolor="#4050c4"> <tr> <td width="60" class="hofwhite10">action</td> <td width="140"><span class="hofwhite14">DATE</span></td> <td width="80"><span class="hofwhite14">ID</span></td> <td><span class="hofwhite14">News Titile</span></td> <td width="100"><span class="hofwhite14">Status</span></td> </tr> <tr height="0"> <td bgcolor="white" width="60"></td> <td bgcolor="white" width="140" height="0"></td> <td bgcolor="white" width="80" height="0"></td> <td bgcolor="white" height="0"></td> <td bgcolor="white" width="100" height="0"></td> </tr> </table><table width="780" border="0" cellspacing="0" cellpadding="4"><tr> <td width="60"></td> <td width="80"></td> <td><a class="blueullrg" href="add.php">Add News</a></td> <td align="right" width="120"></td> </tr> <tr height="0"> <td width="60" height="0"></td> <td width="80" height="0"></td> <td height="0"></td> <td align="right" width="120" height="0"></td> </tr> </table> <?php //get the DB connection variables include("../../../includes/config.php"); //connect to DB $connection = @mysql_connect($db_address,$db_username,$db_password) or die("Couldn't CONNECT."); $db = @mysql_select_db($db_name, $connection) or die("Couldn't select DATABASE."); $query2="SELECT * FROM news WHERE !(news_status='deleted')"; $result2 = mysql_query($query2) or die("Couldn't execute QUERY - Select NEWS Qty"); $fqty = mysql_num_rows($result2); //SELECT or FIND the same USERNAME $query3="SELECT * FROM news WHERE !(news_status='deleted') ORDER BY news_id DESC"; $result3 = mysql_query($query3) or die("Couldn't execute QUERY - Select NEWS"); while ($row = mysql_fetch_array($result3)) { $news_id = $row['news_id']; $news_title = $row['news_title']; $news_story = $row['news_story']; $news_image = $row['news_image']; $news_image_caption = $row['news_image_caption']; $news_image_link = $row['news_image_link']; $news_date_day = $row['news_date_day']; $news_date_month = $row['news_date_month']; $news_date_year = $row['news_date_year']; $news_status = $row['news_status']; $news_website = $row['news_website']; $news_date_created = $row['news_date_created']; $news_date_modified = $row['news_date_modified']; ?> <table width="780" border="0" cellspacing="0" cellpadding="4" bgcolor="#eeeeee"> <tr> <td width="60"><span class="hofblack10"> <?php if($news_status=="deleted"){ print("<a class='hifblack10'>deleted</span>"); }ELSE{ print("<a class='blueul' href='edit.php?id=$news_id'>edit</a>"); } ?> </span></td> <td width="140"><span class="titlegrey12"> <?php if(!$news_date_day) { echo "00"; } else{ echo $news_date_day; } echo "/"; if(!$news_date_month) { echo "00"; }else{ echo $news_date_month; } echo "/"; if(!$news_date_year) { echo "0000"; }else{ echo $news_date_year; } ?> </span></td> <td width="80"><span class="titlegrey12"><?php print("$news_id"); ?></span> </td> <td><?php if($news_status=="deleted") { print("<class='hofblack10'>$news_title</span>"); }ELSE{ print("<a class='blueul' href='edit.php?id=$news_id'>$news_title</a>"); } ?></td> <td width="100"> <form id="list_update" action="status_update.php" method="post" name="list_update"> <select name="newnstatus" size="1"> <option <?php if($row['news_status'] == "") { print("selected"); } ?> selected="selected" value="">Status...</option> <option <?php if($row['news_status'] == "on") { print("selected"); } ?> value="on">On</option> <option <?php if($row['news_status'] == "off") { print("selected"); } ?> value="off">Off</option> <option <?php if($row['news_status'] == "deleted") { print("selected"); } ?> value="deleted">Delete</option> </select> <input type="hidden" name="nstatus" value="<?php echo $row[news_status]; ?>" /> <input type="hidden" name="id" value="<?php echo $row[news_id]; ?>" /> <input type="submit" name="update" value="update" /> </form> </td> </tr> <tr height="0"> <td bgcolor="white" width="60"></td> <td bgcolor="white" width="140" height="0"></td> <td bgcolor="white" width="80" height="0"></td> <td bgcolor="white" height="0"></td> <td bgcolor="white" width="100" height="0"></td> </tr> </table> <?php } mysql_close($connection);//}?> <table width="780" border="0" cellspacing="0" cellpadding="4"> <tr> <td width="60"></td> <td width="80"></td> <td><a class="blueullrg" href="add.php">Add News</a></td> <td align="right" width="120"></td> </tr> </table><?php // include("list_navigation.html"); ?> <?php include("../footer.html"); ?> </div></body></html> The action script php Code: [Select] <?php /* echo "fstatus: ".$fstatus."<BR>"; echo "id: ".$id."<BR>"; echo "fclient: ".$fclient."<BR>"; echo "newfstatus: ".$newfstatus."<BR>";*/ //set the date of agreement $timestamp = date('l jS \of F Y h:i:s A'); //get the DB connection variables include("../../../includes/config.php"); //connect to DB $connection = @mysql_connect($db_address,$db_username,$db_password) or die("Couldn't CONNECT."); $db = @mysql_select_db($db_name, $connection) or die("Couldn't select FILMS DATABASE."); // All appears well, so enter into database $query= "UPDATE news SET news_status = '$newnstatus' WHERE news_id='$id'"; $result = mysql_query($query) or die("could not execute query - Update FILMS Record to DB"); //setup an email to the Admin @ hof, w/o attachment $emailto="xx@xxx.co.uk"; $emailfrom="no-reply@xxxx.co.uk"; $emailsubject="xx Record Updated"; $emailmessage="Hello Registrar\n\n"; $emailmessage.="News ID: ".$id."\n"; $emailmessage.="Updated on: ".$timestamp."\n\n"; $emailmessage.="Status was: ".$nstatus."\n"; $emailmessage.="Status now: ".$newfnstatus."\n"; $emailmessage.="Thank you,\n\n"; $emailmessage.="Web Site ROBOT\n"; $emailmessage.="(Administrator)\n"; $emailmessage.="xxx.co.uk | xxx.biz\n"; $emailmessage.="----------------------------------------------\n"; $emailmessage.="e. http://www.xxx.co.uk/contact.php\n"; $emailmessage.="w. http://www.xxx.co.uk\n"; $emailheader="From: xxx.co.uk<$emailfrom>"; $emailheader .= 'Cc: xxx@xxx.co.uk'."\r\n"; $emailheader .= 'Bcc: xxx@xxxxx.co.uk'."\r\n"; $ok=mail($emailto,$emailsubject,$emailmessage,$emailheader); mysql_close($connection); if ($ok) { header("Location: list.php"); /* Redirect browser */ exit; } else { $errmsg="There was a problem, please try later or telephone us direct."; $errsta="1"; include("edit_error.html"); //echo "<p>Mail could not be sent. Sorry!</p>"; exit; } ?> Thanks in advance what im trying to do is take a youtube embed code find the URL code for that video and remove all other parts of the code keeping only the URL of the video after i get the URL by it self then replace the http://www.youtube.com/ part of the URL with http://i2.ytimg.com/vi/ to do this i know that i need something like this to get the URL of the video http://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+) but how to only return just the URL is something idk how to do then use str_replace http://www.youtube.com/(?:v|cp)/" with http://i2.ytimg.com/vi/ so in the end im asking if anyone know how to remove all other codes i dont want and only keep the URL this may have to be done using "regex" im not sure as i dont know to much about regex and what it can do but does sound like it would help lol what Im basically trying to do is just like a phpmyadmin function... you select rows you want to update with a checkbox and then it takes you to a page where the rows that are clicked are shown in forms so that you can view and edit info in them... and then have 1 submit button to update them all at once. Dear All Good Day, i am new to PHP (a beautiful server side scripting language). i want to send a mail with line by line message i tried with different types like by placing the things in table and using <br /> but the thing is the tags are also visible in the message of the mail. Here is my code: $message1 = "Name :". $_REQUEST['name']."<br />"; $message1 .= "Surname :". $_REQUEST['surname']."<br />"; $message1 .= "Cellphone :". $_REQUEST['mobileno']."<br />"; $message1 .= "Telephone :". $_REQUEST['landno']."<br />"; $message1 .= "Fax :". $_REQUEST['fax']."<br />"; $message1 .= "Company :". $_REQUEST['company']."<br />"; $message1 .= "Email :". $_REQUEST['email']."<br />"; $message1 .= "Country :". $_REQUEST['country']."<br />"; $message1 .= "Enquity :". $_REQUEST['enquiry']."<br />"; $message1 .= "Date&Time :". $date."<br />"; For this code if try to print/echo it it is working fine it is displaying line by line, but using this variable ($message1) in the mail these <br /> are also visible. Can any one guide me to resolve(to remove these tags from the message part) this issue. Thanks in Advance. :confused: Hi. I want a simple textbox, that when submited, will replace very every new line, with the <br> tag. What will happen, when it submits, it will take the contents of a textbox, add the <br> tag where a new line is suposed to be, and save the string to a MySQL Database. I think this is the easiest way of allowing a user to edit what appears on a website when logged in, but if there is a easier way, then please tell me. What I am trying to do, is a login page, and once logged in, you enter new text into the textbox, click submit, and on the website homepage, the main text will change to what was submitted. But if there is a new line, I think the only way in HTML to make one is to put a <br> tag, so I want the PHP to but that tag wherever there is a new line. Sorry if I am confusing, I am not that advanced at PHP, but I would be very happy if you could supply me with the correct code. Time is running out... If you do not understand me, please tell me -- PHPLeader (not) |