Jump to content

PHP/MySQL Array Newbie Help


Acuity

Recommended Posts

I created a shell script in OS X which forces my Macbook to connect to a MySQL database to see if my laptop was stolen.  I can mark the Macbook as stolen in the database, which would provide me with a series of fuctions; one of these functions allows you to take pictures through the iSight camera and upload to an FTP server.  The script and database work well, but now I'm trying to make it more user friendly by making it web-based.

 

Here is an example of the code I'm having trouble with:

 

$picture = mysql_query("SELECT picture FROM laptops");

$picrow = mysql_fetch_array($picture);

 

if ( $picrow[0] == 0){

echo "<td>" . "<center><a href='start.php?cmd=start&id=$row[uID]'><img

src='images/stopped.gif'></center></a>" . "</td>";

 

} else {

 

echo "<td>" . "<center><a href='stop.php?cmd=stop&id=$row[uID]'><img

src='images/started.gif'></center></a>" . "</td>";

 

}

 

In the database there is a "1" for active and a "0" for inactive.  What it's looking to do is ask to see if it's active or inactive.  If it's active, it will have a green button, and inactive with have a red button.  Eventually I'd like to be able to activate and deactivate functions by pressing the button, but I need to complete step 1 first.

 

Currently this code does work (except for the links of course); however, I need to specify the number in the array ($picrow[0], $picrow[1], etc.)  How do I have this populate automatically from 0 to infinity?  I made a field in the database called UID (starting at 1) that automatically increments.  I'm not sure if this

would help or not.

 

Thanks in advance.

 

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.