עבור לתוכן

תאים כפולים בטבלה ב php

Featured Replies

פורסם

בבסיס נתונים יש טבלה

| Intel | 478 | P4 |
| AMD | 754 | AXP Mobile |

וקובץ php שאמור להוציא אותה (כולה) באתר

<?php
if (!mysql_select_db('TEST4'))
die("Can't select database TEST4");

echo ("<table><tr><td>manufacturer</td><td>socket</td><td>cpu</td></tr>") ;
$result = mysql_query("SELECT * FROM TBL_HARDWARE");
while($row = mysql_fetch_array($result))
{
echo ("<tr>") ;
foreach ($row as $cell)
{
echo ("<td>".$cell."</td>") ;
}
echo ("</tr>") ;
}
echo ("</table>") ;
?>

הקובץ שהגולש באתר רואה נראה כך

| manufacturer | socket | cpu |
| Intel | Intel | 478 | 478 | P4 | P4 |
| AMD | AMD | 754 | 754 | AXP Mobile | AXP Mobile |

ניסיתי להוסיף בדיקה מאיפה זה מגיע

...
$i = 0 ;
...
echo ("<td>".$i++.$cell."</td>") ;
...

תוצאה

| manufacturer | socket | cpu |
| 0Intel | 1Intel | 2478 | 3478 | 4P4 | 5P4 |
| 6AMD | 7AMD | 8754 | 9754 | 10AXP Mobile | 11AXP Mobile |

פורסם
  • מחבר

עובד - תודה

  • 4 שבועות מאוחר יותר...
פורסם

נחמד וזה עובד מצויין תודה רבה

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים