unable to retrive data

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
njbabbas
Forum Newbie
Posts: 1
Joined: Thu Sep 15, 2011 8:45 am

unable to retrive data

Post by njbabbas »

hi.. i am new to php and have got to complete my project in it.The issue that i am facing is that i have created a php from in Dreamweaver for the user to enter the details.I am facing two problems in the form.

1.I am not able to populate my drop down menu from mysql data base

2.On clicking submit button every data item is saved in the user table except the ones that are in the drop down menu who's options i have entered manually
---------------------------------------------------------------
Using table to store Data is USER TABLE... in which i have to store the countryid,cityid,stateid on selection of the country,city and state from mast_country,mast_city,mast_state where countryid,cityid,stateid are primary keys can anyone guide me how to do it plz....

de is as fallows :===

Code: Select all

<?php require_once('Connections/mydata.php'); ?>

<?php

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 7) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO user (email, name, mobile,country, pincode, place, address) VALUES (%s, %s, %s, %s, %s, %s,%s)",
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['name'], "text"),
GetSQLValueString($_POST['mobile'], "text"),
GetSQLValueString($_POST['country'], "text"),
GetSQLValueString($_POST['pincode'], "text"),
GetSQLValueString($_POST['place'], "text"),
GetSQLValueString($_POST['address'], "text"));

mysql_select_db($database_mydata, $mydata);
$Result1 = mysql_query($insertSQL, $mydata) or die(mysql_error());

$insertGoTo = "coursefact10.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}

mysql_select_db($database_mydata, $mydata);
$query_user = "SELECT * FROM user";
$user = mysql_query($query_user, $mydata) or die(mysql_error());
$row_user = mysql_fetch_assoc($user);
$totalRows_user = mysql_num_rows($user);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
body {
background-color: #9C6;
}
</style>
</head>

<body>
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Email:</td>
<td><input name="email" type="text" value="" size="32" maxlength="100" /></td>
</tr>

<tr valign="baseline">
<td nowrap="nowrap" align="right">Name:</td>
<td><input name="name" type="text" value="" size="32" maxlength="100" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Mobile:</td>
<td><input name="mobile" type="text" size="32" maxlength="10" /></td>
</tr>

<tr valign="baseline">
<td align="right" valign="middle" nowrap="nowrap">Country:</td>
<td><select name="select"width="40" >
<option>India
<option>USA
<option>England
<option>Russia
<option>China
<option>France
<option>Germany
<optionvalue="country" selected>

</select></td>
</tr>

<tr valign="baseline">
<td nowrap="nowrap" align="right">state:</td>
<td><select name="select"width="40" >
<option>New Delhi
<option>Jammu & Kashmir
<option>Himachal Pradesh
<option>Kerala
<option>Karnatika
<option>West Bengal
<option>Orisa
<optionvalue="option1"selected>

</select></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">city:</td>
<td><select name="select"width="40" >
<option>Noida
<option>Gurgaon
<option>Gaziabad
<option>Jammu
<option>Srinagar
<option>Banglore
<option>Pune
<optionvalue="option1"selected>

</select></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Pincode:</td>
<td><input name="pincode" type="text" value="" size="32" maxlength="6" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Place:</td>
<td><input name="place" type="text" value="" size="32" maxlength="100" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Address:</td>
<td><textarea name="address" text="text" value="" cols="50" rows="3"></textarea></td>
</tr>

<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td><input type="submit" value="submit" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
<p> </p>
</body>
</html>
<?php
mysql_free_result($user);
?>
Last edited by Benjamin on Thu Sep 15, 2011 4:18 pm, edited 1 time in total.
Reason: Added [syntax=php|sql|css|javascript] and/or [text] tags.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: unable to retrive data

Post by Benjamin »

:arrow: Moved to PHP - Code
Post Reply