Help Me Plezz

Jun 23, 2008

how to insert many data in the database..?? i had the coding but it will return value to 0.. so how i'm gonna to make it appear my value..
<?php require_once('Connections/mas.php'); ?>

<?php

$host="localhost"; // Host name
$username="root"; // Mysql username
$password="123"; // Mysql password
$db_name="mas"; // Database name
$tbl_name="medic_registered_course"; // Table name

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

// Get values from form
$matric_no=$_POST['matric_no'];
$block=$_POST['block'];
$s_code=$_POST['s_code'];
$sessi=$_POST['sessi'];
$year=$_POST['year'];
$group=$_POST['group'];

// Insert data into mysql
$sql="INSERT INTO $tbl_name(`matric_no`, `block`, `s_code`, `sessi`, `year`, `group`)VALUES('$matric_no', '$block', '$s_code', '$sessi', '$year', '$group')";
$result=mysql_query($sql);

// if successfully insert data into database, displays message "Successful".
if($result){
echo "Successful";
echo "<BR>";

}

else {
echo "ERROR";
}

// close connection
mysql_close();
?>
<?php
mysql_select_db($database_mas, $mas);
$query_terd = "SELECT medic_block_reg.matric_no, medic_block_reg.block, medic_block_reg.name,medic_subject_offered.s_code, medic_block_reg.sessi, medic_block_reg.`year`, medic_block_reg.`group`, medic_block_reg.status, medic_subject_offered.s_title FROM medic_block_reg, medic_subject_offered ORDER BY `matric_no` ASC";
$terd = mysql_query($query_terd, $mas) or die(mysql_error());
$row_terd = mysql_fetch_assoc($terd);
$totalRows_terd = mysql_num_rows($terd);





?>

<!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">
<!--
.style1 {
font-size: 18px;
font-weight: bold;
}
-->
</style>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
<p align="center" class="style1">LIST REGISTERED SUBJECTS</p>
<p align="center"> </p>
<p>Matric No:
<input name="textfield" type="text" id="textfield" value="<?php echo $row_terd['matric_no']; ?>" />
Year :

<input name="textfield3" type="text" id="textfield3" value="<?php echo $row_terd['year']; ?>" size="5" />
</p>
<p>Name :
<input name="textfield2" type="text" id="textfield2" value="<?php echo $row_terd['name']; ?>" size="50" />
</p>
<p> </p>
</form>

<form id="form2" name="form2" method="post" action="">
<table width="598" height="69" border="1" align="center">
<tr>
<th width="138" scope="col">S_Code</th>
<th width="124" scope="col">S_Title</th>
<th width="79" scope="col">Sessi</th>
<th width="72" scope="col">Block</th>
<th width="73" scope="col">Group</th>
<th width="72" scope="col">Status</th>
</tr>
<tr>
<td><div align="center"><?php echo $row_terd['s_code']; ?></div></td>
<td><?php echo $row_terd['s_title']; ?></td>
<td><div align="center"><?php echo $row_terd['sessi']; ?></div></td>
<td><div align="center"><?php echo $row_terd['block']; ?></div></td>
<td><div align="center"><?php echo $row_terd['group']; ?></div></td>
<td><div align="center"><?php echo $row_terd['status']; ?></div></td>
</tr>
</table>
<p>  </p>
<p align="center">
<input type="submit" name="button" id="button" value="ADD" />
<input type="submit" name="button2" id="button2" value="DROP" onclick="return confirmLink(this, 'ALTER TABLE `medic_registered_course` DROP `matric_no`')"/>

</p>
<div align="center">
<p> </p>
<p class="style10"><a href="reg_main.php">Back</a> | <a href="main.php">Module Menu</a> | <a href="<?php echo $logoutAction ?>" onclick="MM_popupMsg('You're successfully logout from this system...')">Logout</a></p>
</div>
</form>
</body>
</html>
<?php
mysql_free_result($terd);


?>

View 3 Replies


ADVERTISEMENT

Help Me Making FOR XML QUERY Plezz!!

Sep 20, 2007

OK Here goes my BIG question


I've following database structure (just junk values)

[ChannelID]---[ChannelName]---[ChannelCatID]---[RSSFeedURL]

1---YouTube---1---ret---
2---GoogleVideo---1---ert---
3---MSNVideo---1---rtertert---
4---ABC---2---retert---
5---YahooVideo---1---erter---
6---CBS---2---rtr---
7---NBC---2---trtrt---
8---ESPN---2---rt---
9---FOX---2---rtrtttr---
10---AOL---1---rt---

I wanna generate following XML structure out of it

<DOC>
-<Item Type="xyz">
--<Channel id="a">
---<Name>aaaaa<Name/>
---<URL>aaaaa<URL/>
--</Channel>

--<Channel id="b">
---<Name>bbbb<Name/>
---<URL>bbbb<URL/>
--</Channel>
---
---
-</Item>

-<Item Type="lmn">
--<Channel id="x">
---<Name>xxxx<Name/>
---<URL>xxxx<URL/>
--</Channel>

--<Channel id="y">
---<Name>yyyy<Name/>
---<URL>yyyy<URL/>
--</Channel>
---
---
-</Item>
------
------
------
</DOC>

I've written this Select For XML query

SELECT ChannelCatID as '@type',
ChannelID as 'Channel/@id',
ChannelName as 'Channel/Name',
RSSFeedURL as 'Channel/URL'
FROM ChannelMaster
FOR XML PATH('Item'), ROOT('DOC')


It gives me this result
<DOC>
-<Item Type="xyz">
--<Channel id="a">
---<Name>aaaaa<Name/>
---<URL>aaaaa<URL/>
--</Channel>
-</Item>
-<Item Type="xyz">
--<Channel id="b">
---<Name>bbbb<Name/>
---<URL>bbbb<URL/>
--</Channel>
-</Item>
-<Item Type="xyz">
---
-</Item>
-<Item Type="xyz">
---
-</Item>
------
------
------
</DOC>

I want it this way :

all channels of Type xyz should come under singe <Item Type="xyz"> tag instead of seperate tags

what changes should i make, plezz help meout wit dis ??

.(][)[](][).

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved