I have a problem with inserting one field from a table to another. I have two tables: member and reservation table. In both table I have member_ID I want to get the value of the member_ID from member table and insert it in reservation table.

This is my code:

$type=$_POST['serv_name'];
$no=$_POST['reserv_hours'];
$time=$_POST['reserv_time'];
$date=$_POST['reserv_date'];
$ID=$_POST['member_ID'];
$fn=$_SESSION['fn'];

$sql=mysql_query("INSERT INTO reservation (serv_name,reserv_hours,reserv_time,reserv_date,member_ID)
VALUES ('$type','$no','$time','$date',$ID)");

$sql1=mysql_query("INSERT INTO reservation (reserv_ID,serv_name,reserv_hours,reserv_time,reserv_date,member_ID)
(SELECT r.reserv_ID,r.serv_name,r.reserv_hours,r.reserv_time,r.reserv_date,m.member_ID  FROM reservation r LEFT JOIN member  m ON r.member_ID=m.member_ID)");

$result = ($sql.$sql1);
if($result)
{
    header("Location:payment.php");
}
else
{
    echo "ERROR!";
    header("refresh:5;url=main.php");
}


It is working and it do register in my database but the member_ID in my reservation table remained 0. Please help. Thank you in advance.


Question: Can a number have both a periodic an a non-periodic representation in a non-integer base?
Answer: We have $2=\frac23+\frac49+\cdots+(\frac23)^k+\cdots$, which is clearly periodic. Let us write, alternatively, $$2=1+\dfrac23+\dfrac{8}{27}+\dfrac{512}{19683}+\cdots,$$or$$1=\dfrac23+\dfrac{8}{27}+\dfrac{512}{19683}+\cdots=\sum_{k=1}^{\infty}\dfrac{2^k}{3^k}a_k,$$ where $a_1=1,a_2=0,a_3=1,a_4=\cdots=a_{8}=0,a_{9}=1,$ and generally $a_n=1$ if $$1-\sum_{k=1}^{n-1}\dfrac{2^k}{3^k}a_k&gt;\dfrac{2^n}{3^n},$$ with $a_n=0$ otherwise. A proof that $\sum_{k=1}^{\infty}\left(\frac23\right)\!^ka_k=1$ is appended below. We will show that the sequence $(a_1,a_2,...)$ cannot be eventually periodic. To do this, suppose the contrary. Then there are integers $l\geqslant0$ and $m\geqslant1$ such that$$1-\left(\dfrac23+\dfrac{8}{27}+\dfrac{512}{19683}+\cdots+\dfrac{2^l}{3^l}\right)
=\dfrac{2^{l+1}}{3^{l+1}}\sum_{k=1}^{m}\dfrac{2^{k-1}}{3^{k-1}}a_{l+k}\sum_{k=0}^\infty\dfrac{2^{mk}}{3^{mk}}$$ $$\qquad\qquad\qquad\quad\qquad\qquad\quad=\dfrac{2^{l+1}p}{3^l(3^m-2^m)},$$ where $p$ is an integer. Now the fraction on the LHS, in its lowest terms, has an odd numerator, while the fraction on the RHS has an even numerator: a contradiction.

Edit: To prove that $\sum_{k=1}^{\infty}\left(\frac23\right)\!^ka_k=1,$ we show by induction that $$0&lt;1-\sum_{k=1}^{n-1}\dfrac{2^k}{3^k}a_k&lt;2\frac{2^n}{3^n}\quad(n=1,2,..).$$This is true for $n=1,$ since $0&lt;1&lt;\frac43.$ Now suppose that it has been established for $n=j,$ namely $$0&lt;1-\sum_{k=1}^{j-1}\dfrac{2^k}{3^k}a_k&lt;2\frac{2^j}{3^j}.$$(Case 1) If $$1-\sum_{k=1}^{j-1}\frac{2^k}{3^k}a_k&gt;\frac{2^j}{3^j},$$then $a_j=1,$ and $$0&lt;1-\sum_{k=1}^j\frac{2^k}{3^k}a_k=1-\sum_{k=1}^{j-1}\dfrac{2^k}{3^k}a_k-\frac{2^j}{3^j}&lt;2\frac{2^j}{3^j}-\frac{2^j}{3^j}=\frac{2^j}{3^j}&lt;2\frac{2^{j+1}}{3^{j+1}}.$$(Case 2) If $$1-\sum_{k=1}^{j-1}\frac{2^k}{3^k}a_k&lt;\frac{2^j}{3^j},$$then $a_j=0,$ and $$0&lt;1-\sum_{k=1}^j\frac{2^k}{3^k}a_k=1-\sum_{k=1}^{j-1}\frac{2^k}{3^k}a_k&lt;\frac{2^j}{3^j}&lt;2\frac{2^{j+1}}{3^{j+1}}.$$This completes the inductive step.