473,327 Members | 1,976 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

how to pass a php array to a sql query

2
hi all,
i have a string for example:
$str="The annual general meeting is scheduled on ::date:: at ::time::.
you all are requested to be present on ::date:: at ::time::."

i store it in the Templates_T table in my DB. Template_ID =1 [for eg.] now this format can be used further for drafting letters or creating newsletters etc..

Now in newsletters.php page for every ::date:: and ::time:: instance, for Template_ID 1 , i load textboxes in array for date[<input type =text name="dispdate[]">] and <select NAME="hours[]" > </select> <select NAME="minutes[]" > </select>in array[] for time. user enters some date and time in the textboxes and <select> respectively. now while updating the content in DB it should go as:
Step 1 : select the entire content from Template_T where Template_ID=1
Step 2: modify the message and replace ::date:: and ::time:: with relevant textbox values , <select > values. some thing like below
Expand|Select|Wrap|Line Numbers
  1. $EntireContent="The annual general meeting is scheduled on 'ValueOfBoxInArray' at 'ValueOfSelectInArray'.
  2. you all are requested to be present on 'ValueOfBoxInArray' at 'ValueOfSelectInArray'."
  3. $sql=mysql_query("insert into mytable_t values('$EntireContent')");
  4.  
how will i accomplish this?

Thanks in advance
Nov 12 '07 #1
1 1869
Atli
5,058 Expert 4TB
Hi.

All you need is the str_replace function.

You simply loop through each of the values you want to switch out, replacing them one at a time. Something like this:
Expand|Select|Wrap|Line Numbers
  1. foreach($dateArray as $date) {
  2.   $str = str_replace("::date::", $date, $str, 1);
  3. }
  4.  
Nov 12 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Nath | last post by:
Please help!? I am new to writing html, javascript, pretty new to MySQL but quite proficient at writing Perl and i'm a quick learner. I am building a database driven website and i am a little...
3
by: dk | last post by:
Hi all, Would appreciate some advice on the following: I am trying to speed up an Access database connected to a SQL Server back-end. I know I can use a pass-through query to pass the sql...
7
by: Zlatko Matiæ | last post by:
Let's assume that we have a database on some SQL server (let it be MS SQL Server) and that we want to execute some parameterized query as a pass.through query. How can we pass parameters to the...
3
by: Andrew Mueller | last post by:
Hello, I tried this question prior and got no response, so thought I would try to explain differently.. I am not sure which type of object to pass between a VB 6.0 ActiveX dll and C#. I am...
9
by: Alan Silver | last post by:
Hello, I'm a bit surprised at the amount of boilerplate code required to do standard data access in .NET and was looking for a way to improve matters. In Classic ASP, I used to have a common...
4
by: _Mario.lat | last post by:
Hallo, I have a little question: In the function session_set_save_handler I can pass the name of function which deal with session. In Xoops code I see the use of this function like that: ...
3
by: Jon Paal | last post by:
why is this code only deleting on the first pass when there is more than one item in the array? checking the array shows all items are present, lower and upper bounds are correct if the array...
14
by: Abhi | last post by:
I wrote a function foo(int arr) and its prototype is declared as foo(int arr); I modify the values of the array in the function and the values are getting modified in the main array which is...
9
by: JRough | last post by:
I tried to pass the $result from a mysql_query in a url like this line Header("Location:clm_historyXL.php?_result=".$result); but on the redirect location clm_history.php page I get an error on...
3
by: swetha123 | last post by:
hello, I don't know how to use cookies please help me in this I am using the dream weaver cs4 I designed the navigation bar to my page using dream weaver cs4 navigation bar contains...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.