Jump to content

How to echo a mysqli table


shadowpat
Go to solution Solved by jcbones,

Recommended Posts

Says the person who doesn't know what "sans" means... The irony ;)

ohhhh i assumed he meant "and"... i thought it was a typo.... haha, so what does it mean? Also, I got it working!!! Do you know how to turn every result into a table row with this code?

 

 

while($row = mysqli_fetch_array($result)) { 
   echo "<font color='grey'>".$row['date']."</font> ".$row['sender']." - ".$row['subject']."";
}
Please post the code if you get it working in a table.... I'm not sure of the best way to do it...... thanks!
I also have another question.... but I won't post it until i get this figured out.... thanks!
Edited by shadowpat
Link to comment
Share on other sites

Says the person who doesn't know what "sans" means... The irony ;)

 

okay got it working....

 

 

echo "<table border='1'>";
while($row = mysqli_fetch_array($result)) { //while you still have data left in the table:
   echo "<tr><td><font color='grey'>".$row['date']."</font></td><td> ".$row['sender']."</td><td> - ".$row['subject']."</td></tr>";
}
echo '</table>'; //ends the table.

 

is that a good way to do it?

Thanks....

on to the next question.....

 

This is what I want to achieve with this program I have been working on:

 

I have a user system that allows users to log in with their username and password...

I want the users to be able to send emails to each other, but without using email.

I will solve this by creating a table for each user (when the sign up) that is username-mail.. all of their mail is stored in there (is this a bad way to do it?)

 

so this is what a username-mail table would look like:

 

date-sender-subject-message

 

for example an entry might be:

 

5/12/13 bob mysubject mymessage

 

I told the script not to echo the message because it might get annoying if it is in the table too... so what i want to do (not sure if even possible) is to have a link at the end of each entry (after the subject) that will open a new window (or something of that sort) that shows the message.... for example, we would now have this:

 

5/12/13 bob mysubject open

 

Is this possible? Sorry about the really long explanation... Please let me know how I should do this!

Thanks!

Link to comment
Share on other sites

Says the person who doesn't know what "sans" means... The irony ;)

Okay got that working too!

I used the JavaScript document.open() like this:

 

 

<script language=JavaScript>
function createDoc()
  {
  var doc=document.open(\"text/html\",\"replace\");
  var txt=\"$row[message]\";
  doc.write(txt);
  doc.close();
  }
</script>

 

i just echoed that along with my script, and had a button that (when clicked) would call createDoc() and then it would output the message.. ;)

Edited by shadowpat
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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