0
        <td>Jumlah  :</td>
        <td><input type="text" size="12" maxlength="22" name="Jumlah" value="2 box 1 pack"></td><br> 
    <tr>
        <?php // use date picker to automate date ?>
        <td>Tanggal :</td>
        <td><input type="date" id="datepicker" size="12" maxlength="22" name="Tanggal" value=""></td><br>
    </tr>    
    <?php
if (isset($_POST['submit'])){
    mysql_query("INSERT INTO Stock (Produk,Jumlah,Tanggal) VALUES ('$_POST[batch]','$_POST[Jumlah]','$_POST[Tanggal]')");
    echo "<script type=\"text/javascript\">
    window.location = \"print.php\";
    </script>";
}
    ?>
    </table>

    <input name="submit" type="submit" value="Submit">

</form>   

<?php

echo mysql_query("SELECT * FROM stock");

?>

This is a form with sql query to view what's stored in the table. I receive this message though:

Produk :
Jumlah :
Tanggal :

Resource id #5
(where the resource id #5 appeared from?)

4
Contributors
5
Replies
7
Views
4 Years
Discussion Span
Last Post by TonyG_cyprus
0

if you want to print the result from table stock then you should do something like this.

!IMPORTANT! My mysql techniques are pretty rusty.. it has been a while since I used it in application. I am so accustomed of using a database wrapper..

here we go let me give it another try...

$result = mysql_query("SELECT * FROM stock") 
or die(mysql_error());  
while($row = mysql_fetch_array( $result )) {


echo $row['Produk'].'<br/>';

echo $row['Jumlah'];

} 

that's pretty much it... Just a friendly suggestion... if you will be using this script for more than a year, I highly recommend to use a PDO wrapper or mysqli..

PHP language is going for High Level language status pretty soon ( I mean it is already is, but it has to be refined). So, our conventional ways of writing codes may become old style that will only work on older version of PHP. I have no problem with the procedural, but OOP will be the standard pretty soon..

Edited by veedeoo: info added

0

in fixing it dont echo the execution
if you want to print the statement separate it like

$sql = "select * from table";
echo $sql;
$query = mysql_query($sql);

but if you want to print the result follow veedeoo's advice

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.