Reputation: 667
this is my code
<select>
<?php
$query = "SELECT * FROM 'sections'";
$result = mysql_query($query);
while($row=mysql_fetch_array($result)){
echo "<option value='".$row[id]."'>".$row[sectionName]."</option>";
}
?>
</select>
nothing happen I don't know why this my page maybe there is wrong some where
<?php
ob_start();
session_start();
include('../includes/connect.php');
include('../includes/phpCodes.php');
?>
<!DOCTYPE html>
<html>
<head>
<title>لوحة التحكم</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="../css/mainstyle.css">
<link rel="stylesheet" type="text/css" href="css/controlstyle.css">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#tabs div').hide();
$('#tabs div:first').show();
$('#tabs ul li:first').addClass('active');
$('#tabs ul li a').click(function(){
$('#tabs ul li').removeClass('active');
$(this).parent().addClass('active');
var currentTab = $(this).attr('href');
$('#tabs div').hide();
$(currentTab).show();
return false;
});
});
</script>
</head>
<body>
<div class="wrapper">
<?php headerCode(); ?>
<div class="content">
<div id="tabs">
<ul>
<li><a href="#add">اضافة موضوع</a></li>
<li><a href="#remove">حذف موضوع</a></li>
<li><a href="#edit">تعديل موضوع</a></li>
<li><a href="#edit">التحكم بالاقسام</a></li>
</ul>
<div id="add">
<form method="POST" action="includes/add.php" dir="rtl" enctype="multipart/from-data">
<br>
حدد القسم :
<select>
<?php
$query = "SELECT * FROM 'sectionsd'";
$result = mysql_query($query);
while($row=mysql_fetch_array($result)){
echo "<option value='".$row[id]."'>".$row[sectionName]."</option>";
}?>
</select><br>
عنوان الموضوع :<input type="text" name="title" class="mem-information"/><br>
الموضوع : <br /><textarea name="subject" rows="10" cols="50" class="mem-information" style="width: 500px"></textarea><br /><br>
الصورة :<input type="file" name="image"><br>
<input type="submit" value="إرسال" name="send" class="log" style="color: black">
</form>
</div>
<div id="remove">
<form method="POST" action="includes/remove.php" dir="rtl"><br>
حدد القسم :
<select name ="sectionsName">
<option value="">dd</option>
</select>
<input type="submit" value="حذف" name="send" class="log" style="color: black">
</form>
</div>
<div id="edit">
</div>
<div id="addDep">
</div>
</div>
</div>
</div>
</body>
</html>
sorry for my bad English my table
Upvotes: 3
Views: 38899
Reputation: 1
echo '
<option value='.$row["id"].'>'.$row["sectionName"].'</option>
';
Upvotes: 0
Reputation: 38645
The problem I see is you are using single quotes on your table name in your query, you should either use back tick or no back ticks for table name. Please try the following code:
<?php
$query = "SELECT * FROM `sections`";
$result = mysql_query($query);
while($row=mysql_fetch_array($result, MYSQL_ASSOC)){
echo "<option value='".$row['id']."'>".$row['sectionName']."</option>";
}
?>
Also start looking into using mysqli
(http://php.net/manual/en/book.mysqli.php) or PDO
(http://php.net/manual/en/book.pdo.php), as mysql
is deprecated.
Upvotes: 7
Reputation: 786
Try this... And we are all Asuming the name of the column is "sectionsd" with the "d".
<?php
$query = "SELECT * FROM 'sectionsd'";
$result = mysql_query($query);
while($row=mysql_fetch_assoc($result)){
echo "<option value='".$row["id"]."'>".$row["sectionName"]."</option>";
}?>
</select>
If it's not working it may be due to:
1) You're using a mysql_ function and you're not sending the parameter $link to the function. Like: mysql_query($query, $connectionlink);
2) The table name is wrong
3) You have an error: Use mysql_query() or die(mysql_error()); to see what's going on
4) DO NOT use single quotes ' around your table name in the query
Upvotes: 1