PHP - Insert Content Of Array Into One Variable?
I am making a website where writers can share stories.
One of the fields is other stories. So I used this code to make it a array with the links in each f the items. $other_split = explode(',', $other_form); $other_int = count($other_split); $x = 0; while ($x>$other_int) { $other_link[$x] = "<a href = '$other_split[$x]'> Chapter $x </a>"; } How can I insert the data in that array into one non array variable. Similar TutorialsI need a help in the following : I have an admin page from where the admin attaches an gif image.This attached image should be shown to the user as a scrolling image. The code for the scrolling image is done through javascript. So my actual problem is getting the name of the attached gif image to the javascript array which is used for scrolling horizontally. Good evening,
I am working on a program that takes images, and casts them into an associated array, I then want to display thumbnails of those images into a 3 column by 4 row table...
[image][image][image]
[image][image][image]
[image][image][image]
[image][image][image]
(For my visual friends)
here is my current, pardon for the mess, but right now, functionality is more important.
<!DOCTYPE html> <html> <head> <title>Zodiac Gallery</title> </head> <body> <h2 style="text-align:center">Zodiac Gallery</h2> <p>Click a thumbnail image to see enlarged view.</p> <?php $ZodiacArray = array ( "Images/rat.jpg" => "Rat", "Images/ox.jpg" => "Ox", "Images/tiger.jpg" => "Tiger", "Images/rabbit.jpg" => "Rabbit", "Images/dragon.jpg" => "Dragon", "Images/snake.jpg" => "Snake", "Images/horse.jpg" => "Horse", "Images/goat.jpg" => "Goat", "Images/monkey.jpg" => "Monkey", "Images/rooster.jpg" => "Rooster", "Images/dog.jpg" => "Dog", "Images/pig.jpg" => "Pig"); foreach ($ZodiacArray as $image => $zodiac) { echo "<table> <tr> <td><img src="$image" alt="$zodiac" style="width:68px;height:65px"></td <td><img src="$image" alt="$zodiac" style="width:68px;height:65px"></td> <td><img src="$image" alt="$zodiac" style="width:68px;height:65px"></td> </tr> <tr> <td><img src="$image" alt="$zodiac" style="width:68px;height:65px"></td> <td><img src="$image" alt="$zodiac" style="width:68px;height:65px"></td> <td><img src="$image" alt="$zodiac" style="width:68px;height:65px"></td> </tr> <tr> <td><img src="$image" alt="$zodiac" style="width:68px;height:65px"></td> <td><img src="$image" alt="$zodiac" style="width:68px;height:65px"></td> <td><img src="$image" alt="$zodiac" style="width:68px;height:65px"></td> </tr> <tr> <td><img src="$image" alt="$zodiac" style="width:68px;height:65px"></td> <td><img src="$image" alt="$zodiac" style="width:68px;height:65px"></td> <td><img src="$image" alt="$zodiac" style="width:68px;height:65px"></td> </tr> </table>"; ?>Help is welcome, thank you. Hello Guys, I want to insert an array variable into the database e.g Code: [Select] foreach($html->find('div[class=PostContent]') as $element) { echo $element; $sq = "INSERT INTO articles(original_text) VALUES ('$element') WHERE article_link='$item_url'"; $result = mysql_query($sql1) or die('Query failed: ' . mysql_error()); } i want to insert the variable $element into the database but i'm not able to do so for some reason! $element contains only a paragraph of text. how can i insert the variable $element? First page adds a new job number, then the order page loaded with the job number id as a get id. Basically there is a while loop in the order page which shows products/services client can order and he chooses what he requires 'one or eight services' (8 in total) and some other variables like date of order and client name etc. Here is the order item code The first sql statement executes fine, but in the second sql query nothing happens $sql="insert into job_order(order_num,order_date,order_customer_id, order_remarks) values(".$_GET['id'].",NOW(),".$_POST['companyBox'].",'".$_POST['remarkBox']."');"; $res=mysql_query($sql); $id=mysql_insert_id(); foreach($_POST as $key => $value) { if(!empty($value)) { $key.' => '.trim(strip_tags($value)); $order="INSERT INTO orderprod (order_num,prod_id,order_amount,teeth_amount) VALUES ('$_GET[id]','$value','$value','$value');"; $orderres=mysql_query($order) or die(mysql_error()); } }?>$sql="insert into job_order(order_num,order_date,order_customer_id, order_remarks) values(".$_GET['id'].",NOW(),".$_POST['companyBox'].",'".$_POST['remarkBox']."');"; $res=mysql_query($sql); $id=mysql_insert_id(); foreach($_POST as $key => $value) { if(!empty($value)) { $key.' => '.trim(strip_tags($value)); $order="INSERT INTO orderprod (order_num,prod_id,order_amount,teeth_amount) VALUES ('$_GET[id]','$value','$value','$value');"; $orderres=mysql_query($order) or die(mysql_error()); } } ?> ============= This is the formI have removed parts which are irrelevant. Please note that dateBox and companyBox are not required to be looping as they are only for first table, echo "<form action=".$config_basedir."./vieworder.php?id=".$_GET['id']." name=form1 method=post>";?><table><tr><td><h4>JOB ORDER</H4></TD><TD></TD></TR><TR><TD>ORDER NUMBER</TD><TD><?PHP ECHO $_GET['id'] ?></td></tr><tr><td>ORDER DATE</td><td><input type=text name=dateBox></td></tr> <tr><td>COMPANY NAME</td><td><?PHP$sql="select * from customers";$res=mysql_query($sql);echo "<select name=companyBox><option value=''>Please select</option>";WHILE($fetch=mysql_fetch_assoc($res)){ echo "<option value='".$fetch['id']."'>".$fetch['cust_name']."</option>";} echo "</select>"; echo "</td></tr>"; ?> </table> <table><tr><th>ITEM</th><th>QUANTITY</th><th>N0. of Teeths</th></tr><tr><?PHP$sql="select * from products";$res=mysql_query($sql); WHILE($fetch=mysql_fetch_assoc($res)){ echo "<td><input type=text name=desBox value='".$fetch['prod_id']."'>".$fetch['prod_name']."</td><td><input type=text name=quantBox></td><td><input type=text name=teethBox></td>";echo "</tr>";}echo "</table>";?>echo "<form action=".$config_basedir."./vieworder.php?id=".$_GET['id']." name=form1 method=post>"; ?> <table> <tr> <td><h4>JOB ORDER</H4></TD><TD></TD> </TR> <TR> <TD>ORDER NUMBER</TD><TD><?PHP ECHO $_GET['id'] ?></td> </tr> <tr> <td>ORDER DATE</td><td><input type=text name=dateBox></td> </tr> <tr> <td>COMPANY NAME</td><td> <?PHP $sql="select * from customers"; $res=mysql_query($sql); echo "<select name=companyBox><option value=''>Please select</option>"; WHILE($fetch=mysql_fetch_assoc($res)){ echo "<option value='".$fetch['id']."'>".$fetch['cust_name']."</option>";} echo "</select>"; echo "</td></tr>"; ?> </table> <table> <tr> <th>ITEM</th><th>QUANTITY</th><th>N0. of Teeths</th> </tr> <tr> <?PHP $sql="select * from products"; $res=mysql_query($sql); WHILE($fetch=mysql_fetch_assoc($res)){ echo "<td><input type=text name=desBox value='".$fetch['prod_id']."'>".$fetch['prod_name']."</td> <td><input type=text name=quantBox></td> <td><input type=text name=teethBox></td>"; echo "</tr>";} echo "</table>"; ?> HERE IS THE IMAGE showing the populated services. http://dubads.com/images/order.jpg Hi, I will start off trying to explain what I am trying to make the best I can. What I want to create is a script that gets the gold value from this website: http://www.lbma.org.uk/pages/index.cfm?page_id=46&title=current_statistics and then save it to a variable which I will use to calculate values of different gold karats. Here is the content in bold I need on the website I linked: Quote LONDON GOLD FIXING USD GBP EUR AM 1588.00 1005.127 1251.083 PM 1589.50 1004.741 1249.803 So what help do I need? Well, I don't expect you to figure out the calculating part for me but some help how to get that content pointed out above and save it to a variable is what I would appreciate getting some help with. I don't know much PHP, only some and I have been trying to figure this out for a day now without any success. I suppose php get contents and/or curl should be used here but I don't know how really. I would very much appreciate the help I can get on this. Thank you! I have an array $array_1 Code: [Select] ARRAY( [0] => info 1 [1] => info 2 [2] => info 3 ) and I have another array $array_2 Code: [Select] ARRAY( [0] =>thank you and welcome to what ever [1] =>the info you added * thanks for entering your info ) I want to loop though the first array and place the values into the [1] of the second array. But the tricky thing is I want it to insert were the * is. Code: [Select] foreach ($array_1 as $key => $val) { //not sure about this insert into ($array_2[1],after *, $val); } any help would be awesome. Hi there,
I want to make script which will execute via crontab every Sunday at 0:01h and will stop at 23:59h. My goal is to put(show) some tekst on the site. The problem is how to put this tekst in the site? I mean I know how to configure Cron Jobs but how to include the tekst in index.php for example?
crontab will be.
1 0 * * 0 /usr/bin/php Start.php 59 23 * * 0 /usr/bin/php Stop.php Hello! How do I insert the content of two different variables into the SAME field in a table? Let's say, that variable A contains the word "blue" and variable B contains the word "sky". How do I "merge" these to variables into only one variable containing the words "Blue Sky"? Best regards Morris im working on my website and im trying to insert text from a file into the webpage. the webpage is index.php the .txt file is indexbody.txt at the point of where the code is i would like to insert the contents of the text file into the html document so the person viewing the site can read it as if it was directly in that webpage. i hope you understand what im asking the current not working code is: <?php $myFile = "indexbody.txt"; $fh = fopen($myFile, 'r'); $theData = fread($fh, 5); fclose($fh); echo $theData;?> I'm trying to create a INSERT query statement that makes use of the content of 'include' files. When I call up the include it simply echos it to the screen but I can't seem to capture the text string and actually make it function as part of the query. I've tried setting the include as a variable but again it only outputs to the screen. Help please! Here's a portion of the code... if (($_POST['sched_templates']) == "sched_TestingOnly.htm") { $query = include 'sched_TestingOnlyQuery1.htm'; } if (@mysql_query ($query)) { mysql_close(); // End adding Registration to the database header ('Location: redirectfile.htm'); exit(); } else { print "<p><b>Sorry, your entry could not be entered. } hello can anyone help me how to insert GET variable into mysql <?php $page_title = 'Personal Wellness'; include ('template/header.inc'); include_once('config.php'); $id = $_GET['id']; if(isset($_POST['submit'])) //if submit was pressed { if(strlen($_POST['height'])<1) //if there was no height { print "You did not enter a height."; } else if(strlen($_POST['weight'])<1) //no weight { print "You did not enter a weight."; } else if(strlen($_POST['bodyfat'])<1) //no bodyfat { print "You did not enter a Body Fat Range"; } else if (strlen ($_POST['bodywater'])<1) //no bodywater { print "You did not enter a Body Water Range"; } else if( strlen($_POST['musclemass'])<1) //no musclemass { print "You did not enter a Muscle Mass"; } else if (strlen ($_POST['physiqueratt'])<1) //no physiqueratt { print "You did not enter a Physique Ratings"; } else if (strlen ($_POST['bonemass'])<1) //no bonemass { print "You did not enter a Bone Mass"; } else if (strlen ($_POST['bmr'])<1) //no bmr { print "You did not enter a BMR"; } else if (strlen ($_POST['basalmetabolic'])<1) //no basalmetabolic { print "You did not enter a Basal Metabolic Age"; } else if (strlen ($_POST['visceralfat'])<1) //no visceralfat { print "You did not enter a Visceral Fat"; } else if(strlen($_POST['registrationmonth'] && $_POST['registrationday'] && $_POST['registrationyear'])<1) // no date { print "You did not enter a date of birth"; } else //all fields met { $id=$_GET['id']; $height=$_POST['height']; $weight=$_POST['weight']; $bodyfat=$_POST['bodyfat']; $bodywater=$_POST['bodywater']; $musclemass=$_POST['musclemass']; $physiqueratt=$_POST['physiqueratt']; $bonemass=$_POST['bonemass']; $bmr=$_POST['bmr']; $basalmetabolic=$_POST['basalmetabolic']; $visceralfat=$_POST['visceralfat']; $date=$_POST['registrationyear'] . '-' . $_POST['registrationmonth'] . '-' . $_POST['registrationday']; $insertadmin="INSERT into personalwelness (m_id,height,weight,body_fat,body_water,muscle_mas s,physique_ratt,bone_mass,bmr,basal_metabolic,visc eral_fat,evaluation_date) values ('$id','$height','$weight','$bodyfat','$bodywater','$mus clemass','$physiqueratt','$bonemass','$bmr','$basa lmetabolic','$visceralfat','$date')"; //registering admin in databae echo $insertadmin; $insertadmin2=mysql_query($insertadmin) or die("Could not insert admin"); print "Personal Wellness Successfully Submitted"; } } ?> <form method="post" class="form" action="<?php echo $_SERVER['PHP_SELF'];?>"> <fieldset><legend>Enter Personal Wellness Information in the form below:</legend> <table width="80%" border="0"> <tr> <td width="16%">Height(CM)</td> <td width="2%">:</td> <td width="82%"><label for="height"></label> <input type="text" name="height" id="height" value="<?php if (isset($_POST['height'])) echo $_POST['height'];?>" /></td> </tr> <tr> <td>Weight(KG)</td> <td>:</td> <td><label for="weight"></label> <input type="text" name="weight" id="weight" value="<?php if (isset($_POST['weight'])) echo $_POST['weight'];?>" /></td> </tr> <tr> <td >Body Fat Range</td> <td>:</td> <td><label for="body fat"></label> <input type="text" name="bodyfat" id="bodyfat" value="<?php if (isset($_POST['bodyfat'])) echo $_POST['bodyfat'];?>" ></td> </tr> <tr> <td>Body Water Range(%)</td> <td>:</td> <td><label for="bodywater"></label> <input type="text" name="bodywater" id="bodywater" value="<?php if (isset($_POST['bodywater'])) echo $_POST['bodywater'];?>"/></td> </tr> <tr> <td>Muscle Mass</td> <td>:</td> <td><label for="musclemass"></label> <input type="text" name="musclemass" id="musclemass" value="<?php if (isset($_POST['musclemass'])) echo $_POST['musclemass'];?>"></td> </tr> <tr> <td>Physique Ratings</td> <td>:</td> <td><label for="physiqueratt"></label> <input type="text" name="physiqueratt" id="physiqueratt" value="<?php if (isset($_POST['physiqueratt'])) echo $_POST['physiqueratt'];?>"></td> </tr> <tr> <td>Bone Mass</td> <td>:</td> <td><label for="bonemass"></label> <input type="text" name="bonemass" id="bonemass" value="<?php if (isset($_POST['bonemass'])) echo $_POST['bonemass'];?>" /></td> </tr> <tr> <td>BMR</td> <td>:</td> <td><label for="bmr"></label> <input type="text" name="bmr" id="bmr" value="<?php if (isset($_POST['bmr'])) echo $_POST['bmr'];?>"/></td> </tr> <tr> <td>Basal Metabolic Age</td> <td>:</td> <td><label for="basalmetabolic"></label> <input type="text" name="basalmetabolic" id="basalmetabolic" value="<?php if (isset($_POST['basalmetabolic'])) echo $_POST['basalmetabolic'];?>"></td> </tr> <tr> <td>Visceral Fat</td> <td>:</td> <td><label for="visceralfat"></label> <input type="text" name="visceralfat" id="visceralfat" value="<?php if (isset($_POST['visceralfat'])) echo $_POST['visceralfat'];?>"></td> </tr> <tr> <td>Evaluation Date</td> <td>:</td> <td> <?php echo date_picker("registration")?></td> </tr> </table> </fieldset> <div align="center"><input type="submit" name="submit" value="Submit" /> </div> </form> <?php function date_picker($name, $startyear=NULL, $endyear=NULL) { if($startyear==NULL) $startyear = date("Y")-100; if($endyear==NULL) $endyear=date("Y")+50; $months=array('','January','February','March','Apr il','May', 'June','July','August', 'September','October','November','December'); // Month dropdown $html="<select name=\"".$name."month\">"; for($i=1;$i<=12;$i++) { $html.="<option value='$i'>$months[$i]</option>"; } $html.="</select> "; // Day dropdown $html.="<select name=\"".$name."day\">"; for($i=1;$i<=31;$i++) { $html.="<option $selected value='$i'>$i</option>"; } $html.="</select> "; // Year dropdown $html.="<select name=\"".$name."year\">"; for($i=$startyear;$i<=$endyear;$i++) { $html.="<option value='$i'>$i</option>"; } $html.="</select> "; return $html; } ?> <?php include ('template/footer.inc'); ?> Hi anyone here know how to insert $GET variable into mysql, i don't know how to put this variable between curly bracket, when i put on top insert query, i got error 'Could not insert admin'...please help Code: [Select] <?php mysql_connect("localhost","root","") or die(mysql_error()); mysql_select_db("healthsystem") or die(msql_error()); [color=red]//GET varibable $id = $_GET['id'];[/color] // file properties $file = $_FILES['image']['tmp_name']; if (!isset($file)) echo "Please select an image"; else { $image = addslashes(file_get_contents($_FILES['image']['tmp_name'])); $image_name = addslashes($_FILES['image']['name']); $image_size = getimagesize($_FILES['image']['tmp_name']); if ($image_size==FALSE) echo "That's not an image."; else { $insert = "INSERT INTO image_tbl(m_id,name,image) VALUES ('$id','$image_name','$image')"; $insert2=mysql_query($insert) or die("Could not insert admin"); print "Personal Wellness Successfully Submitted"; } } ?> Hello, I'm working on a PHP register form, all I want to do, is to be able to insert an extra variable into the database: Code: [Select] // now we insert it into the database $insert = " INSERT INTO users (username, password) VALUES ('".$_POST['username']."', '".$_POST['pass']."') "; $add_member = mysql_query($insert); right, so I have the username and password variable being passed. But I also want to pass a variable into a column called 'weaponAttachments', all I want for this variable to be is 5000. So, in other words, something like this: 5000['weaponAttachments'] Thanks I have this link "https://localhost/what/index.php?album=parent%2Fsubalbum&image=1coffee.jpg" Am trying to insert a variable(eid=86) so that it comes before all other variables to read thus "https://localhost/what/index.php?eid=86&album=parent%2Fsubalbum&image=1coffee.jpg" Regards Hi - I'm quite confused. I have a variety of variables derived from a post array which all INSERT except for one: $prodname[$i]. Yet it will echo out, and Var_dump shows that it is a string. I have checked the table and the field is a 50 character varchar. If I hard code into my app 'foobar' ( a string ! ) instead of the variable it will insert. Theother variables that I am using will also insert - ok they are floats and ints. If I remove the $prodname[$i] from my query, the query executes fine with the remaining values, but it fails with it in. Can anyone tell me what I need to do to get this one variable to insert ? I'm using MySQL 5.5 MANY THANKS ! Here is the code: Code: [Select] function confirmed_Order(){ $prodname = $_POST['prodname']; $prodid =$_POST['prodid']; $quantity = $_POST['quantity']; $pricelb = $_POST['pricelb']; $numloops = count($_POST['prodid']); for ($i = 0; $i < $numloops ; $i++) { echo "ProdName".$prodname[$i] . "ProdID".$prodid[$i]."Qunatity".$quantity[$i]. "Pricelb".$pricelb[$i]; // ECHOS FINE var_dump($prodname[$i]); // CONFIRMS IT IS A STRING $sql =" INSERT INTO `confirmedorder` (Prodid, Prodname, pricelb,quantity) VALUES ($prodid[$i], $prodname[$i],$pricelb[$i], $quantity[$i]) "; $this->db->query($sql); } } Hello! I was wondering if this could be done... I want to take a variable, and insert it into a URL for a $_GET on a different page? Basically Its a member website, and I want the admin to be able to "accept" or "deny" the application... So i have a page that displays all the applications, and I want it to take him to a different page with all the user's information in detail. Right now it only displays their name, but when the admin presses the link, it takes them to a more detailed page about the applicant, where they can then "accept" or "deny" the application.... Here is what i got so far... Code: [Select] $character_name = "Nightmareinhell"; <a href="admin_evaluate.php?name=$character_name">$character_name</a> Here is the error I get from the code above Quote Parse error: syntax error, unexpected T_STRING in C:\wamp\www\admin_acceptapply.php Thanks to any help!!!! Hi guys im in the middle of optimizing code.. Code: [Select] $sql = "SELECT * FROM sa_enemystats WHERE username='$username'"; $res = mysql_query($sql); while ($row = mysql_fetch_assoc($res)) { $enemy['current_health'] = $row['current_health']; $enemy['current_skill'] = $row['current_skill']; $enemy['level'] = $row['level']; $enemy['damage'] = $row['damage']; $enemy['evade'] = $row['evade']; $enemy['accuracy'] = $row['accuracy']; $enemy['speed'] = $row['speed']; $enemy['luck'] = $row['luck']; echo 'debug: variables synced with db table'; }I know that the setting of these variables are messy and can be done in a better way... but how? I have tried foreach and copying other's code for an array copy but it lead no where. Then again my syntax could be wrong... I used something like Code: [Select] foreach ( $enemy[$value] as $row => $value) { $enemy[$value] = $row[$value]; } Code: [Select] <?php "INSERT INTO costumers (firstname,lastname,birthdate,product_name,price,details,category,subcategory,city,state,zipcode,country) VALUES('$fname','$lname','$birthday','$itemname','$price','$details','$category','$subcategory','$city','$state','$zipcode','$country')"; ?> What am I missing in the INSERT query above that is not inserting the values of birthday.? This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=346503.0 hi ..
hit little snag Ive got html <form name="formx" method="POST" action="connect.php" class='ajaxform'> and about 4 varibles in that form .. now how to properly
query table users so i can find out which prefix correspond with that user
Insert into table "upis" in this case that prefix with 3 variables..
everything in single,.. in this case connect.php file
I know how to do QUERY and INSERT INTO but i don't know how to connect with 2 different tbl or db and do the query and input of data.. every time I put 2 of them together .. never works out..
this is example.. i dont know is this right way to do it .. |