לוגו אתר Fresh          
 
 
  אפשרות תפריט  ראשי     אפשרות תפריט  צ'אט     אפשרות תפריט  מבזקים     אפשרות תפריט  צור קשר     חץ שמאלה ‎print ‎"Hello World!"; if‎ ‎not rules.‎know ‎then rules.‎read(); חץ ימינה  

לך אחורה   לובי הפורומים > מחשבים > תכנות ובניית אתרים
שמור לעצמך קישור לדף זה באתרי שמירת קישורים חברתיים
תגובה
 
כלי אשכול חפש באשכול זה



  #1  
ישן 19-06-2007, 18:38
  yoda69 yoda69 אינו מחובר  
 
חבר מתאריך: 19.06.07
הודעות: 3
העברת משתנים מדף אחד לשני

שלום,
אני מצליח להעביר משתנה(id$) מדף php אחד לשני. הבעיה היא שבדף השני יש לינק בראש טבלה (שמחזירה תוצאות ממסד נתונים MYSQL) שמאפשרת למשתמש לסדר את התוצאות לפי סדר עולה או יורד.
הכל עובד בסדר, והמתשנה באמת עובר בצורה תקינה בין הדפים. אבל ברגע שהמשתמש לוחץ על הלינק, המשתנה מאפס את עצמו..... לא מצליח למצוא לזה פיתרון. אשמח לקבל עזרה ועצות...

הנה הקוד לדף הראשון:
<?PHP
$db = mysql_connect("localhost","root","test") or die("Problem connecting");
mysql_select_db("education") or die("Problem selecting database");
$query = "SELECT * From teachers";
$result = mysql_query($query) or die ("Query failed");
//let's get the number of rows in our result so we can use it in a for loop
$numofrows = mysql_num_rows($result);

echo "<TABLE class=\"maintable\" BORDER=1 frame=box width=100% CELLPADDING=0 CELLSPACING=1 >\n";
echo "<TR bgcolor=\"lightblue\">
<TD>Teacher</TD>
</TR>\n";
for($i = 0; $i < $numofrows; $i++) {
$row = mysql_fetch_array($result); //get a row from our result set
if($i % 2) { //this means if there is a remainder
echo "<TR bgcolor=\"#CCFFCC\">\n";
} else { //if there isn't a remainder we will do the else
echo "<TR bgcolor=\"#BFD8BC\">\n";
}
echo"
<TD><a href='bymaster.php?id={$row[id]}'>".stripslashes($ row[teacher_name])."</a></TD>
\n";
echo "</TR>\n";
}
//now let's close the table and be done with it
echo "</TABLE>\n";
?>

והקוד לדף השני:

<?PHP


$db = mysql_connect("localhost","root","test") or die("Problem connecting");
mysql_select_db("education") or die("Problem selecting database");

//set a direction for the search. If none is set, we'll choose ASC
if(!isset($_GET['direction'])){
$direction = 'ASC';
}else{
$direction = $_GET['direction'];
}
//set the newdirection as the opposite to the old
if($direction=="ASC"){
$newdirection= "DESC";
}else{
$newdirection = "ASC";
}
if(isset($_GET['orderby'])){
$query = "SELECT * FROM classes, teachers, types WHERE (classes.teacher_id=teachers.id AND classes.discipline_id=classes.id AND teachers.id=$id) ORDER BY '$_GET[orderby]' $direction";
}else{
$query = "SELECT * FROM classes, teachers, types WHERE (classes.teacher_id=teachers.id AND classes.discipline_id=classes.id AND teachers.id=$id)";
}

$result = mysql_query($query) or die ("Main Query failed");
//let's get the number of rows in our result so we can use it in a for loop
$numofrows = mysql_num_rows($result);

echo "<TABLE class=\"maintable\" BORDER=1 frame=box width=100% CELLPADDING=0 CELLSPACING=1 >\n";
echo "<TR bgcolor=\"lightblue\">
<TD><a href='".$_SERVER["PHP_SELF"]."?orderby=start_date& direction=".($newdirection)."'>Start Date</a></TD>
<TD><a href='".$_SERVER["PHP_SELF"]."?orderby=title&direc tion=".($newdirection)."'>Title</a></TD>
<TD>Type</TD>
<TD>Teacher</TD>
</TR>\n";
for($i = 0; $i < $numofrows; $i++) {
$row = mysql_fetch_array($result); //get a row from our result set
if($i % 2) { //this means if there is a remainder
echo "<TR bgcolor=\"#CCFFCC\">\n";
} else { //if there isn't a remainder we will do the else
echo "<TR bgcolor=\"#BFD8BC\">\n";
}
echo"
<TD>".$row['start_date']."</TD>
<TD><a href='/showall.php?primary_index={$row[primary_ind ex]}'>".stripslashes($row[title])."</a></TD>
<TD>".$row['type_name']."</TD>
<TD>".$row['teacher_name']."</TD>
\n";
echo "</TR>\n";
}
//now let's close the table and be done with it
echo "</TABLE>\n";
mysql_free_result($result);
?>
תגובה ללא ציטוט תגובה עם ציטוט חזרה לפורום
תגובה

כלי אשכול חפש באשכול זה
חפש באשכול זה:

חיפוש מתקדם
מצבי תצוגה דרג אשכול זה
דרג אשכול זה:

מזער את תיבת המידע אפשרויות משלוח הודעות
אתה לא יכול לפתוח אשכולות חדשים
אתה לא יכול להגיב לאשכולות
אתה לא יכול לצרף קבצים
אתה לא יכול לערוך את ההודעות שלך

קוד vB פעיל
קוד [IMG] פעיל
קוד HTML כבוי
מעבר לפורום



כל הזמנים המוצגים בדף זה הם לפי איזור זמן GMT +2. השעה כעת היא 10:07

הדף נוצר ב 0.04 שניות עם 12 שאילתות

הפורום מבוסס על vBulletin, גירסא 3.0.6
כל הזכויות לתוכנת הפורומים שמורות © 2024 - 2000 לחברת Jelsoft Enterprises.
כל הזכויות שמורות ל Fresh.co.il ©

צור קשר | תקנון האתר