-
Posts
1,437 -
Joined
-
Last visited
Never
Posts posted by papaface
-
-
use:
[code]<pre> getfromdbcode </pre>[/code]
e.g
[code]echo "<pre>" . $row['2'] . "</pre>";[/code] -
[code]list($name, $extension) = explode('.', $filename);[/code]
$name = without extension
$extension = extension -
Please use {code} {/code} around your code - replace { & } with [ & ]
-
This is not possible as when a person views an image in their web browser it IS actually downloaded.
-
<<<<<<<<<<<<<<<
-
the directories you are trying to access and the file.
-
have you checked permissions?
-
Isn't that illegal without a license?..........
or do you have one? -
No, because $key is the value of all the input field names on the previous page. So I would end up getting "name,order1,order2,order3,order4,order5" all put into the order_name field. Whereas I just want the value of the "name" $key added.
-
[code]if (isset($_POST["submit"]))
{
foreach ($_POST as $key => $value)
{
if ($key != empty($value))
{
if ($key != "submit")
{
$query = mysql_query("SELECT * FROM orders WHERE order_item = '$value'");
$check = mysql_num_rows($query);
if(!$check)
{
mysql_query("insert into orders (order_item) values ('$value')",$con);
}
else {
$query = mysql_query("SELECT order_quantity FROM orders WHERE order_item='$value'");
$data = mysql_fetch_assoc($query);
$quantity = $data["order_quantity"];
$quantity = $quantity + 1;
mysql_query("UPDATE orders SET order_quantity=$quantity WHERE order_item='$value'");
}
}
}
}
echo "Thank your for your order!";
}[/code]
^^ that is what I have at the moment. Presently that code will input into the database the values into the order_items table. I want all the $values to go into the items field, except for the name field (that was submitted on a previous page). I want the name value to be inserted into the same row as the order_items. Very difficult to explain, but I want to achieve this:
[code]mysql_query("insert into orders (order_item,order_name) values ('$value','THEVALUEOFTHENAMEFIELDONPREVIOUSPAGESHOULDBEINSERTEDHERE')",$con);[/code]
hope that clears things up a little. -
Thanks for that, but it isnt what i really need.
Im trying to include a specific input field that has been posted to this script in a peice of SQL coding.
In order to do that i need to do something like $key[name] but that doesnt work.
Any ideas? -
Hello,
Could someone please inform me of how I would select a specific key in this loop?[code]foreach ($_POST as $key => $value)[/code]
I want to get a key named "name".
Thank you. -
Thanks for your help. :)
-
Hello,
I was wondering if someone can help me.
I am trying to make a kind of shopping cart.
A person submits a form of checkboxes with each items quantity equaling "1".
How would I go about checking in the mysql database if the name of that item exists in the order table, and if so increment the current quantity stored in the table by one.
On the other hand if the value is not present, add it with the quantity equalling 1.
Hope you can understand that. I would appreciate any help anyone can give.
Thanks.
edit:
The code I currently have in a script named process.php is:
[code]if (isset($_POST["submit"]))
{
foreach ($_POST as $key => $value)
{
if ($key != "submit")
{
mysql_query("insert into orders (order_item) values ('$value')",$con) or die (mysql_error());
}
}
}[/code] -
Thanks. Worked great.
-
Hello,
Could someone inform me of how I can go about excluding the value of $_POST["submit"] in a foreach loop?
regards -
Hello,
I was wondering if someone can help me.
Currently I have the following code in a file named submit.php:
[code]<?php
require("includes/connect.php");
require("includes/selectdb.php");
?>
<form action="process.php" method="post">
<?php
$sql = mysql_query("select id,name from groceries",$con);
while (list($id,$name) = mysql_fetch_array($sql))
{?>
<label><?=$name?><input name="<?=$id?>" type="checkbox" value="<?=$name?>"></label><br>
<?php }
?>
</form>[/code]
How would I go about adding the values of an unlimited amount of checkboxes to a database? -
Its good for that website. But as I mentioned the link I gave you isnt the link I want to use. The link I want to use is for something completely different. I basically need the ability to enter a phrase and for php to bring back the phrase then the number to the right of it, whether it be a currency or just a number. Do you have any other method of contact besides the forum The Little Guy ?
-
Great :)
-
Simpler:
[code]list($name, $extension) = explode('.', $filename);[/code]
$name = without extension
$extension = extension -
Not entirely sure what you want to do. But you can use this to do something to all the values of $_POST.
[code]
foreach ($_POST as $key => $value)
{
what ever you want to do with the values of the postdata.
}
[/code] -
No problem :)
-
[code]<?php
$file = file_get_contents("http://www.amazon.co.uk/Sony-Ericsson-W800i-Vodafone-Weekends/dp/B000BSRU6I")or die ("error " . mysql_error());
echo $file;
preg_match_all("~^Price: \£[0-9]$/i~", $file,$out, PREG_PATTERN_ORDER);
foreach($out[0] as $value){
echo $value.'<br>';
}
?>
[/code]
That is what im using. Its not the URL im really trying to use, but it still doesnt work. -
I get:
Warning: Invalid argument supplied for foreach() in xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx on line 6
Color changing options, switching CSS's
in PHP Coding Help
Posted
[code]switch ($_GET["style"])
{
case "1":
$stylesheet = "style1.css";
case "2":
$stylesheet = "style2.css";
default:
$stylesheet = "style1.css";
}
echo '<link rel="stylesheet" type="text/css" href="'.$stylesheet.'" media="screen"/>';[/code]