Jump to content

online php tutorial error???


burge124

Recommended Posts

hi, here is my modified code from the online tutorial, this connects to the table "chapter" and within that table are ChapterID (pk) and ChapterTitle. Any help would be great!

 

<?

// Connect database

mysql_connect("localhost","root","");

mysql_select_db("questiondb");

 

// If submitted, check the value of "select". If its not blank value, get the value and put it into $select.

if(isset($select)&&$select!=""){

$select=$_GET['select'];

}

?>

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

</head>

<body>

<form id="form1" name="form1" method="get" action="<? echo $PHP_SELF; ?> ">

Car company :

<select name="select">

<option value="">--- Select ---</option>

<?

// Get records from database (table "chapter").

$list=mysql_query("SELECT * FROM chapter ORDER BY ChapterID asc");

 

// Show records by while loop.

while($row_list=mysql_fetch_assoc($list)){

?>

<option value="<? echo $row_list['ChapterID']; ?>" <? if($row_list['ChapterID']==$select){ echo "selected"; } ?>><? echo $row_list['ChapterTitle']; ?></option>

<?

// End while loop.

}

?>

</select>

<input type="submit" name="Submit" value="Select" />

</form>

<hr>

<p>

<?

// If you have selected from list box.

if(isset($select)&&$select!=""){

 

// Get records from database (table "chapter").

$result=mysql_query("SELECT * FROM chapter WHERE ChapterID='$select'");

$row=mysql_fetch_assoc($result);

?>

Information about <strong><? echo $row['ChapterTitle']; ?></strong> company...</p>

<p>........................................<br>

........................................<br>

........................................

<?

// End if statement.

}

 

// Close database connection.

mysql_close();

?>

</p>

</body>

</html>

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.