Jump to content

funbinod

Members
  • Posts

    501
  • Joined

  • Last visited

Posts posted by funbinod

  1. You're getting a PHP error because you're asking for an index in mysql_result() that doesn't seem to exist. The easiest way to solve the problem is to use mysql_fetch_assoc() rather than mysql_result() to get data from the query.

     

    Looking at your second code more carefully, you don't seem to have a while loop and you have a pair of braces { } that aren't representing anything.

    echo '<form action="#" id="test" name="test">';echo '<select name="item">';echo "<option></option>";echo "<option>";{echo '' . mysql_result($result,$n,'item') . '<br />';}echo "</option>";echo '</select>';echo '</form>';

    Somebody already provided working code for your question in this thread: http://w3schools.invisionzone.com/index.php?showtopic=49767

     

    thank u!

     

    now i understood where i did mistake.

     

    actually i had used for loop to get data. but i placed that line elsewhere on the page and expected the result here. finally i completed the code by doing this ---

    <?$rows = mysql_num_rows($result);for ($n = 0 ; $n < $rows ; ++$n)	{		echo '' . mysql_result($result,$n,'item') . '<br />';	}echo '<form action="#" id="test" name="test">';echo '<select name="item">';$rows = mysql_num_rows($result);for ($n = 0 ; $n < $rows ; ++$n){		echo "<option>" . mysql_result($result,$n,'item') . "</option>" ;}echo '</select>';echo '</form>';	?>

    thank u for guiding me. :good:

     

    (sorry! i couldn't understand the solution that was given on that thread. that's why i was continuing here also.)

  2. You probably should use mysql_fetch_assoc() instead.

     

    Best if you used a more recent database library, such as mysqli or PDO, because mysql is insecure and is being deprecated.

     

    i think thats not the solution to my problem.

     

    my problem IS NOT that i could not extract data from table.

     

    my problem IS i coludn't put that data in a DROPDOWN list.

     

    or i didn't understand ur sugestion?????

  3. i created loop for selecting from all the rows of a table

    like this---

    <?$rows = mysql_num_rows($result);for ($n = 0 ; $n < $rows ; ++$n)    {        echo '' . mysql_result($result,$n,'item') . '<br />';    }?>

    and tried to put in dropdown menu like this ----

     

    echo '<form action="#" id="test" name="test">';echo '<select name="item">';echo "<option></option>";echo "<option>";{echo '' . mysql_result($result,$n,'item') . '<br />';}echo "</option>";echo '</select>';echo '</form>';

    but returned error

    "Warning: mysql_result(): Unable to jump to row 2 on MySQL result index 5 in .................................."

    please guide me....
  4. tried to put in dropdown menu like this ----

     

    echo '<form action="#" id="test" name="test">';echo '<select name="item">';echo "<option></option>";echo "<option>";{echo '' . mysql_result($result,$n,'item') . '<br />';}echo "</option>";echo '</select>';echo '</form>';

    but returned error

     

    "Warning: mysql_result(): Unable to jump to row 2 on MySQL result index 5 in .................................."

  5. i created loop for selecting from all the rows of a table

    like this---

    <?$rows = mysql_num_rows($result);for ($n = 0 ; $n < $rows ; ++$n)	{		echo '' . mysql_result($result,$n,'item') . '<br />';	}?>

    but couldn't insert it into a dropdown list. please guide...

  6. wow! thank u both of u for the guidance. i made it work now.

     

    now i again stuck on retriving data for "Billing Address" from "Shipping Address" field for 'IF CHECKED' clause.

     

    i tried this

    				$("#add").val($("#shipAdd"));

    but it didn't work.

     

    please guide...

  7. i tried this - to disable form field if CHECKED and if UNCHECKED cancel disable. but it didnt work on my browser "chrome 33.0.1726.0" and "IE 11". please help me find out the error.....

     

    please help me find out the error ------

    <form action="#"><h3><u>Shipping Address:</u></h3>Address:<input type="text" name="shipAdd" id="shipAdd"><br /><br />City:<input type="text" name="shipCity" id="shipCity"><br /><hr align="left" width="15%" noshade color="#996666" />Billing address same as shipping address.<input type="checkbox" name="billAdd" id="billAdd"><br /><br />Address:<input type="text" name="add" id="add" class="baddr"><br /><br />City:<input type="text" name="city" id="city" class="baddr"><br /><br /><input type="submit" name="submit" id="submit" value="SUBMIT"></form><script type="text/javascript">	$(document).ready(function(e) {        $("#billAdd").click(function() {			if ($("#billAdd").attr("checked") == "checked") {				$(".baddr").val("");				$(".baddr").attr("disabled","disabled");			}			else if ($("#billAdd").attr("checked") == "undefined") {				$(".baddr").removeAttr("disabled");			}		});    });</script>
  8. sorry sir! i didnt meen to make u do my work. actually i'm not doing any work. m not in any mission. i just imagined something and tried to do it. but i forgot that i'm nothing on coding. i've just started learning php and i tried on applications. i know almost nothing about php & mysql, that's why i stuck on every step i move on. since i'm very new on coding, it was bitta difficult for me to understand, so i asked u for direct help. i didnt imagine it will be kind of asking to do work in my favor.

     

    but i think i got some idea from this reply and i can try my code now. i'll try and will be back.

     

    one thing more before i move on - 'can this be done within a FORM?' i mean select 'where' clause from a form field and data be displayed on next form field.

     

    thank u for ur kind support..

  9. where's your code? what have you started? what are you stuck on?

     

    didn't u see the image!? sorry for that. i think the attached image describes my problem.

     

    sorry! i'vent attached my code. u might be more confused seeing my code :Bucktooth: . (coz m very fresh on coding) please try understanding from the image attached. if u still got confused, i'will post what i've written.....

     

    thank u for kind reply.

  10. i'm sorry sir! but its completely confusing for me. i cant understand how is this made done. can u please, if u dont mind, write that code, for example, so that i can understand this more easily.

    what i designed the invoice and wish it to do is like this---

     

    
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>TEST CASHIER</title>
    <link rel=stylesheet href=style.css?>
    </head>
    <body bgcolor="#999999">
    <h1>Test Invoice</h1>
    <h3>Customer Name: Laptop House</h3>
    <table align="left" width="75%" cellspacing="10" border="1">
    <tr>
    <td width="50%" valign="top">
    <table leftmargin=0 marginheight=0 marginwidth=0 topmargin=0 border=1 cellspacing=0 width="100%">
    <form action="tempinvoice.php" method="POST" id="cart">
    <tr>
    <td width=120>Item Code: </td>
    <td><input type=text name=icode style="width:900;"></td><!-- Item Code' is entered here-->
    </tr>
    <tr>
    <td>Item Name: </td>
    <td><input type=text name=item style="width:900" readonly="readonly"></td><!-- Item Name' is displayed here auto -->
    </tr>
    <tr>
    <td>Rate:</td>
    <td><input type=text name=rate style="width:900" readonly="readonly"></td><!-- & 'Rate' is displayed here auto -->
    </tr>
    <tr>
    <td>Quantity:</td>
    <td><input type=text name=qty style="width:900"></td>
    </tr>
    <tr>
    <td>Discount (%):</td>
    <td><input type=text name=less style="width:900"></td>
    </tr>
    <tr>
    <td>Amount:</td>
    <td><input type=text name=amt style="width:900"></td>
    </tr>
    <tr>
    <td> </td>
    <td ><input type=submit class="nav" value='Add to Cart'></td>
    </tr>
    <input type=hidden name=action value=doregister>
    </form>
    </table>
    </td>
    <td align="center"> </td> <!-- & every item added to cart is displayed here in a table (with customer name) which would be posted at once to the database -->
    </tr>
    </table>
    </body>
    </html>
  11. That's what the query will have to be, yes. You don't need to write the literal query though, if the name you're searching for is in a variable then use the variable in the query to put the name they typed there.

    $first_name = 'Peter'; // change that to whatever you want, or set it from a form or whatever else$stmt = mysqli_prepare($con, 'SELECT FirstName, LastName FROM Persons WHERE FirstName=?');mysqli_stmt_bind_param($stmt, 's', $first_name);mysqli_stmt_execute($stmt);mysqli_stmt_bind_result($stmt, $fname, $lname);while (mysqli_stmt_fetch($stmt)) {  echo $fname . ' ' . $lname . '<br>';}
    http://www.php.net/manual/en/mysqli.prepare.php

     

     

    thank u! i think this is now on the way to my goal.

     

    i tried ur suggestive code as my own like this -

     

    <?$icode = '$_POST[icode]';$stmt = mysqli_prepare($con, 'SELECT icode, item FROM stock WHERE icode=$_POST[icode]');mysqli_stmt_bind_param($stmt, 's', $icode);mysqli_stmt_execute($stmt);mysqli_stmt_bind_result($stmt, $icode, $item);while (mysqli_stmt_fetch($stmt)) {  echo $item;}?>

    buy it showed no result. please help finding problem.

     

    thank u

  12. You can format the form so it looks like table. you can use 'box modeling' in css to achieve it. Google box modeling for more information.

     

    sorry sorry! i think i wrote wrong.

     

    i wish a TABLE be treated as FORM, not FORM as TABLE.

     

    and more important is "MOVE EVERY DATA FROM A DATABASE TABLE TO ANOTHER AND DELETE IT WITH A SINGLE SUBMIT". can u please help me with this...???

  13. i want to try an invoice script but got confused at one place.

     

    how to get information from a database table with MANUALLY SELECTING 'WHERE' clause?

     

    i wish a code be entered manually on a form and its details be displayed automatically.

     

    attached is the file what i made and it describes what i wish to be.

     

    please guide.

     

    post-171081-0-95653500-1393814044_thumb.jpg

  14. You can't! the data must be entered by form inputs, when the form is submitted it will in most cases go to a page, that connects to a database through validation of host, username, password to insert the imputed details to specific table and column names.

     

    thank u.

     

    can't the table be treated as form!? i mean all are coded in FORM but displayed as TABLE!

     

    if not could we MOVE all data from a database table to another and delete it with a single SUBMIT!?

  15. please help me inserting data to mysql database table from a html table.

     

    like

    <table> <tr>  <td>name</td>  <td>Gender</td>  <td>age</td>  <td>school</td> </tr> <tr>  <td>John</td>  <td>Male</td>  <td>21</td>  <td>Oxford</td> </tr> <tr>  <td>Juliya</td>  <td>Female</td>  <td>25</td>  <td>Oxford</td> </tr><!- bla! bla! bla! --></table>SUBMIT

    I want to send all the rows' data at once to a table.

     

    Please guide how could it be done!

  16. thank u again.

    and again confusion continues. (sorry! its because am newbie in php or programming)

    let me explain differently.

    if 'peter' is selected as 'first name', then it echos his 'last name'.

    i understood this line. but if i want to echo 'last name' of another name (lets say 'john') then should i have to write another code like

     

    <?

    $result = mysqli_query($con,"SELECT * FROM PersonsWHERE FirstName='John'");while($row = mysqli_fetch_array($result)) { echo $row['FirstName'] . " " . $row['LastName']; echo "<br>"; }

    ?>

     

    and similar for each name!

     

    or can i write a single line for each and every data!?

    (if u'll feel comfortable seeing what i wrote, i would love to send u the file)

  17. thanks justsomeguy for ur kind reply. i've just begun working with databases. i've used SELECT & WHERE command that was taught on w3schools. but that taught selecting with one particular information. but i wish selecting from all rows.(m not sure how to explain either)

     

    w3schools taught me selecting from a single row like -

     

    <?php$con=mysqli_connect("example.com","peter","abc123","my_db");// Check connectionif (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); }$result = mysqli_query($con,"SELECT * FROM PersonsWHERE FirstName='Peter'");while($row = mysqli_fetch_array($result)) { echo $row['FirstName'] . " " . $row['LastName']; echo "<br>"; }?>

     

    it teaches if 'Peter' is selected as 'FirstName' then 'LastName' should be selected from same row. but i wonder if there is one thousand rows then should i have to write lines for each row? or there is alternative? or i misunderstood the code? please guide.

  18. am very fresh in php and whatever i learnt is from w3schools.

     

    i am trying to create invoice script. for this i wish if automatic display of "item name" & "price" by entering just "item code" be possible.

     

    there is a table for stock item with rows "item code", "item name", "price".

    please guide me.

     

    thank u.

×
×
  • Create New...