Jump to content

array


Jenling

Recommended Posts

Dear expert,

I want to use array to do the system. I want to get the query from database and use array to display the data. How can I do that? My code is as below:

<?
$sql="select MRname from meetingroom";
$resu = mysql_query($sql, $connect) or die('Error when running command<br>'.$sql);
$num=@mysql_num_rows($resu);
while($row_Recordset=mysql_fetch_array($resu, MYSQL_BOTH)){
$m=array($row_Recordset[MRname]);
}

 

$meeting = array($m);

Link to comment
https://forums.phpfreaks.com/topic/99925-array/
Share on other sites

Some thing like this could work:

 

<?php
$myArray
$sql="select MRname from meetingroom";
$resu = mysql_query($sql, $connect) or die('Error when running command<br>'.$sql);
$num=@mysql_num_rows($resu);
while($row_Recordset=mysql_fetch_array($resu, MYSQL_BOTH)){
    $myArray[] = $row_Recordset['Column_Name_Here'];
}
?>

Link to comment
https://forums.phpfreaks.com/topic/99925-array/#findComment-510959
Share on other sites

try

<?php

$sql="select MRname from meetingroom";
$resu = mysql_query($sql, $connect) or die('Error when running command<br>'.$sql);

$m = array();                                                        // create empty array
while($row_Recordset=mysql_fetch_assoc($resu)){
    $m[] = $row_Recordset['MRname'];                                 // add names to array
}

// output the array
foreach ($m as $room)
{
    echo $room, '<br />';
}

?>

Link to comment
https://forums.phpfreaks.com/topic/99925-array/#findComment-511003
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.