473,503 Members | 1,650 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

display sql data on webpage with php

77 New Member
Hi ppl,

I am trying to insert records into my database using a form. this works. but after this i would like the records to be displayed onto another page.. the database gets updated but the webpage i want the data to be displayed remains empty....any suggestions..

code so far.

[PHP]
<?php require_once('Connections/mysql_connect.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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":
$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"] == "form2")) {
$insertSQL = sprintf("INSERT INTO `assignment submission sheet` (`Student number`, `Pathway / Course`, `Essay only`, `Marking tutor name`, `Module unit title`, `Module number`, `Assignment title`) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['Student_number'], "int"),
GetSQLValueString($_POST['Pathway__Course'], "text"),
GetSQLValueString($_POST['Essay_only'], "int"),
GetSQLValueString($_POST['Marking_tutor_name'], "text"),
GetSQLValueString($_POST['Module_unit_title'], "text"),
GetSQLValueString($_POST['Module_number'], "text"),
GetSQLValueString($_POST['Assignment_title'], "text"));

mysql_select_db($database_mysql_connect, $mysql_connect);
$Result1 = mysql_query($insertSQL, $mysql_connect) or die(mysql_error());

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

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO `assignment submission sheet` (`Student number`, `Pathway / Course`, `Essay only`, `Marking tutor name`, `Module unit title`, `Module number`, `Assignment title`) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['Student_number'], "int"),
GetSQLValueString($_POST['Pathway__Course'], "text"),
GetSQLValueString($_POST['Essay_only'], "int"),
GetSQLValueString($_POST['Marking_tutor_name'], "text"),
GetSQLValueString($_POST['Module_unit_title'], "text"),
GetSQLValueString($_POST['Module_number'], "text"),
GetSQLValueString($_POST['Assignment_title'], "text"));

mysql_select_db($database_mysql_connect, $mysql_connect);
$Result1 = mysql_query($insertSQL, $mysql_connect) or die(mysql_error());

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

mysql_select_db($database_mysql_connect, $mysql_connect);
$query_Recordset2 = "SELECT * FROM `assignment submission sheet`";
$Recordset2 = mysql_query($query_Recordset2, $mysql_connect) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);
?><!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>
</head>

<body>
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Student number:</td>
<td><input name="Student_number" type="text" value="" size="32" maxlength="7" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Pathway / Course:</td>
<td><input name="Pathway__Course" type="text" value="" size="32" maxlength="30" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Essay only:</td>
<td><input name="Essay_only" type="text" value="" size="32" maxlength="7" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Marking tutor name:</td>
<td><input name="Marking_tutor_name" type="text" value="" size="32" maxlength="25" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Module unit title:</td>
<td><input name="Module_unit_title" type="text" value="" size="32" maxlength="30" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Module number:</td>
<td><input name="Module_number" type="text" value="" size="32" maxlength="10" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Assignment title:</td>
<td><input name="Assignment_title" type="text" value="" size="32" maxlength="30" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">&nbsp;</td>
<td><input type="submit" value="Insert record" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
<p>&nbsp;</p>
</body>
</html>
<?php
mysql_free_result($Recordset2);
?> [/PHP]
Oct 9 '08 #1
4 2439
Markus
6,050 Recognized Expert Expert
Isn't the code you provided the code that inserts the data into the database? And didn't you say the database was getting updated? If yes to both of these, we need to see the code that pulls the data from the database and displays it. Otherwise, ... where's the coffee?
Oct 9 '08 #2
Mubs
77 New Member
Isn't the code you provided the code that inserts the data into the database? And didn't you say the database was getting updated? If yes to both of these, we need to see the code that pulls the data from the database and displays it. Otherwise, ... where's the coffee?

lol..
sorry..

code:

[PHP]<?php require_once('Connections/mysql_connect.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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":
$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"] == "form2")) {
$insertSQL = sprintf("INSERT INTO `assignment submission sheet` (`Student number`, `Pathway / Course`, `Essay only`, `Marking tutor name`, `Module unit title`, `Module number`, `Assignment title`) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['Student_number'], "int"),
GetSQLValueString($_POST['Pathway__Course'], "text"),
GetSQLValueString($_POST['Essay_only'], "int"),
GetSQLValueString($_POST['Marking_tutor_name'], "text"),
GetSQLValueString($_POST['Module_unit_title'], "text"),
GetSQLValueString($_POST['Module_number'], "text"),
GetSQLValueString($_POST['Assignment_title'], "text"));

mysql_select_db($database_mysql_connect, $mysql_connect);
$Result1 = mysql_query($insertSQL, $mysql_connect) or die(mysql_error());

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

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO `assignment submission sheet` (`Student number`, `Pathway / Course`, `Essay only`, `Marking tutor name`, `Module unit title`, `Module number`, `Assignment title`) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['Student_number'], "int"),
GetSQLValueString($_POST['Pathway__Course'], "text"),
GetSQLValueString($_POST['Essay_only'], "int"),
GetSQLValueString($_POST['Marking_tutor_name'], "text"),
GetSQLValueString($_POST['Module_unit_title'], "text"),
GetSQLValueString($_POST['Module_number'], "text"),
GetSQLValueString($_POST['Assignment_title'], "text"));

mysql_select_db($database_mysql_connect, $mysql_connect);
$Result1 = mysql_query($insertSQL, $mysql_connect) or die(mysql_error());

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

mysql_select_db($database_mysql_connect, $mysql_connect);
$query_Recordset2 = "SELECT * FROM `assignment submission sheet`";
$Recordset2 = mysql_query($query_Recordset2, $mysql_connect) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);
?><!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>
</head>

<body>
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Student number:</td>
<td><input name="Student_number" type="text" value="" size="32" maxlength="7" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Pathway / Course:</td>
<td><input name="Pathway__Course" type="text" value="" size="32" maxlength="30" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Essay only:</td>
<td><input name="Essay_only" type="text" value="" size="32" maxlength="7" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Marking tutor name:</td>
<td><input name="Marking_tutor_name" type="text" value="" size="32" maxlength="25" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Module unit title:</td>
<td><input name="Module_unit_title" type="text" value="" size="32" maxlength="30" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Module number:</td>
<td><input name="Module_number" type="text" value="" size="32" maxlength="10" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Assignment title:</td>
<td><input name="Assignment_title" type="text" value="" size="32" maxlength="30" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">&nbsp;</td>
<td><input type="submit" value="Insert record" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
<p>&nbsp;</p>
</body>
</html>
<?php
mysql_free_result($Recordset2);
?> [/PHP]
Oct 9 '08 #3
Mubs
77 New Member
wrong one..

correct code

[PHP]<?php require_once('Connections/mysql_connect.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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":
$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;
}
}

mysql_select_db($database_mysql_connect, $mysql_connect);
$query_Recordset2 = "SELECT * FROM `assignment submission sheet`";
$Recordset2 = mysql_query($query_Recordset2, $mysql_connect) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);
?><!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>
</head>

<body>
</body>
</html>
<?php
mysql_free_result($Recordset2);
?>[/PHP]
Oct 9 '08 #4
Markus
6,050 Recognized Expert Expert
Ok, you've kind of selected the data from the database, but how are you displaying it? Or is that the problem you have - displaying the data?

If so, check out this.
Oct 9 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1605
by: javacelt | last post by:
Good afternoon, I am looking to be able to view CSV date in a table on a webpage. I don't want to manipulate the data at all on the webpage, simply view in a table. I am having real troubles...
2
2517
by: Naha | last post by:
Hi Guys, Does anyone know how to display data from a text file onto a webpage? So far I have opened and read the data in the text file and printed it out on command line, but I am having...
1
941
by: Dan Somdahl | last post by:
Hi, I am new to ASP but have what should be a fairly simple task that I can't figure out. I need to parse a string from a single, semi-colon delimited, 60 character field (el_text) in a recordset...
3
3172
by: BOBss | last post by:
I am using ASP with VBScript. I want to query an access database username field, and display the output as a hyperlink on an a webpage.The webpage will display all records. I then need to be able...
10
20283
by: Lorie0114 | last post by:
Hello, We have an issue that I do not know how to resolve. Our website has several hundred reports. There are a handful of them that are causing issues when there is no interaction for a couple...
2
3221
by: wreed06 | last post by:
Hello, I have 2 problems. In my webpage, I have a dropdown list with a button that takes the user to a popup window specific to the option. I am using Firefox 2.0.0.13. I have successfully...
5
1950
by: wreed06 | last post by:
I have 2 problems. In my webpage, I have a dropdown list with a button that takes the user to a popup window specific to the option. I am using Firefox 2.0.0.13. I have successfully validated my HTML...
4
4393
by: eschneider | last post by:
I get the following error when trying to browse the .asmx. I get the same thing when trying to add a reference. using .NET 2.0 There is no error message. Any ideas? Thanks,
9
5966
by: Mel | last post by:
I have some Asp.net 2.0/vb.net code that creates a gantt chart with some dependencies as a new MS Project (.mpp) file. How would I show this resulting .mpp file on an Asp.net webpage? I want to...
3
2173
by: 532054 | last post by:
when i fill this form i need to display data on my webpage how can i do this form page = http://rightmotion.com/reservation.php where i need to display data =...
0
7084
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7278
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7328
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7458
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5013
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
380
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.