Avatar billede sadiq81 Nybegynder
24. august 2011 - 22:50 Der er 23 kommentarer

Genopfrisk indholdet af en div ved tryk på knap

Hej

Jeg er ved at lave en hjemmeside som generer en automatisk madplan for den kommende uge.

Det kan dog ske at samme ret kommer med 2 gange på en uge, og derfor vil jeg gerne have at man kan ændre den uden at genopfriske hele siden.


<div id="mandagTable">
<table border=1 width="400">
<tr>
<th>Monday:</th>
<th><?php print ($_POST [monday]) ;    ?></th>
<th><?php $mondayArray = ($_POST [monday]);
                   
$mondayArray = str_replace ( " ", "_", $mondayArray );

$mondaysdish = array_pop ( ${$mondayArray . 'Array'} );
               
print ($mondaysdish ['name']) ;    ?></th>

<th><?php print ($mondaysdish ['DATE_FORMAT(last_mad,\'%d/%m/%Y\')']) ;    ?></th>

</tr>
</table>
</div>   

Det som jeg gerne vil have opdateret er :

$mondaysdish = array_pop ( ${$mondayArray . 'Array'} );
               
print ($mondaysdish ['name']) ;    ?></th>

På forhånd tak.
Avatar billede majbom Novice
25. august 2011 - 08:01 #1
var det ikke smartere at sørge for at den ikke kan vælge samme ret 2 gange?
Avatar billede sadiq81 Nybegynder
25. august 2011 - 09:20 #2
Jooo men det er også en funktionalitet som jeg gerne kunne tænke mig at indføre på et senere tidspunkt alligevel.

Så på denne måde slipper jeg for at skulle programmere 2 ting :)
Avatar billede majbom Novice
25. august 2011 - 09:51 #3
det forstår jeg ikke - hvis du laver løsningen med at en ret kun kan tilføjes én gang, slipper du jo for denne opgave...
Avatar billede sadiq81 Nybegynder
25. august 2011 - 10:04 #4
Hvis man nu ikke er tilfreds med den ret som man får ud, så kan man få genereret en ny ret.
Avatar billede heinzdmx Nybegynder
25. august 2011 - 10:14 #5
Personligt ville jeg bruge jQuery og så lave en en funktion nogenlunde sådan her:

<script>
$(document).ready(function()
{

  $(".dindivklasse").click(function()
  {
      $.post("ajax.php", { value: "parameter", value2: "parameter2" },
        function(data)
        {
            this.html(data);
        });
  }
}


Se mere:
http://api.jquery.com/jQuery.post/


Og så skal du sådan set bare sørge for at din ajax.php modtager de parametre der er brug for og sender et gyldigt resultat tilbage
Avatar billede sadiq81 Nybegynder
25. august 2011 - 10:19 #6
Jeg kender ikke så meget til jquery og ajax, kunne du evt. pege på en god guide der dækker netop dette område?
Avatar billede heinzdmx Nybegynder
25. august 2011 - 10:23 #7
Avatar billede sadiq81 Nybegynder
25. august 2011 - 11:40 #8
Kan se at man også skal kende til DOM og javascript. Der er jeg heller ikke så god :/
Avatar billede olebole Juniormester
25. august 2011 - 16:04 #9
<ole>

Jeg foretager aldrig gynækologiske operationer, da jeg ikke ved noget særlig om emnet.

Hvis du vil lave avanceret frontendkode, bør du naturligvis lære det først  =)

/mvh
</bole>
Avatar billede sadiq81 Nybegynder
26. august 2011 - 18:35 #10
Så har jeg læst en bog om javascript. Meget lærende, man kan alligevel gøre tingene lidt mere levende.

Kigger på dine links nu.
Avatar billede olebole Juniormester
26. august 2011 - 18:47 #11
At lære JavaScript og avanceret kode kræver nok en del mere end at læse én bog. Webudvikling er et fag  *o)

Til gengæld lærer du ikke en dyt ved at bruge jQuery - og du har ikke hat begreb om, hvad der foregår i din kode
Avatar billede sadiq81 Nybegynder
27. august 2011 - 02:11 #12
nyt spørgsmål

Jeg har følgende kode:

<div id="mondayTable">

<table border=1 width="600">

<tr onmouseover="style.background='C0C0C0'" onmouseout="style.background='white'">

<th align="left" width="20%">Monday:&nbsp;</th>

<th align="left" width="20%"><?php print ($_POST [monday]);?>&nbsp;</th>

<th align="left" width="20%"><?php $mondayArray = ($_POST [monday]);
                           
$mondayArray = str_replace ( " ", "_", $mondayArray );

$mondaysdish = array_pop ( ${$mondayArray . 'Array'} );
               
print ($mondaysdish ['name']) ;    ?>&nbsp;</th>

<th align="left" width="20%"><?php print ($mondaysdish ['DATE_FORMAT(last_mad,\'%d/%m/%Y\')']) ;    ?>&nbsp;</th>
           
<?php

if ($mondaysdish != null)
{
?>
<th align="left" width="20%"><input type="button" value="New reciepe" onclick="getNewReceipe()">&nbsp;</th>
<?php
}
if ($mondaysdish == null)
{
?>
<th align="left" width="20%">&nbsp;</th>
<?php
}
?>
</tr>
</table>
</div>


Mit spørgsmål er så, hvordan får jeg værdien fra $_POST [monday] til at stå inde i mit funktionskald.

Altså getNewReceipe($_POST [monday])
Avatar billede sadiq81 Nybegynder
27. august 2011 - 14:09 #13
Har fundet ud af det.

Tak for at pege mig i den rigtige retning.

Hvis du smider et svar så accepterer jeg.

ps. brugte ikke jquery.
Avatar billede majbom Novice
27. august 2011 - 14:43 #14
og hvem vil du have svar fra?
Avatar billede sadiq81 Nybegynder
29. august 2011 - 12:36 #15
Den der kan svare mig på hvorfor mine hidden fields ikke bliver opdateret, men bare tomme.

madplan.php:


<html>
<head>
<title>FoodPlaner</title>



<style type="text/css">
.tal {
    text-align: right;
}
</style>


<script type="text/javascript">
function getNewReceipe(categori, day)
{
if (categori=="")
  {
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById(day).innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","newTable.php?q="+categori+"&day="+day,true);
xmlhttp.send();
}
</script>
</head>
<body>

<?php

error_reporting ( 0 );

$including = true;

include ('helper.php');

ini_set ( 'default_charset', 'UTF-8' );

?>

<center>



<h1>Kal kya pakaye.com</h1>

<script language="javascript" type="text/javascript">

function checkIfFeltIsTrue(felt){
   
if (felt[1].checked == true)
{
    return true;   
}
return false;
}

</script>


<?php
if (! isset ( $_POST [ja] ) and ! isset ( $_POST ["vaelgOpskrifter"] ) and (! isset ( $_POST [lockweeksrecepies] ))) {
    ?>
<h2>Lets make our menu</h2>

<form name="chooseInterval" method="post" action="<?php print "$_SERVER[PHP_SELF]";?>">

What interval do you want your menu? <br>
<br>
<table>
    <tr>
        <td>Next week<input type="radio" name="interval" value="nextWeek" onclick="document.chooseInterval.includingToday.checked = false"></td>
    </tr>
    <tr>
        <td>Rest of this week<input id="restOfThisWeek" type="radio" name="interval" value="restOfThisWeek">
        Including today?<input id= "includingToday" type="checkbox"    name="includingToday" onclick="return checkIfFeltIsTrue(document.chooseInterval.elements['interval'])"></td>
    </tr>
    <tr>
        <!-- <td>Just today<input type="radio" name="interval" value="onlyToday"></td> -->
    </tr>
</table>
<input type="submit" value="Lets do it!!!" name="ja">
</form>

<?php
}

if (isset ( $_POST [ja] )) {
    ?>

<form method="post" action="<?php print "$_SERVER[PHP_SELF]";?>">
<table border=1>
    <tbody>
        <tr>
       
        <?php
   
    $weekdaysPrint = array ("Monday", "Tuesday", "Wedensday", "Thursday", "Friday", "Saturday", "Sunday" );
   
    $dayOfTheWeek = 0;
   
    if ($_POST [interval] == "restOfThisWeek") {
        $dayOfTheWeek = ( integer ) date ( "w", time () );
       
        if (isset ( $_POST [includingToday] )) {
            $dayOfTheWeek -= 1;
        }
    }
   
    if ($_POST [interval] == "onlyToday") {
        $dayOfTheWeek = 6;
        $weekdaysPrint [6] = "Today";
    }
   
    for($optaelling1 = $dayOfTheWeek; $optaelling1 < 7; $optaelling1 ++)

    {
        print ("<th>") ;
        print $weekdaysPrint [$optaelling1];
        print ("</th>") ;
    }
   
    ?>
        </tr>
        <tr>

<?php
   
    $receipeCategories = array ("Rice with chicken", "Roti with ghost", "Roti with chicken", "Rice with ghost", "Other", "Weekend", "Day Off" );
    $weekdays = array ("monday", "tuesday", "wedensday", "thursday", "friday", "saturday", "sunday" );
   
    for($optaelling = $dayOfTheWeek; $optaelling < 7; $optaelling ++)
    {
        print ("<th>") ;
       
        print ("<select name=\"$weekdays[$optaelling]\">") ;
       
        for($count = 0; $count < 7; $count ++) {
           
            print ("<option value=\"" . $receipeCategories [$count]) ;
            if ($optaelling == $count)
            {
                print ("\" SELECTED ") ;
            }
            print ("\">" . $receipeCategories [$count]) ;
            print ("</option>") ;
            print ("\n") ;
        }
        print ("</select>") ;
        print ("\n") ;
        print ("</th>") ;
    }
    ?>
</tr>
    </tbody>
</table>
<br>
<input type="hidden" name="interval" value="<?php print ($_POST [interval]) ;?>">
<input type="hidden" name="includingToday" value="<?php    print ($_POST [includingToday]) ;?>">
<input type="submit" value="ok" name="vaelgOpskrifter">
<br>
<br>
<input type="button" value="Change your choice"    onclick="history.go(-1);return false;" /></form>
<?php
}
?>

<?php
if (isset ( $_POST [vaelgOpskrifter] )) {
   
    $weeksrecepies = array ($_POST [monday], $_POST [tuesday], $_POST [wedensday], $_POST [thursday], $_POST [friday], $_POST [saturday], $_POST [sunday] );
   
    if (in_array ( "Rice with chicken", $weeksrecepies )) {
        $Rice_with_chickenArray = getRiceWithChickenArray ();
        shuffle ( $Rice_with_chickenArray );
    }
   
    if (in_array ( "Rice with ghost", $weeksrecepies )) {
        $Rice_with_ghostArray = getRiceWithGhostArray ();
        shuffle ( $Rice_with_ghostArray );
    }
   
    if (in_array ( "Roti with chicken", $weeksrecepies )) {
        $Roti_with_chickenArray = getRotiWithChickenArray ();
        shuffle ( $Roti_with_chickenArray );
    }
   
    if (in_array ( "Roti with ghost", $weeksrecepies )) {
        $Roti_with_ghostArray = getRotiWithGhostArray ();
        shuffle ( $Roti_with_ghostArray );
    }
   
    if (in_array ( "Other", $weeksrecepies )) {
        $OtherArray = getOtherArray ();
        shuffle ( $OtherArray );
    }
   
    if (in_array ( "Weekend", $weeksrecepies )) {
        $WeekendArray = getWeekendArray ();
        shuffle ( $WeekendArray );
    }
   
    if (in_array ( "Day Off", $weeksrecepies )) {
        $DayOffArray = Array(" ", " ", " ", " ", " "," "," ");
       
    }
   

    ?>
   

<table border=1 width="600">
    <tbody>
        <tr>
            <th align="center" width="20%">Day to cook</th>
            <th align="center" width="20%">Type of Dish</th>
            <th align="center" width="20%">Name of Dish</th>
            <th align="center" width="20%">Last made</th>
            <th align="center" width="20%"> </th>
        </tr>
</table>

<?php
   
    if (($_POST [interval]) != "onlyToday")

    {
        ?>

<form method="post" action="<?php print "$_SERVER[PHP_SELF]"?>">
<div id="mondayTable">
<table border=1 width="600">
        <tr onmouseover="style.background='#C0C0C0'" onmouseout="style.background='white'">
            <th align="left" width="20%">Monday: </th>
            <th align="left" width="20%"><?php print ($_POST [monday]);?> </th>
            <th align="left" width="20%"><?php $mondayArray = ($_POST [monday]);
                           
                $mondayArray = str_replace ( " ", "_", $mondayArray );

                $mondaysdish = array_pop ( ${$mondayArray . 'Array'} );
               
                print ($mondaysdish ['name']) ;    ?> </th>
               
            <th align="left" width="20%"><?php print ($mondaysdish ['DATE_FORMAT(last_mad,\'%d/%m/%Y\')']) ;    ?> </th>
            <?php
            if ($mondaysdish != null)
            {
            ?>
            <th align="left" width="20%"><input type="button" value="New dish" onclick="getNewReceipe('<?php echo ($_POST [monday]);?>','mondayTable')"> </th>
            <?php
            }
            if ($mondaysdish == null)
            {
            ?>
            <th align="left" width="20%"> </th>
            <?php
            }
            ?>
        </tr>
</table>
<input type="hidden" value="<?php print ($mondaysdish ['name']);?>" name="monday">
<input type="hidden" value="<?php print ($_POST[monday]);?>" name="mondayCategori">
</div>       

<div id="tuesdayTable">
<table border=1 width="600">
        <tr onmouseover="style.background='#C0C0C0'" onmouseout="style.background='white'">
            <th align="left" width="20%">Tuesday: </th>
            <th align="left" width="20%"><?php print ($_POST [tuesday]) ;?> </th>
            <th align="left" width="20%"><?php $tuesdayArray = ($_POST [tuesday]);
               
                $tuesdayArray = str_replace ( " ", "_", $tuesdayArray );
               
                $tuesdaysdish = array_pop ( ${$tuesdayArray . 'Array'} );
               
                print ($tuesdaysdish ['name']) ;?> </th>
            <th align="left" width="20%"> <?php print ($tuesdaysdish ['DATE_FORMAT(last_mad,\'%d/%m/%Y\')']) ;    ?> </th>
            <?php
            if ($tuesdaysdish != null)
            {
            ?>
            <th align="left" width="20%"><input type="button" value="New dish" onclick="getNewReceipe('<?php echo ($_POST [tuesday]);?>','tuesdayTable')"> </th>
            <?php
            }
            if ($tuesdaysdish == null)
            {
            ?>
            <th align="left" width="20%"> </th>
            <?php
            }
            ?>       
        </tr>
</table>
<input type="hidden" value="<?php print ($tuesdaysdish ['name']);?>" name="tuesday">
<input type="hidden" value="<?php print ($_POST[tuesday]);?>" name="tuesdayCategori">
</div>
<div id="wedensdayTable">
<table border=1 width="600">
        <tr onmouseover="style.background='#C0C0C0'" onmouseout="style.background='white'">
            <th align="left" width="20%">Wedensday: </th>
            <th align="left" width="20%"><?php print ($_POST [wedensday]) ;?> </th>
            <th align="left" width="20%"><?php $wedensdayArray = ($_POST [wedensday]);
               
                $wedensdayArray = str_replace ( " ", "_", $wedensdayArray );
               
                $wedensdaysdish = array_pop ( ${$wedensdayArray . 'Array'} );
               
                print ($wedensdaysdish ['name']) ;?> </th>
            <th align="left" width="20%"><?php print ($wedensdaysdish ['DATE_FORMAT(last_mad,\'%d/%m/%Y\')']) ;    ?> </th>
            <?php
            if ($wedensdaysdish != null)
            {
            ?>
            <th align="left" width="20%"><input type="button" value="New dish" onclick="getNewReceipe('<?php echo ($_POST [wedensday]);?>','wedensdayTable')"> </th>
            <?php
            }
            if ($wedensdaysdish == null)
            {
            ?>
            <th align="left" width="20%"> </th>
            <?php
            }
            ?>
        </tr>
</table>
<input type="hidden" value="<?php print ($wedensdaysdish ['name']);?>" name="wedensday">
<input type="hidden" value="<?php print ($_POST[wedensday]);?>" name="wedensdayCategori">
</div>
<div id="thursdayTable">
<table border=1 width="600">
        <tr onmouseover="style.background='#C0C0C0'"    onmouseout="style.background='white'">
            <th align="left" width="20%">Thursday: </th>
            <th align="left" width="20%"><?php print ($_POST [thursday]) ; ?> </th>
            <th align="left" width="20%"><?php $thursdayArray = ($_POST [thursday]);
                           
                $thursdayArray = str_replace ( " ", "_", $thursdayArray );
           
                $thursdaysdish = array_pop ( ${$thursdayArray . 'Array'} );
               
                print ($thursdaysdish ['name']) ;?> </th>
            <th align="left" width="20%"> <?php print ($thursdaysdish ['DATE_FORMAT(last_mad,\'%d/%m/%Y\')']) ;    ?> </th>
            <?php
            if ($thursdaysdish != null)
            {
            ?>
            <th align="left" width="20%"><input type="button" value="New dish" onclick="getNewReceipe('<?php echo ($_POST [thursday]);?>','thursdayTable')"> </th>
            <?php
            }
            if ($thursdaysdish == null)
            {
            ?>
            <th align="left" width="20%"> </th>
            <?php
            }
            ?>
        </tr>
</table>
<input type="hidden" value="<?php print ($thursdaysdish ['name']);?>" name="thursday">
<input type="hidden" value="<?php print ($_POST[thursday]);?>" name="thursdayCategori">
</div>
<div id="fridayTable">
<table border=1 width="600">
        <tr onmouseover="style.background='#C0C0C0'" onmouseout="style.background='white'">
            <th align="left" width="20%">Friday: </th>
            <th align="left" width="20%"><?php print ($_POST [friday]) ;    ?> </th>
            <th align="left" width="20%"><?php $fridayArray = ($_POST [friday]);

                $fridayArray = str_replace ( " ", "_", $fridayArray );
               
                $fridaysdish = array_pop ( ${$fridayArray . 'Array'} );
               
                print ($fridaysdish ['name']) ;    ?> </th>
            <th align="left" width="20%"><?php print ($fridaysdish ['DATE_FORMAT(last_mad,\'%d/%m/%Y\')']) ;    ?> </th>
            <?php
            if ($fridaysdish != null)
            {
            ?>
            <th align="left" width="20%"><input type="button" value="New dish" onclick="getNewReceipe('<?php echo ($_POST [friday]);?>','fridayTable')"> </th>
            <?php
            }
            if ($fridaysdish == null)
            {
            ?>
            <th align="left" width="20%"> </th>
            <?php
            }
            ?>
        </tr>
</table>
<input type="hidden" value="<?php print ($fridaysdish ['name']);?>"    name="friday">
<input type="hidden" value="<?php print ($_POST[friday]);?>" name="fridayCategori">
</div>
<div id="saturdayTable">
<table border=1 width="600">
        <tr onmouseover="style.background='#C0C0C0'" onmouseout="style.background='white'">
            <th align="left" width="20%">Saturday: </th>
            <th align="left" width="20%"><?php print ($_POST [saturday]) ;?> </th>
            <th align="left" width="20%"><?php $saturdayArray = ($_POST [saturday]);
               
                $saturdayArray = str_replace ( " ", "_", $saturdayArray );
               
                $saturdaysdish = array_pop ( ${$saturdayArray . 'Array'} );
               
                print ($saturdaysdish ['name']) ;?> </th>
            <th align="left" width="20%"><?php print ($saturdaysdish ['DATE_FORMAT(last_mad,\'%d/%m/%Y\')']) ;?> </th>
            <?php
            if ($saturdaysdish != null)
            {
            ?>
            <th align="left" width="20%"><input type="button" value="New dish" onclick="getNewReceipe('<?php echo ($_POST [saturday]);?>','saturdayTable')"> </th>
            <?php
            }
            if ($saturdaysdish == null)
            {
            ?>
            <th align="left" width="20%"> </th>
            <?php
            }
            ?>
        </tr>
</table>
<input type="hidden" value="<?php print ($saturdaysdish ['name']);?>" name="saturday">
<input type="hidden" value="<?php print ($_POST[saturday]);?>" name="saturdayCategori">
</div>
<div id="sundayTable">
<table border=1 width="600">
        <tr onmouseover="style.background='#C0C0C0'" onmouseout="style.background='white'">
            <th align="left" width="20%">Sunday: </th>
            <th align="left" width="20%"><?php print ($_POST [sunday]) ;    ?> </th>
            <th align="left" width="20%"><?php $sundayArray = ($_POST [sunday]);
       
            $sundayArray = str_replace ( " ", "_", $sundayArray );
               
            $sundaysdish = array_pop ( ${$sundayArray . 'Array'} );
               
            print ($sundaysdish ['name']) ;    ?> </th>
            <th align="left" width="20%"><?php print ($sundaysdish ['DATE_FORMAT(last_mad,\'%d/%m/%Y\')']) ;    ?> </th>
            <?php
            if ($sundaysdish != null)
            {
            ?>
            <th align="left" width="20%"><input type="button" value="New dish" onclick="getNewReceipe('<?php echo ($_POST [sunday]);?>','sundayTable')"> </th>
            <?php
            }
            if ($sundaysdish == null)
            {
            ?>
            <th align="left" width="20%"> </th>
            <?php
            }
            ?>
        </tr>
</table>
<input type="hidden" value="<?php print ($sundaysdish ['name']);?>" name="sunday">
<input type="hidden" value="<?php print ($_POST[sunday]);?>" name="sundayCategori">
</div>
<input type="button" value=" <-- Choose other recepies "    onclick="history.go(-1);return false;" />
<br>
<br>
<input type="submit" name="lockweeksrecepies" value="Lock Recepies"    onmouseover="this.value='Recepies will be locked for 3 weeks!'"    onmouseout="this.value='Lock Recepies'">
</form>


<br>
<br>





<?php
    }
}

if (isset ( $_POST [lockweeksrecepies] )) {
   
    $message = '<html><body>';
    $message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
    $message .= "<tr style='background: #eee;'><td><strong>Day</strong></td><td><strong>Categori</strong></td><td><strong>Dish</strong></td></tr>";
    $message .= "<tr><td>Monday:</td><td>".$_POST[mondayCategori]."</td><td>".$_POST[monday]."</td></tr>";
    $message .= "<tr><td>Tuesday:</td><td>".$_POST[tuesdayCategori]."</td><td>".$_POST[tuesday]."</td></tr>";
    $message .= "<tr><td>Wedensday:</td><td>".$_POST[wedensdayCategori]."</td><td>".$_POST[wedensday]."</td></tr>";
    $message .= "<tr><td>Thursday:</td><td>".$_POST[thursdayCategori]."</td><td>".$_POST[thursday]."</td></tr>";
    $message .= "<tr><td>Friday:</td><td>".$_POST[fridayCategori]."</td><td>".$_POST[friday]."</td></tr>";
    $message .= "<tr><td>Saturday:</td><td>".$_POST[saturdayCategori]."</td><td>".$_POST[saturday]."</td></tr>";
    $message .= "<tr><td>Sunday:</td><td>".$_POST[sundayCategori]."</td><td>".$_POST[sunday]."</td></tr>";
    $message .= "</table>";
    $message .= "</body></html>";
   
//    $headers = "From: Foodplaner\r\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
       
    mail("tommy.lynge@gmail.com", "Weekmenu", $message, $headers);
   
    //    weekMenuApproved($_POST[monday], $_POST[tuesday], $_POST[wedensday], $_POST[thursday], $_POST[friday], $_POST[saturday], $_POST[sunday]);
   

    print ("Receipes locked!") ;
    print ("<br>") ;
    print ("<br>") ;
    print ("Check apka email for menu") ;
    print("<br>");
    print("<br>");

}
?>
</center>
</body>
</html>

newtable.php

<?php
$including = true;

include ('helper.php');


$q=$_GET["q"];
$day=$_GET["day"];



$array = array();

    switch ($q)
    {
        case "Rice with chicken" :
            $array = getRiceWithChickenArray();
            shuffle($array);
            break;
        case "Rice with ghost" :
            $array = getRiceWithGhostArray ();
            shuffle($array);
            break;
        case "Roti with chicken" :
            $array = getRotiWithChickenArray ();
            shuffle($array);
            break;
        case "Roti with ghost" :
            $array = getRotiWithGhostArray ();
            shuffle($array);
            break;
        case "Other" :
            $array = getOtherArray ();
            shuffle($array);
            break;
        case "Weekend" :
            $array = getWeekendArray ();
            shuffle($array);
            break;
    }

$weekday = str_replace ( "Table", "", $day );
$Weekday = ucfirst(str_replace ( "Table", "", $day ));



print ("<table border=1 width=\"600\">");
print ("<tr onmouseover=\"style.background='#C0C0C0'\" onmouseout=\"style.background='white'\"> ");
print ("<th align=\"left\" width=\"20%\">".$Weekday.": </th>");
print ("<th align=\"left\" width=\"20%\">". ($q) ." </th>");
print ("<th align=\"left\" width=\"20%\">");
           
                ${$weekday.'sdish'} = array_pop ($array);
               
                print (${$weekday.'sdish'} ['name']);

print (" ");
print ("</th>");
print ("<th align=\"left\" width=\"20%\">". ${$weekday.'sdish'}['DATE_FORMAT(last_mad,\'%d/%m/%Y\')']);
print (" </th>");
           
            if (${$weekday.'sdish'} != null)
            {
print ("<th align=\"left\" width=\"20%\"><input type=\"button\" value=\"Try again\" onclick=\"getNewReceipe('" . ($_GET ["q"]). "','".($_GET ["day"])."')\"> </th>");           
            }
            if (${$weekday.'sdish'} == null)
            {
print ("<th align=\"left\" width=\"20%\"> </th>");
            }
print ("</tr>");
print ("</table>");
print ("<input type=\"hidden\" value=\"". (${$weekday.'sdish'}['name'])."\" name=\"sunday\">");
print ("<input type=\"hidden\" value=\"".$q."\" name=\"sundayCategori\">");
?>
Avatar billede majbom Novice
29. august 2011 - 12:43 #16
det er lidt svært lige at overskue den lange kodestump dér - er det én fil?

kan du ikke smide det ind på pastebin.com og lægge link(s) her til filen/filerne?
Avatar billede sadiq81 Nybegynder
29. august 2011 - 13:00 #17
Avatar billede sadiq81 Nybegynder
29. august 2011 - 13:06 #18
Hvis der ellers er konstruktiv kritik til koden vil jeg gerne høre det :)
Avatar billede majbom Novice
29. august 2011 - 13:11 #19
$_POST [interval]


skal være uden mellemrum og helst med gåseøjne eller glyffer omkring key'en:

$_POST['interval']
Avatar billede sadiq81 Nybegynder
29. august 2011 - 13:46 #20
Det virker sålænge jeg ikke trykker på "new dish".
Avatar billede majbom Novice
29. august 2011 - 13:59 #21
har ikke lige umiddelbart noget bud, men kan kun fraråde dig at sende ren HTML vha AJAX, brug XML eller JSON formateret data, som det oprindelig er tiltænkt. så kan du generere dine tabeller i klienten bagefter, så er det også nemmere at fejlfinde...
Avatar billede sadiq81 Nybegynder
29. august 2011 - 15:03 #22
Har du nogle links til guides, eller kan du evt. anbefale en bog om emnet?
Avatar billede majbom Novice
29. august 2011 - 15:24 #23
her er en lille guide om json i javascript og php: http://ditio.net/2008/07/17/php-json-and-javascript-usage/

og lidt om dynamisk oprettelse af tabeller med java script: http://www.howtocreate.co.uk/tutorials/javascript/domtables

kender ingen af dem, søgte på google...
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester