Welcome to Dream.In.Code
Click Here
Getting PHP Help is Easy!

Join 117,572 PHP Programmers for FREE! Ask your question and get quick answers from experts. There are 1,878 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Create dynamic page with PHP

 
Reply to this topicStart new topic

Create dynamic page with PHP

cygnusX
post 23 Jul, 2008 - 07:49 AM
Post #1


D.I.C Head

**
Joined: 19 May, 2007
Posts: 152


My Contributions


Ok,i have some buttons,and drop-down boxes and when one of the buttons is clicked or the visitor choose item from the drop-down box the content in certain div must be replaced with data from a database.How to do that?I'm new to web programming so please give some good example...yes,there are many tutorials on internet but they're very vague and very different from each other and that's confusing.I need just a simple example(if it's possible).

This post has been edited by cygnusX: 23 Jul, 2008 - 07:51 AM
User is offlineProfile CardPM

Go to the top of the page


grimpirate
post 23 Jul, 2008 - 12:03 PM
Post #2


D.I.C Head

Group Icon
Joined: 3 Aug, 2006
Posts: 177



Thanked 5 times

Dream Kudos: 375
My Contributions


PHP
echo '<form method="POST" action="' . basename(__FILE__) . '">';
echo '<p><input type="radio" name="yes" CHECKED> Yes</p>';
echo '<p><input type="radio" name="no"> No</p>';
echo '<input type="submit">';
echo '</form>';
if(isset($_POST['yes'])){
echo 'YES';
}else{
echo 'NO';
}
By selecting an alternate radio button you'll see the page switch from YES to NO as you submit the form.
User is offlineProfile CardPM

Go to the top of the page

cygnusX
post 24 Jul, 2008 - 10:41 AM
Post #3


D.I.C Head

**
Joined: 19 May, 2007
Posts: 152


My Contributions


Well,i don't know what this code really does,but i doubt it will do what i want.I said "the content in certain div must be replaced with data from a database".Thanks anyway...some other guy said that i must use JavaScript/Ajax to do that.I thought that's very simple task.Isn't that the way most of the webpages works?I just need to connect to the database,and according to the incoming information from the database to create some elements in the page - divs,images,text,blah blah...
User is offlineProfile CardPM

Go to the top of the page

coolbhatia18
post 24 Jul, 2008 - 11:33 PM
Post #4


New D.I.C Head

*
Joined: 13 Jul, 2008
Posts: 5

<code>
<?php
$conn = mysql_connect("localhost","varun","iceman");
mysql_select_db("gamesframework",$conn);

$sql = "SELECT * FROM category";
$display_block="<ul>";
$result = mysql_query($sql, $conn) or die(mysql_error());

while ($newArray = mysql_fetch_array($result))
{
$name= $newArray['name'];
$id= $newArray['id'];
$display_block .= "
<li><a href=\"viewgameslist.php?id=$id\">
<strong>$name</strong></a><br>

";
}
$display_block .="</ul>";



if ($_GET[id]>0)
{
$sql1 = "SELECT * FROM category_game where category_id = $_GET[id]";
$display_block1="<ul>";
$result1 = mysql_query($sql1, $conn) or die(mysql_error());

while ($newArray1 = mysql_fetch_array($result1))
{
$game_id1= $newArray1['game_id'];

$sql2 = "SELECT name,id FROM game where id = '$game_id1'";
$result2 = mysql_query($sql2, $conn) or die(mysql_error());
while ($newArray2 = mysql_fetch_array($result2))
{
$game_name= $newArray2['name'];
$id=$newArray2['id'];




$display_block1 .= "
<li><a href=\"viewgamedetails.php?id=$id\">
<strong>$game_name</strong></a><br>

";
}
}
$display_block1 .="</ul>";
}
?>

<html>
<head>
<title>Update Game</title>
</head>
<body>
<spacer type=horizontal size=300>
<a href="index.php">
<strong>Home</strong></a><br>
<h1>Choose Game Category</h1>
<p><?php echo $display_block ?></p>
<p><?php echo $display_block1 ?></p>



</body>
</html>
</code>

hope this helps.... i reload the same page and pass value 2 it usin GET. when there is a user click its corresponding value is passed.. and $display_block1 is generated an displayed... if u dnt understand completely ... do ask!
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 10/7/08 08:34PM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month