Jump to content

help with tables


ckdoublenecks

Recommended Posts

I want to read records from the database and print out in this table and I need help with the code.

<?php
mysql_connect(localhost,root,"");
mysql_select_db(oodb) or die( "Unable to select database");
$query=" SELECT * FROM oocust";
$result=mysql_query($query);
$num=mysql_numrows($result);
?>
<HTML><HEAD>
<script type="text/javascript">
var monthNames = [ "January","February","March","April","May","June","July",
                   "August","September","October","November","December"     ];
var today = new Date();  
var mmyy = monthNames[today.getMonth()] + " / " + today.getFullYear();
</script>
</HEAD><BODY  bgcolor="#CCCC99" background="oldorchard.jpg"><b><center>
<font size=+2><b> Old Orchard Invoice </font>Date: 
<script type="text/javascript">document.write(mmyy);</script></center>

echo "<TABLE BORDER="0" CELLPADDING="5" CELLSPACING="5" background="oldorchard.jpg">
<TD>
<TABLE BORDER="0" CELLPADDING="10" CELLSPACING="10" background="oldorchard.jpg">
<TD>
<TABLE BORDER="0" CELLPADDING="1" CELLSPACING="1" background="oldorchard.jpg">
    <TD>
<input type=text size=25 value="Old Orchard Plumbing"><br>
<input type=text size=25 value="2210 E. Hogan Hollow Road"><br>
<input type=text size=25 value="Margate, Fl  33063"><br></TD>
      <TR>
   <td>
<input type=text size=3 value="Bill To:"><br>
<input type=text size=25 value="$bname"><br>
<input type=text size=25 value="$bstreet:">><br>
<input type=text size=25 value="$bcity"><br>
<input type=text size=25 value="$contact"><br></TD>
      <tr>
   <td>
<input type=text size=5 value="Ship To:"><br>
<input type=text size=25 value="$sname:"><br>
<input type=text size=25 value="$street"><br>
<input type=text size=25 value="$scity"></td>
</TR>
      </TABLE>
      </TD>
     <TD>
<input type=text size=25 value="Invoice No: $invnum"><br>
<input type=text size=25 value="Date: $mm/dd/yyyy"><br>
<input type=text size=25 value="Terms: $terms"><br>
<input type=text size=25 value="Due Date: $duedate"><br>
<input type=text size=25 value="Order No: $ordernum"><br>
<input type=text size=25 value="Territory:"><br>
<input type=text size=25 value="Salesperson:"><br>
</TD>
</TABLE>
</TD>
<TD align=center><img src="dave pic.jpg" width=250 height=350></td>
</TABLE>

echo "</tr>";
<hr>
echo "</table>";mysql_close();
?> 
</b></BODY></HTML>

Link to comment
Share on other sites

I made these changes:

<?php
mysql_connect(localhost,root,"");
mysql_select_db(oodb) or die( "Unable to select database");
$query=" SELECT * FROM oocust";
$result=mysql_query($query);
$num=mysql_numrows($result);
?>
<HTML><HEAD>
<script type="text/javascript">
var monthNames = [ "January","February","March","April","May","June","July",
                   "August","September","October","November","December"     ];
var today = new Date();  
var mmyy = monthNames[today.getMonth()] + " / " + today.getFullYear();
</script>
</HEAD><BODY  bgcolor="#CCCC99"><b><center>
<font size=+2><b>Old Orchard Invoice</font> 
<script type="text/javascript">document.write(mmyy);</script></center>
<?php
while ($row = mysql_fetch_assoc($result) ) 
{
echo "<TABLE BORDER="0" CELLPADDING=5 CELLSPACING=5>";
<TD>
<TABLE BORDER="0" CELLPADDING=10 CELLSPACING=10>
<TD>
<TABLE BORDER="0" CELLPADDING=1 CELLSPACING=1>
    <TD>
Old Orchard Plumbing<br>
2210 E. Hogan Hollow Road<br>
Margate, Fl  33063<br></TD>
      <TR>
   <td>
<input type=text size=3 value="Bill To:"><br> 
<input type=text size=25 value="<?php echo($bname);?>"><br> 
<input type=text size=25 value="<?php echo($bstreet;?>:">><br> 
<input type=text size=25 value="<?php echo($bcity);?>"><br> 
<input type=text size=25 value="<?php echo($contact)?>"><br></TD> 
      <tr>
   <td>
<input type=text size=3 value="Bill To:"><br> 
<input type=text size=25 value="<?php echo($sname);?>"><br> 
<input type=text size=25 value="<?php echo($sstreet;?>:">><br> 
<input type=text size=25 value="<?php echo($scity);?>"><br> 
</TR>
      </TABLE>
      </TD>
     <TD>
<input type=text size=3 value="Bill To: "> 
<input type=text size=25 value="<?php echo($invnum);?>"><br>
<input type=text size=3 value="Date: ">  
<input type=text size=10 value="<?php echo($mm/dd/yyyy);?>:">><br>
<input type=text size=3 value="Terms: ">
<input type=text size=25 value="<?php echo($terms);?>"><br> 
<input type=text size=3 value="Due Date: ">
<input type=text size=25 value="<?php echo($duedate);?>"><br> 
<input type=text size=3 value="Order No: ">
<input type=text size=25 value="<?php echo($ordernum);?>"><br> 
</TD>
</TABLE>
</TD>
<TD align=center><img src="dave pic.jpg" width=250 height=350></td>
</TABLE>
echo "<tr>";
</tr>";
echo "</table>";mysql_close();
}
?> 
</b></BODY></HTML>

and I got this error:

Parse error: syntax error, unexpected T_LNUMBER, expecting ',' or ';' in C:\xampp\htdocs\oofiles\bill.php on line 21
Link to comment
Share on other sites

I felt good that I was almost done so I added a little selection code but then got this error:

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\xampp\htdocs\oofiles\bill.php on line 70

<?php?>
<HTML><HEAD>
<script type="text/javascript">
var monthNames = [ "January","February","March","April","May","June","July",
                   "August","September","October","November","December"     ];
var today = new Date();  
var mmyy = monthNames[today.getMonth()] + " / " + today.getFullYear();
</script>
</HEAD><BODY bgcolor="#CCCC99" background="oldorchard.jpg"><b><center>
<font size=+2><b> 
<script type="text/javascript">document.write(mmyy);</script></center>
<?php
mysql_connect(localhost,root,"");
mysql_select_db(oodb) or die( "Unable to select database");
if(!empty($_POST["submit"]))
{
$invnum = $_POST['invnum'];
$query=" SELECT * FROM oocust";
$result=mysql_query($query);
$num=mysql_numrows($result);
{
echo "<form action='#' method='post'><b>";
echo "<TABLE BORDER=0 CELLPADDING=5 CELLSPACING=5'>
<TD>
<TABLE BORDER=0 CELLPADDING=10 CELLSPACING=10>
<TD>
<TABLE BORDER=0 CELLPADDING=1 CELLSPACING=1>
   <TD>
<input type=text size=25 value='Old Orchard Plumbing'><br>
<input type=text size=25 value='2210 E. Hogan Hollow Road'><br>
<input type=text size=25 value='Margate, Fl 33063'><br>
  </td>
   <tr>
   <td>
<input type=text size=3 value='Bill To:'><br> 
<input type=text size=25 value='$bname'><br> 
<input type=text size=25 value='$bstreet'><br> 
<input type=text size=25 value='$bcity'><br> 
<input type=text size=25 value='$contact'><br>
    </TD>
    <tr>
    <td>
<input type=text size=3 value='Ship To:'><br> 
<input type=text size=25 value='$sname'><br> 
<input type=text size=25 value='$sstreet'><br> 
<input type=text size=25 value='$scity'><br> 
    </TR>
    </TABLE>
    </TD>
    <TD>
<input type=text size=3 value='Invoice No: '> 
<input type=text size=25 value='$invnum'><br>
<input type=text size=3 value='Terms: '>
<input type=text size=25 value='$terms'><br> 
<input type=text size=3 value='Due Date: '>
<input type=text size=25 value='$duedate'><br> 
<input type=text size=3 value='Order No: '>
<input type=text size=25 value='$ordernum'><br> 
   </TD>
   </TABLE>
   </TD>
<td align=center><img src='dave pic.jpg' width=250 height=350></td>
</table>
echo '<tr>';
<hr>
</tr>';
</table>';
echo '</form>';
  }
else{echo "No listing for invoice no.$invnum.<br />Select another?<br />";
}
?>
<form method="post" action="#">
<br />
<input type="text" name="invnum"/> <p>
<input type="submit" name="submit" value="+"/>
</form>

Link to comment
Share on other sites

- I've trimmed this way down trying to resolve. The only fields that print out are invnum and ordernum and I get this message:

while ( = mysql_fetch_assoc(Resource id #5) ) { echo '
 

<?php?>
<HTML><HEAD>
<script type="text/javascript">
var monthNames = [ "January","February","March","April","May","June", "July",
"August","September","October","November","Decembe r" ];
var today = new Date(); 
var date = monthNames[today.getMonth()] + " - " + today.getDate() + " - " + today.getFullYear();
</script>
</HEAD><BODY>
</center><div align=right>
<script type="text/javascript">document.write(date);</script> 
</div>     
<?php
mysql_connect(localhost,root,""); 
mysql_select_db(numbersdb) or die( "Unable to select database"); 
if(!empty($_POST["submit"])) 
{ 
$invnum = $_POST['invnum']; 
} 
mysql_query("UPDATE numbdata SET invnum=invnum+1"); 
$result=mysql_query("select invnum from numbdata") or die ("Error - could not retrieve invoice number from database");
$data=mysql_fetch_assoc($result);
echo "Invoice No: ".$data['invnum'];
mysql_close(); 
mysql_connect(localhost,root,""); 
mysql_select_db(oodb) or die( "Unable to select database");
if(!empty($_POST["submit"]))
{
$ordernum = $_POST['ordernum']; 
$query=" SELECT * FROM oocust"; 
$result=mysql_query($query); 
if(mysql_num_rows($result))
{
$bname = $_POST['bname'];
$sname = $_POST['sname'];
$terms = $_POST['terms'];
echo "<form action='#' method='post'>
while ($row = mysql_fetch_assoc($result) ) 
{ 
echo '<TABLE BORDER=0 CELLPADDING=5 CELLSPACING=5 background='oldorchard.jpg'> 
<TD> 
<TABLE BORDER=0 CELLPADDING=10 CELLSPACING=10 background='oldorchard.jpg'> 
<TD> 
<TABLE BORDER=0 CELLPADDING=1 CELLSPACING=1 background='oldorchard.jpg'> 
<TD> 
<input type=text size=25 value=Plumbing'><br> 
<input type=text size=25 value='210 E. Road'><br> 
<input type=text size=25 value=38063'><br>
</TD> 
<TR> 
<td> 
<input type=text size=4 value='Bill To:'><br>
<input type=text size=25 value='$bname'><br> 

<tr> 
<td> 
<input type=text size=5 value='Ship To:'><br> 
<input type=text size=25 value='$sname'><br> 

</TR> 
</TABLE> 
</TD> 
<TD> 
<input type=text size=5 value='Terms: '> 
<input type=text size=12 value='$terms'><br> 
<input type=text size=10 value='$ordernum'><br> 
</TD> 
</TABLE> 
</TD> 
<TD align=center><img src='dave pic.jpg' width=250 height=350></td> 
</TABLE> 
<tr> 
</tr>
</table>";
echo "</form>";
}
else{echo "No listing for order no. $ordernum.<br />Select another?<br />";}
}
?>
<form method="post" action="#">
<br />
<input type="text" name="ordernum"/> <p>
<input type="submit" name="submit" value="+"/>
</form>

 

 

 

Link to comment
Share on other sites

You missed a few end-quotes and braces:

<HTML><HEAD>
<script type="text/javascript">
var monthNames = [ "January","February","March","April","May","June", "July",
"August","September","October","November","Decembe r" ];
var today = new Date(); 
var date = monthNames[today.getMonth()] + " - " + today.getDate() + " - " + today.getFullYear();
</script>
</HEAD><BODY>
</center><div align=right>
<script type="text/javascript">document.write(date);</script> 
</div>     
<?php
mysql_connect(localhost,root,""); 
mysql_select_db(numbersdb) or die( "Unable to select database"); 
if(!empty($_POST["submit"])) 
{ 
    $invnum = $_POST['invnum']; 
} 
mysql_query("UPDATE numbdata SET invnum=invnum+1"); 
$result=mysql_query("select invnum from numbdata") or die ("Error - could not retrieve invoice number from database");
$data=mysql_fetch_assoc($result);
echo "Invoice No: ".$data['invnum'];
mysql_close(); 
mysql_connect(localhost,root,""); 
mysql_select_db(oodb) or die( "Unable to select database");
if(!empty($_POST["submit"]))
{
    $ordernum = $_POST['ordernum']; 
    $query=" SELECT * FROM oocust"; 
    $result=mysql_query($query); 
    if(mysql_num_rows($result))
    {
        $bname = $_POST['bname'];
        $sname = $_POST['sname'];
        $terms = $_POST['terms'];
        echo "<form action='#' method='post'>";
        while ($row = mysql_fetch_assoc($result) ) 
        { 
            echo "<TABLE BORDER=0 CELLPADDING=5 CELLSPACING=5 background='oldorchard.jpg'> 
<TD> 
<TABLE BORDER=0 CELLPADDING=10 CELLSPACING=10 background='oldorchard.jpg'> 
<TD> 
<TABLE BORDER=0 CELLPADDING=1 CELLSPACING=1 background='oldorchard.jpg'> 
<TD> 
<input type=text size=25 value=Plumbing'><br> 
<input type=text size=25 value='210 E. Road'><br> 
<input type=text size=25 value=38063'><br>
</TD> 
<TR> 
<td> 
<input type=text size=4 value='Bill To:'><br>
<input type=text size=25 value='$bname'><br> 

<tr> 
<td> 
<input type=text size=5 value='Ship To:'><br> 
<input type=text size=25 value='$sname'><br> 

</TR> 
</TABLE> 
</TD> 
<TD> 
<input type=text size=5 value='Terms: '> 
<input type=text size=12 value='$terms'><br> 
<input type=text size=10 value='$ordernum'><br> 
</TD> 
</TABLE> 
</TD> 
<TD align=center><img src='dave pic.jpg' width=250 height=350></td> 
</TABLE> 
<tr> 
</tr>
</table>";
            echo "</form>";
        } //end while
    } //end if(mysql_num_rows($result))
    else {
        echo "No listing for order no. $ordernum.<br />Select another?<br />";
    }
} //end if(!empty($_POST["submit"]))
?>
<form method="post" action="#">
<br />
<input type="text" name="ordernum"/> <p>
<input type="submit" name="submit" value="+"/>
</form>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.