PHP - Jquery Autocomplete Multiple Times With Multiple Input Fields
First, Happy X-Mas to all!
I want to do a form for entering dog-show results. On first site of form the user is able to enter how many dogs for each class (there are youth and open class for example) he want to insert. So on second site there will be formfields for every dog in every class, created with php. User should be able to take dogname from jquery autocomplete - this works for multiple fields. But i need the according id to the dogname - and actual only one id is given - the first one is changing by choosing from autocomplete in next fields... Data came from a json array like 0: {dogidindatabase: "9892", value: "Excalibur Khali des Gardiens de la Cour ",…} dogidindatabase: "9892" label: "<img src='../main/img/female.png' height='20'>Excalibur Khali des Gardiens de la Cour " value: "Excalibur Khali des Gardiens de la Cour " 1: {dogidindatabase: "15942", value: "Excalibur from Bandit's World Kalli",…} dogidindatabase: "15942" label: "<img src='../main/img/male.png' height='20'>Excalibur from Bandit's World Kalli" value: "Excalibur from Bandit's World Kalli"all i need is inside ... the script in form is <script type='text/javascript'> //<![CDATA[ $(function() { $(".dog").autocomplete({ source: "xxx.php", minLength: 3, select: function(event, ui) { $('#dogidindatabase').val(ui.item.dogidindatabase); } }); $["ui"]["autocomplete"].prototype["_renderItem"] = function( ul, item) { return $( "<li></li>" ) .data( "item.autocomplete", item ) .append( $( "<a></a>" ).html( item.label ) ) .appendTo( ul ); }; }); //]]> </script>and the form looked like <input type='text' name='dog' class='dog' value='".strip_tags(${'dogname' .($countbabymale+1)})."' size='35' data-required='true' /><br> <input class='readonly' readonly='readonly' type='text' id='dogidindatabase' name='dogidindatabase' size='5' />I changed in script and form id='dogidindatabase' to class, but it doesn´t work. Testsite is under http://www.wolfdog-d...how.php?lang=de (only german at first) - Insert a number (higher than 1) under baby 3-6 (first box, the others are not working for testing); submit to get to page 2; you see all post-variables (for testing). Try to insert a dogname in first input-field (choose "exc") and insert first one - the id is under dogname. In second dogname inputfield you can choose second dog - the id for the first one changes to id of seond one .... How can i get both for every dog? Similar TutorialsI need to know how to echo multiple things on the same page. If you do understand the last line then don't read this next part. So say if had just a textbox and a submit button. I already know how to make it where they type something and they hit submit and echo's to the page. But after it echos I want to know how to make it where if they entered in another body of text it would enter on the same page right under the last echo, or the last thing they typed. So if you could help me with this or just post a code for me that would be nice. Hi guys, i got the following code i wrote which displays a small pop up on screen if the user has mail, and display a little icon. The problem is it displays a new icon for each new mail message. How can i make it so it only display 1 icon no matter how many unread mail the user has. Or even better if not too complicated display a number next too the image? Code: [Select] <? require'xxxxxxxxxxxxxxxxx.php'; mysql_select_db("membership") or die( "Unable to select database"); $sql=("SELECT * FROM user_alerts WHERE user_id = '".($_SESSION['user_id'])."'") or die (mysql_error()); if ($query=@mysql_query($sql)) { if (mysql_num_rows($query) > 0) { while ($req=mysql_fetch_array($query)) { if ($req['messageRead'] == 'NO') { ?> <div> <img src="xxxxxxxxxxxxxx.png" width="32" height="32" alt="unread mail" /> <a href="http://www.xxxxxxxxxxxx/account=account">You have Mail!</a> <div id="boxes"> <div style="top: 199.5px; left: 551.5px; display: none;" id="dialog" class="window"> <h2>You have new mail!</h2> <br /> <p>Visit your account page to read it.</p> <br> <a href="#" class="close">Close Window</a> </div> <!-- Mask to cover the whole screen --> <div style="width: 1478px; height: 602px; display: none; opacity: 0.8;" id="mask"></div> </div> </div> <? } } } } You can ignore most of the div stuff but that's pretty much it. It should check my database for any entries with the users session id in the column called 'user_id'. and only show the image if it then finds an entry with 'NO' in the 'messageRead' column. It currently shows the images for each entry it finds. Thanks for any help Okay I'm a newbie at PHP but was trying to write a counter for my website to count the amount of times a specific button is clicked. My desired outcome is as follows: If the form submit button "like" or "dislike" is clicked, get user's ip and check to see if it already exists in the database. If it exists, don't increment the count (of either button), otherwise log the ip and increment the count (of whichever button is clicked) by 1. Currently I've got the increment working (testing only the like button at the moment) and I've got the ip being stored into the database, but cannot get the comparison to work. Each time the button is clicked it adds the ip address into the database instead of disallowing it. Note: there are two different tables--one storing the ip (counter) and one storing the like clicks (Designs) (dunno if there's a better way?) Excuse my newbieness. The problem area: (like button only): if(isset($_POST['like'])) { $ip_address = $_SERVER['REMOTE_ADDR']; $query = mysql_query("SELECT ip FROM counter WHERE ip = '$ip_address'"); $num_rows = mysql_num_rows($query); if ($num_rows > 0) { die ("You've already clicked the button!"); } else { mysql_query("INSERT INTO counter VALUES ($ip_address)"); mysql_query("UPDATE Designs SET up = up + 1 WHERE ref = 'cataclysm'"); } } $select = mysql_query("SELECT up FROM Designs"); while($row = mysql_fetch_array($select)) { echo $row['up']; } Greetings.. I have an ajax application i'm creating, that allows uploading images 1 at a time. That part works, and it works well. What I need to know now, is how would I go about converting the existing code I have, to change the sizing of it twice as well as renaming the images to something more website friendly. here is the code that i currently have, im sure this is easy but as i can't find any workable code on the google, i am lost as to how to modify it. so any help is appreciated. Code: [Select] <script language="JavaScript" type="text/javascript"> if(!/(\.bmp|\.gif|\.jpg|\.jpeg)$/i.test(window.parent.document.form1.filefieldname.value)) { window.parent.document.form1.filefieldname.value = ""; } else { <?php function rrmdir($dir) { if (is_dir($dir)) { $objects = scandir($dir); foreach ($objects as $object) { if ($object != "." && $object != "..") { if (filetype($dir."/".$object) == "dir") rrmdir($dir."/".$object); else unlink($dir."/".$object); } } reset($objects); rmdir($dir); } } $folder = isset($_POST['folder']) ? $_POST['folder'] : ''; if($folder == '') { $rand = rand(5, 1000000); $folder = 'temp'.$rand; ?> window.parent.document.form1.folder.value = "<?php echo $folder; ?>"; <?php } if(!is_dir("../uploads/".$folder)) { mkdir('../uploads/'.$folder); } else { $rand = rand(5, 100000); $folder = $folder.''.$rand; mkdir('../uploads/'.$folder); } $image_name = $_FILES["filefieldname"]["name"]; $newname = "../uploads/".$folder."/".$image_name; move_uploaded_file($_FILES["filefieldname"]["tmp_name"], $newname); ?> var parDoc = window.parent.document; var A = window.parent.document.form1.upload_cnt.value; A = Number(A); B = 1; var cnt = A + B; if(cnt == '8') { window.parent.document.form1.filefieldname.disabled=true; } parDoc.getElementById('upload_cnt').value = cnt; parDoc.getElementById('files_list').innerHTML += '<br><a href="../uploads/<?php echo $folder.'/'.$_FILES['filefieldname']['name'] ?>"><?php echo $_FILES['filefieldname']['name'] ?></a>'; window.parent.document.form1.filefieldname.value=""; } </script> Hi, I am having some trouble re-using a method of a class which I use to setup my pages. I have an include which instantiates the class and then I make a call at the top of each page depending on the content required. I have several javascripts I want to include for a specific page and would like to just keep calling the same method to load them. If I try to call the method twice on the last one is echoed. I don't really want have to write out different methods for each file I may need. Any help much appreciated. The included class has this: Code: [Select] class Page { public function display_top() { # page specific atrributes $this->display_js(); } public function display_js() { echo "<script type='text/javascript' src='{$this->js}'></script>\n"; } } my page has this: Code: [Select] require ('classes/page_class.php'); $page = new Page; $page->js = "js/jquery-1.3.2.min.js"; $page->js = "js/revealClass.js"; Ok, I need some serious help here. I have a jQuery .load method that retrieves a single users name from a database. However... I also need to incorporate error checking into the script that the .load method access, so that, if the user enters a name in the field that is not in the database, it will insert it into the database, and then then pull it back out again to be returned by the ajax call. This is the jQuery that performs the call: Code: [Select] $('#submit').click(function(e) { var user = $('#user').val(); var checkurl = "indexData.php"; $('#username').load(checkurl, 'user=' + user); e.preventDefault(); }); This is the script form indexData.php: Code: [Select] <?php $db = mysql_pconnect('localhost', 'joeme0', 'Galatians2'); if (!$db) { die('Could not connect: ' . mysql_error()); } mysql_select_db('joeme0_brave'); $name = $_POST['name']; $checkQuery = "select name from users where name='$name'"; $checkResult = mysql_query($checkQuery); if ($checkResult > 1) { $insQuery = "insert into users (id, name) values ("", '$name')"; $insResult = mysql_query($insQuery); if ($insResul 0) { $query="select name from users where name='$name'"; $result=mysql_query($query); while($row=mysql_fetch_array($result)) { echo $row['name']; } } else { echo "Cold not insert your name into the database"; } } else { $query="select name from users where name='$name'"; $result=mysql_query($query); while($row=mysql_fetch_array($result)) { echo $row['name']; } } ?> So far I can get it to pull out a name that is manually entered into the database no problem. But I can't get it to insert a name that isn't in the database, and then query the database a second time to pull that same name back out again. The page is pretty simple. The user comes to the page, enters their name in the text field, either clicks the submit button or presses the enter key. The scripts fire off the ajax call to the database, check to see if the name exists, if not enter it and pull it back out (this is where I have the problem), if so, pull it out and display it back on the page. I have this script Code: [Select] <?php header("content-type: image/png"); include '../../api/config.php'; include "../../api/api.php"; $gamercard = getInfo($_GET['gamertag']); updateStats($gamercard['Gamertag'], "Nxe", 75); $type = $_GET['type']; switch ($type) { case "dark": $type = "dark.png"; break; case "light": $type = "light.png"; break; default: $type = "dark.png"; break; } $image = imagecreatefrompng("$type"); $img = imagecreatetruecolor(imagesx($image), imagesy($image)); $avatar_l = imagecreatefrompng($gamercard["Avatarpic-l"]); $avatar_body = imagecreatefrompng($gamercard["Avatarpic-body"]); imagecopy($img, $image, 0, 0, 0, 0, imagesx($image), imagesy($image)); imagecopy($img, $avatar_l, 64, 7, 0, 0, imagesx($avatar_l), imagesy($avatar_l)); imagecopy($img, $avatar_body, 175, -40, 0, 0, imagesx($avatar_body), imagesy($avatar_body)); for($i = 1; $i <=count($gamercard["RecentGames"]); $i++) { $gameimg = imagecreatefromjpeg($gamercard["RecentGames"][$i]["Icon"]); $x = ($i-1)*35 + 10; imagecopy($img, $gameimg, $x, 77, 0, 0, imagesx($gameimg), imagesy($gameimg)); } $ColorText = imagecolorallocate($img, 255, 255, 255); ImageTTFText($img, 10, 0, 10, 127, $ColorText, "font.ttf", $gamercard['Gamertag']); ImageTTFText($img, 10, 0, 135, 127, $ColorText, "font.ttf", $gamercard['Gamerscore']); imagepng($img); imagedestroy($img); ?> which is made to call the updateStats() function 1 time everytime the page loads. Heres the function (its in api.php) Code: [Select] function updateStats($gamertag, $type, $size) { $query = mysql_query("SELECT * FROM loadstats where Gamertag = '$gamertag' && Type = '$type'") or die(mysql_error()); $exists = mysql_num_rows($query); if ($exists == 0) { mysql_query("INSERT INTO loadstats (Gamertag, Type, Loads, Data) VALUES('$gamertag', '$type', '1', '$size' )") or die(mysql_error()); } else { $row = mysql_fetch_array($query); $newloads = $row['Loads'] + 1; $newdata = $row['Data'] + $size; mysql_query("UPDATE loadstats SET Loads = '$newloads' WHERE gamertag = '$gamertag' && Type = '$type'") or die(mysql_error()); mysql_query("UPDATE loadstats SET Data = '$newdata' WHERE gamertag = '$gamertag' && Type = '$type'") or die(mysql_error()); } } The wierd thing that is happening is, When i have the Header() set in the script, the updateStats() function appears to be called twice, but when the header is commented out, it is only called once. I can tell this by the change of data in the MYSQL database, the Loads value increases by 2 when the header is set, and it only creases by 1 when it isnt set. Any insight as to why this is happening would be greatly appreciated. I have a scenario in PHP, i need a smart way: 1. I run one process on background forever, scheduler.php - done 2. User on the web submit their task in DB to be processed by the above process(scheduler.php) - done 3. scheduler.php read the db after every 1 sec, looking for user's task. Problem: Ideally, if it founds like 10 or more tasks it should process them concurently(in parallel)..i.e it should not wait one task to be fully executed so as to run the next one as one task might take a very long time to be fullu executed. I would do like exec("nohup php <path>/file_name.php >> /dev/null 2>&1 &"), but if i have alot of tasks this will create zombie processes. Any smart way to do this will be highly appreciated! I have a controller(generatebill.php) where I have collected all the value from the form(normaluserview.php). I can see my value is stored. But whenever I wanted to display those values in table format in another view(invoice.php in this case), it keeps repeating. For better understanding, I have uploaded the files as well.. Please help
Attached Files
generatebill.php 592bytes
2 downloads
invoice.php 31bytes
3 downloads
normaluserview.php 3.4KB
1 downloads Hey there - how are you? I'm trying to add up multiple fields from a table and it's mostly working but I have one curious error. It always seems to miss the field upgrade6_fee. I'm totally baffled. I thought it was my syntax but I'm not seeing anything wrong with it. Any ideas? Otherwise it all seems to be working. <?php $query = "SELECT fee1, upgrade3_fee, upgrade4_fee, upgrade5_fee, upgrade6_fee, upgrade7_fee, SUM(fee1 + upgrade3_fee + upgrade4_fee + upgrade5_fee + upgrade6_fee + upgrade7_fee) AS ttotal FROM Register"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo number_format(($row['ttotal']), 2); } ?> According to http://www.phpfreaks.com/forums/index.php?topic=350872.0: Is this a correct usage of what I am trying to create? Code: [Select] <?php $connect = mysql_connect("mysql12.000webhost.com","***","***") or die(mysql_error()); mysql_select_db("***") or die(mysql_error()); $id = mysql_real_escape_string($_GET['id']); $extract = mysql_query("SELECT * FROM webclientcreate WHERE id='$id' LIMIT 1 WHERE ip='$ip' WHERE port='$port' WHERE name='$name' WHERE background='$background'"); ?> Code: [Select] <applet name=client width=765 height=503 archive='<?php echo $jars; ?>' code='client.class'> <PARAM name='java_arguments' value='-Xmx700m'> <PARAM name='server_name' value='<?php echo $name; ?>'> <PARAM name='detail' value='low'> <PARAM name='ip' value='<?php echo $ip; ?>'> <PARAM name='port' value='<?php echo $port; ?>'> <PARAM name='background_image' value='<?php echo $background; ?>'> <PARAM name='headicons' value=''> I've tried several types of the query line such as : Code: [Select] webclientcreate WHERE id='$id' LIMIT 1, WHERE ip='$ip', WHERE port='$port' Code: [Select] webclientcreate WHERE id='$id' LIMIT 1, ip='$ip', port='$port' Code: [Select] webclientcreate WHERE id='$id' LIMIT 1 ip='$ip' port='$port'Without any success I appreciate any help I can get! I have html form that looks like: <form method="post" action="?a=up"> ...some mysql query... while ($i = mysql_fetch_array($result)) { <input name="name[]" type="text" value="<?=$i['name'];?>" /> <input name="years[]" type="text" value="<?=abs($age);?>"/> <input name="to[]" type="checkbox" value="<?=$i['id'];?>" /> } <input name="" type="submit" value="go" /> </form> The problem I have is that I can not get the values of the form fields such as "name" and "years". I can only get a list of the ids (value of "to" checkbox). The php code looks like: $cnt = 0; for($p = 0; $p <= (sizeof($to)-1); $p++) { echo $to[$p].$name[$p].$years[$p]"<br>"; $cnt++; } $tm = array($cnt); What I'm doing wrong? Hi i would like to submit the following code to my database as a mutiple selection box. when i submit i just get the last selected value for example if i hold ctrl and press 1 2 3 4 i am only receiving 4 on my database. any ideas? thanks in advance for any help! Code: [Select] Hours Of Availability:<br> <select name="availability" multiple="multiple" size="9"> <option value="Monday - Period 1">Monday - Period 1</option> <option value="Monday - Period 2">Monday - Period 2</option> <option value="Monday - Period 3">Monday - Period 3</option> <option value="Monday - Period 4">Monday - Period 4</option> <option value="Monday - Period 5">Monday - Period 5</option> <option value="Monday - Period 6">Monday - Period 6</option> <option value="Monday - Period 7">Monday - Period 7</option> <option value="Monday - Period 8">Monday - Period 8</option> <option value="Monday - Period 9">Monday - Period 9</option> </select> <select name="availability" multiple="multiple" size="9"> <option value="Tuesday - Period 1">Tuesday - Period 1</option> <option value="Tuesday - Period 2">Tuesday - Period 2</option> <option value="Tuesday - Period 3">Tuesday - Period 3</option> <option value="Tuesday - Period 4">Tuesday - Period 4</option> <option value="Tuesday - Period 5">Tuesday - Period 5</option> <option value="Tuesday - Period 6">Tuesday - Period 6</option> <option value="Tuesday - Period 7">Tuesday - Period 7</option> <option value="Tuesday - Period 8">Tuesday - Period 8</option> <option value="Tuesday - Period 9">Tuesday - Period 9</option> </select> <select name="availability" multiple="multiple" size="9"> <option value="Wednesday - Period 1">Wednesday - Period 1</option> <option value="Wednesday - Period 2">Wednesday - Period 2</option> <option value="Wednesday - Period 3">Wednesday - Period 3</option> <option value="Wednesday - Period 4">Wednesday - Period 4</option> <option value="Wednesday - Period 5">Wednesday - Period 5</option> <option value="Wednesday - Period 6">Wednesday - Period 6</option> <option value="Wednesday - Period 7">Wednesday - Period 7</option> <option value="Wednesday - Period 8">Wednesday - Period 8</option> <option value="Wednesday - Period 9">Wednesday - Period 9</option> </select> <select name="availability" multiple="multiple" size="9"> <option value="Thursday - Period 1">Thursday - Period 1</option> <option value="Thursday - Period 2">Thursday - Period 2</option> <option value="Thursday - Period 3">Thursday - Period 3</option> <option value="Thursday - Period 4">Thursday - Period 4</option> <option value="Thursday - Period 5">Thursday - Period 5</option> <option value="Thursday - Period 6">Thursday - Period 6</option> <option value="Thursday - Period 7">Thursday - Period 7</option> <option value="Thursday - Period 8">Thursday - Period 8</option> <option value="Thursday - Period 9">Thursday - Period 9</option> </select> <select name="availability" multiple="multiple" size="9"> <option value="Friday - Period 1">Friday - Period 1</option> <option value="Friday - Period 2">Friday - Period 2</option> <option value="Friday - Period 3">Friday - Period 3</option> <option value="Friday - Period 4">Friday - Period 4</option> <option value="Friday - Period 5">Friday - Period 5</option> <option value="Friday - Period 6">Friday - Period 6</option> <option value="Friday - Period 7">Friday - Period 7</option> <option value="Friday - Period 8">Friday - Period 8</option> <option value="Friday - Period 9">Friday - Period 9</option> </select> <select name="availability" multiple="multiple" size="9"> <option value="Saturday - Period 1">Saturday - Period 1</option> <option value="Saturday - Period 2">Saturday - Period 2</option> <option value="Saturday - Period 3">Saturday - Period 3</option> <option value="Saturday - Period 4">Saturday - Period 4</option> <option value="Saturday - Period 5">Saturday - Period 5</option> <option value="Saturday - Period 6">Saturday - Period 6</option> <option value="Saturday - Period 7">Saturday - Period 7</option> <option value="Saturday - Period 8">Saturday - Period 8</option> <option value="Saturday - Period 9">Saturday - Period 9</option> </select> <br>Press + Hold Ctrl For Multiple</p> I have a Form that has 10 questions. When the User completes the Form, each Response needs to be a separate record. (My database has a many-to-many relationship with a "member" and "question" table joined by a "answer" table in the middle. And each Form field will go into its own unique record to make the many-to-many work.) At the top of my Form I have... if ($_SERVER['REQUEST_METHOD']=='POST'){ // Form was Submitted (Post). // Initialize Errors Array. $errors = array(); // Trim all form data. $trimmed = array_map('trim', $_POST); // ************************ // Validate Form Data. * // ************************ // Validate Answer1. if (strlen($trimmed['answer01']) >= 2 && strlen($trimmed['answer01']) <= 1024){ // Valid Answer1. $answerArray[0] = $trimmed['answer01']; }else{ // Invalid Answer1. $errors['question01'] = 'Answer must be 2-1024 characters.'; }//End of VALIDATE ANSWER1 // Validate Answer2. // : // : // Validate Answer10. And down farther in my code, I have each Field in my Form set up like this... Code: [Select] <!-- Question 1 --> <label for="question01">1.) Why did you decide to start your own business?</label> <textarea id="question1" name="answer01" cols="60" rows="8"><?php if (isset($answerArray[0])){echo htmlentities($answerArray[0], ENT_QUOTES);} ?></textarea> <?php if (!empty($errors['question01'])){ echo '<span class="error">' . $errors['question01'] . '</span>'; } ?> So if my Form works like I am thinking, all 10 Form Fields would end up here... Code: [Select] $answerArray[0] $answerArray[1] $answerArray[2] $answerArray[3] $answerArray[4] $answerArray[5] $answerArray[6] $answerArray[7] $answerArray[8] $answerArray[9] First of all, does that sound correct? If that part is correct, then how do I take the $answerArray[] and INSERT each value into a different record in my "answer" table?? Hope that makes sense?! Thanks, Debbie This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=320940.0 I have problem that only last text field is updated, how should I fix this? Here's the code <?php if(isset($_POST["update"])){ mysql_query("UPDATE categories SET name_category = '".$_POST['category']."' WHERE ID= ".$_POST['currentCat']." ") or die(mysql_error()); mysql_query("UPDATE podkategorije SET name_subcategory = '".$_POST['subcategory']."' WHERE id_subCat= ".$_POST['currentSubCat']." ") or die(mysql_error()); } ?> <form action="" method="post" > <?php //creating texfields from db $query = "SELECT k.ID, k.name_category, pk.name_subcategory, pk.id_subCat FROM `categories` AS k JOIN `subcategories` AS pk ON pk.id_mainCat = k.ID"; $result = mysql_query($query) or die(mysql_error()); $currentCat = false; while($row = mysql_fetch_array($result)) { //so it doesn't repeat itself if($currentCat != $row['ID']) { //display of main Categories ?> <ul> <li> <br/><input name="categories" type="text" value="<?php echo $row['name_category']; ?>" /> </li> </ul> <? $currentCat = $row['ID']; } //display subcategories ?> <input name="subcategories" type="text" value="<?php echo $row['name_category']; ?>" /><br/> <input type="hidden" name="currentCat" value="<?php echo $row['ID']; ?>" /> <input type="hidden" name="currentSubCat" value="<?php echo $row['id_subCat']; ?>" /> <? } ?> <br /> <input type="button" value="Back" onClick="history.go(-1);return true;"> <input type="submit" value="Update" name="update"/> </form> HTML code: Code: [Select] <form method="post" action="viewpage.php?page_id=5"> Email: <input name="email" type="text"><br> Full Name: <input name="name" type="text"><br> Age: <input name="age" type="text"><br> Summoner Name: <input name="summon" type="text"><br> Do you have vent? <input name="vent" type="text"><br> Do you have a mic? <input name="mic" type="text"><br> How often can you be on? <input name="online" type="text"><br> What level are you? <input name="level" type="text"><br> Who do you like to play as? <input name="champs" type="text"> </form><br> Can you help donate to the clan for vent and the site?<br> <textarea name="name" rows="7" cols="25"></textarea><br> Before you say anything about the PHP not scripted to do all fields, I already know this I'm trying to figure out how to send multiple ones in one message: PHP Code: Code: [Select] <?php if (isset($_POST['submit'])) { $to = "hidden for privacy"; $subject = "LoL Recruitment"; $email = $_REQUEST['email'] ; $message = ($_REQUEST['name'], $_REQUEST['age']) ; $headers = "From: $email"; $sent = mail($to, $subject, $message, $headers) ; if($sent) { print "Your mail was sent successfully"; } else { print "We encountered an error sending your mail"; } } ?> I'm willing to bet my Code: [Select] $message = ($_REQUEST['name'], $_REQUEST['age']) ;if FAR wrong I want to have a search product feature, but I would like members to be able to search multiple fields in one go i.e. product_code, Product_name in one MySQL query. The thing is, members have to be logged on, so the query must also only show results relating to that specific member, via the session[member_ID], my current query for listing products for that specific member is : Code: [Select] $sql = "SELECT productId, productCode, image, name, price, stock_level FROM product_inventory WHERE memberr_ID = '" . $_SESSION['SESS_mem_ID'] . "; How would I change the above into a search query to search for productcode, productname and still only show results beloging to this member using the session data ? all help appreciated Hi Guys, I am attempting to create a program for a local auction house. I arrived at a stand still on a certain issue which is creating a sticky form. On the "enter auction details page" the user will be entering data as the auction is in session. 1. item Description 2. Item Price 3. Bidders Id 4. Qty Of course it would be repetitive to require the user to keep entering the same data for every bidder, so I want to stick the obvious fields which are "item description" & "Item Price" as these don't change until a new item comes up for sale. As of know I am processing the input on a separate page which records all input to the database with a redirect back to the "enter auction details page". I have tried many times to get the item description and item price fields to stick. These would need to change as the user moves onto the next item in which the description and price would change as well. Here is my current code for this part: Code: [Select] <?php session_start(); $field_itemDescription = ""; //iyem description, default as blank if (isset($_SESSION['itemDescription'])) $itemDescription = $_SESSION['itemDescription']; ?> <form action="record_trans.php" method="post"> <font face= "calibri" size= "4"> <table> <tr> <td><b>Item Description:</b></td> <td><input type= "text" name= "itemDescription" size= "30" value="<?php echo $itemDescription;?>"></td> </tr> <tr> <td><b>Item Price:</b></td> <td><input type= "text" name= "itemPrice" size= "5" value="<?php echo $itemPrice;?>"> </td> </tr> </tr> <td><b>Winning Bidders:</b></td> <td><input type="text" name= "bidderId" size= "5" /> </td> </tr> <tr> <td><b>How many deals?:</b></td> <td><input type="text" name= "itemQty" size= "3" value= "1" /></td> </tr> </table> <center><input type="submit" name="submit" value= "Save & Cont." " /></center> </form></font> hi, i'm new to php. i've got a problem. I've 3 tables and table has following content table 1 id name email address phone execution_date executor_name web_address table 2 id name email address phone execution_date executor_name project_title table 3 id name email address phone execution_date executor_name reviewer I want to export these table to and spreadsheet (.xls) with some criteria a form will assign which data will published at the spreadsheet with these criteria #all data can be exported from three tables #some column can be selected from three tables #some or all data can be selected from individual table i've implement a script for this but it didn't meet my requirements. Can anyone help? here is my script <?php $DB_Server = "localhost"; //your MySQL Server $DB_Username = "root"; //your MySQL User Name $DB_Password = "pass"; //your MySQL Password $DB_DBName = "mydb"; //your MySQL Database Name $search_from_date = $_POST['start_date']; $search_to_date = $_POST['end_date']; $Connect = @mysql_connect($DB_Server, $DB_Username, $DB_Password) or die("Couldn't connect to MySQL:<br>" . mysql_error() . "<br>" . mysql_errno()); $Db = @mysql_select_db($DB_DBName, $Connect) or die("Couldn't select database:<br>" . mysql_error(). "<br>" . mysql_errno()); $now_date = date('m-d-Y H:i'); if(($_POST['typer_of_report'] == 'rrc_report') || ($_POST['typer_of_report'] == 'all_report')) { $DB_TBLName = 'rrc_record'; } if(($_POST['typer_of_report'] == 'erc_report') || ($_POST['typer_of_report'] == 'all_report')) { $DB_TBLName2 = 'erc_record'; } if(($_POST['typer_of_report'] == 'aeec_report') || ($_POST['typer_of_report'] == 'all_report')) { $DB_TBLName3 = 'aeec_record'; } $file_type = "vnd.ms-excel"; $file_ending = "xls"; //} header("Content-Type: application/$file_type"); header("Content-Disposition: attachment; filename=protocol_report.$file_ending"); header("Pragma: no-cache"); header("Expires: 0"); if($DB_TBLName) { $sql = "Select * from ".$DB_TBLName." where execution_date >= '".$search_from_date."' and execution_date <= '".$search_to_date."' order by execution_date desc"; $Use_Title = 1; $title = "Report for $DB_TBLName on $now_date"; $result = @mysql_query($sql,$Connect) or die("Couldn't execute query:<br>" . mysql_error(). "<br>" . mysql_errno()); if ($Use_Title == 1) { echo("$title\n"); } $sep = "\t"; //tabbed character for ($i = 0; $i < mysql_num_fields($result); $i++) { echo mysql_field_name($result,$i) . "\t"; } print("\n"); while($row = mysql_fetch_row($result)) { $schema_insert = ""; for($j=0; $j<mysql_num_fields($result);$j++) { if(!isset($row[$j])) $schema_insert .= "NULL".$sep; elseif ($row[$j] != "") $schema_insert .= "$row[$j]".$sep; else $schema_insert .= "".$sep; } $schema_insert = str_replace($sep."$", "", $schema_insert); $schema_insert = preg_replace("/\r\n|\n\r|\n|\r/", " ", $schema_insert); $schema_insert .= "\t"; print(trim($schema_insert)); print "\n"; } //} echo "\n...\n"; } if($DB_TBLName2) { $sql = "Select * from ".$DB_TBLName2." where execution_date >= '".$search_from_date."' and execution_date <= '".$search_to_date."' order by execution_date desc"; $result = @mysql_query($sql,$Connect) or die("Couldn't execute query:<br>" . mysql_error(). "<br>" . mysql_errno()); $Use_Title = 1; $title = "Report for $DB_TBLName2 on $now_date"; if ($Use_Title == 1) { echo("$title\n"); } $sep = "\t"; //tabbed character for ($i = 0; $i < mysql_num_fields($result); $i++) { echo mysql_field_name($result,$i) . "\t"; } print("\n"); while($row = mysql_fetch_row($result)) { $schema_insert = ""; for($j=0; $j<mysql_num_fields($result);$j++) { if(!isset($row[$j])) $schema_insert .= "NULL".$sep; elseif ($row[$j] != "") $schema_insert .= "$row[$j]".$sep; else $schema_insert .= "".$sep; } $schema_insert = str_replace($sep."$", "", $schema_insert); $schema_insert = preg_replace("/\r\n|\n\r|\n|\r/", " ", $schema_insert); $schema_insert .= "\t"; print(trim($schema_insert)); print "\n"; } echo "\n...\n"; } if($DB_TBLName3) { $sql = "Select * from ".$DB_TBLName3." where execution_date >= '".$search_from_date."' and execution_date <= '".$search_to_date."' order by execution_date desc"; $result = @mysql_query($sql,$Connect) or die("Couldn't execute query:<br>" . mysql_error(). "<br>" . mysql_errno()); $Use_Title = 1; $title = "Report for $DB_TBLName3 on $now_date"; if ($Use_Title == 1) { echo("$title\n"); } $sep = "\t"; //tabbed character for ($i = 0; $i < mysql_num_fields($result); $i++) { echo mysql_field_name($result,$i) . "\t"; } print("\n"); while($row = mysql_fetch_row($result)) { $schema_insert = ""; for($j=0; $j<mysql_num_fields($result);$j++) { if(!isset($row[$j])) $schema_insert .= "NULL".$sep; elseif ($row[$j] != "") $schema_insert .= "$row[$j]".$sep; else $schema_insert .= "".$sep; } $schema_insert = str_replace($sep."$", "", $schema_insert); $schema_insert = preg_replace("/\r\n|\n\r|\n|\r/", " ", $schema_insert); $schema_insert .= "\t"; print(trim($schema_insert)); print "\n"; } } ?> have anyone any idea? |