Jump to content

mySQL index? key? what causes this problem!!!


hossfly007

Recommended Posts

my script and database are not syncing as you can tell PLEASE what do i do? I am very new to this

BagTag#: 1 Name: 
BagTag#:  Name: 1
BagTag#: 2 Name: 
BagTag#:  Name: 3
BagTag#: 4 Name: 
BagTag#:  Name: 4
BagTag#: 5 Name: 
BagTag#:  Name: 5


-



<?php
$host = '0000;     
$user = '0000';
$password = '0000';
$dbName = '0000';
$conn = mysql_connect($host, $user, $password) or die(mysql_error());
$db = mysql_select_db($dbName, $conn) or die(mysql_error());

if (isset($_POST['bag_number']) && trim($_POST['bag_number']) != '') {
$bag_number = $_POST['bag_number'];
$sql  = "insert into testTable (bag_number) values ('$bag_number')";
$result = mysql_query($sql, $conn) or die(mysql_error());
}
if (isset($_POST['bag_member']) && trim($_POST['bag_member']) != '') {
$bag_member = $_POST['bag_member'];
$sql  = "insert into testTable (bag_member) values ('$bag_member')";
$result = mysql_query($sql, $conn) or die(mysql_error());
}

$result = mysql_query("select bag_number, bag_member from testtable");

$row= mysql_fetch_assoc($result);
echo "<table>\n";
while ($row= mysql_fetch_assoc($result))
{
echo "<tr><td>BagTag#: " . $row["bag_number"]. "</td><td>Name: ". $row["bag_member"]. "</td></tr>\n";
}
echo "</table>";
echo "<br> Make a new entry: <br>
<form action = '{$_SERVER['PHP_SELF']}' method ='post'>
<input type = 'text' name = 'bag_number' maxlength='20' size = '10'>
<input type = 'text' name = 'bag_member' maxlength='20' size = '10'>
<input type = 'submit' value = 'Add Entry'>
</form>";

?>




-




Field              Type Null          Default
bag_number    varchar(5)        No     
bag_member    varchar(50)        No     
bag_w            varchar(5)          No     
bag_l              varchar(5)        No     
Link to comment
Share on other sites

i dont really know if that's the term, but when i post the info and the retrieve it it does show up on the same row, i'm thinking that is suppose to stay together right?

1 with 1
2 with 2
3 with 3


<<<example of the output>>>
BagTag#: 1 Name: 
BagTag#:  Name: 1
BagTag#: 2 Name: 
4BagTag#:  Name: 2
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.