-
Posts
24,566 -
Joined
-
Last visited
-
Days Won
822
Everything posted by Barand
-
I think you are missing a closing "}" before </table>
-
No, you have a record for each address so you will need one prepared query, but you will execute it twice, once for the residential address data and again for the postal address data
-
How would we know from what you have posted? Why do you need the ID. Is the repairID not unique?
-
Then both will be updated. If a new address is the same as an existing address then MySQL will ignore the update and do nothing.
-
That will only make things worse and remove the empty items. You could now have a situation where title array quantity array price array ----------- -------------- ------------ item 1 5 10.00 item 2 3 item 3 2 1000.00 After filtering the array, you get title array quantity array price array ----------- -------------- ------------ item 1 5 10.00 item 2 3 1000.00 item 3 2 so you are now charging for item 2 at the item 3 price
-
Add a UNIQUE KEY (user_id, address_type). When you update the table use INSERT ... ON DUPLICATE KEY statement so that if the postal or residential address exists then it will be updated, but if it doesn't exist then a new record is added. No need for extra SELECT queries to see if the address already exists. INSERT INTO user_addresses (user_id, address_type, street_no, street_name, city) VALUES (?,?,?,?,?) ON DUPLICATE KEY UPDATE street_no = VALUES(street_no), street_name = VALUES(street_name), city = VALUES(city) ;
-
As I told you in reply #13, variables are local to functions The variable $conn is unknown inside the above function. You need to pass it as a function argument. The definition needs to be function getEvents($conn){ $qry = "SELECT id ,Event_Type FROM Events ORDER BY id"; $sql = mysqli_query($conn, $qry)or die(mysqli_error($conn)); if(mysqli_num_rows($sql) < 1){ return array(); } while($res1 = mysqli_fetch_array($sql)){ $ret1[$res1['id']] = $res1['Event_Type']; } return $ret1; } then when you call the function, pass the $conn value getEvents($conn);
-
What does your DB/table structure look like?
-
Sorry but I have no idea how your code in #1, #3 and #7 above are related. All I see is code snippets with no context.
-
Where are you getting the value for $street_name etc? In the code I posted earlier, $street_name would be $values[1]
-
WHERE user_id = ? AND address_type = 1
-
You have to put your output inside HTML table tags (table, tr, td). Have a look at html table structure and output your data to match that Example <table> <tr> <th>Month</th> <th>Savings</th> </tr> <tr> <td>January</td> <td>$100</td> </tr> </table>
-
Your search field name is "search", not "name" $name=$_POST['search'];
-
while($row = $stmt->fetch()) { $array[$address_type] = array($street_no, $street_name, $city); }
-
Everything between the textarea tags is part of the value, including all the whitespace in your source. Use <textarea name="comments"><?php echo $comments; ?></textarea>
-
This worked for me Data (zodiac.txt) 1884 Pig 2004 Dog 2005 Rat CREATE TABLE zodiacyears ( year smallint primary key, name varchar(10) ); load data infile 'C:/inetpub/wwwroot/. . ./zodiac.txt' into table zodiacyears fields terminated by ' '; mysql> select * from zodiacyears; +------+------+ | year | name | +------+------+ | 1884 | Pig | | 2004 | Dog | | 2005 | Rat | +------+------+
-
Make sure your "path_to_file" is the full system path to the file on your server
-
the operator ".=" appends to the variable. $current is only set to null by default if you do not pass a third parameter when you call the function. The option with the value that matches $current is set as selected. If none are "selected" the first option is selected by default You would echo the result returned by the function wherever you want that menu displayed It returns an array that you pass to the first function to build a menu Variables are local to functions. You can use the same variable name in as many functions as you like. They are different variables and only exist while the function is executing (unless static)
-
You are adding each date as a separate item. You need to add the date pairs as one item then join the items using "<br>" if ($sd){ $item = date_format(($sd), 'm/d/y'); //m/d/y } if ($ed){ $item .= '-' . date_format(($ed), 'm/d/y'); //m/d/y } $data[$cid]['events'][$m][] = $item; }
-
I'd add an empty result array to that function's arguments, then call it recursively. function someFunc(&$res, array $keys, $data) { if (!empty($keys)) { $k = array_shift($keys); someFunc($res[$k], $keys, $data); } else $res = $data; } // call the function $res = []; someFunc($res, array('key1','key2', 'key3'), 'data'); echo $res['key1']['key2']['key3']; //--> data
-
Then you're doing it incorrectly. Post current code.
-